MapProc.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <?php
  2. namespace loyalsoft;
  3. /**
  4. * Description of MapProc
  5. * 地图数据处理逻辑
  6. * @author gwang
  7. */
  8. class MapProc {
  9. /**
  10. * 地图处理逻辑分发
  11. * 所有的Proc中必须有这样一个方法
  12. */
  13. static function procMain() {
  14. switch (req()->cmd) {
  15. case CmdCode::map_EnterFootHold: # [7501] 进入据点
  16. return self::EnterFootHold();
  17. case CmdCode::map_FixUpTransmission: # [7502] 开启传送阵
  18. return self::FixUpTransmision();
  19. case CmdCode::map_UpdateExplorerationProgress: # [7503] 更新探索进度
  20. return self::UpdateExplorationProgress();
  21. case CmdCode::map_UnlockMap: # [7504] 解锁据点
  22. return self::UnlockMap();
  23. // case CmdCode::map_getUnlockInfoList: # [7505] 获取mapid下已经解锁的列表
  24. // return self::getUnlockInfoList();
  25. case CmdCode::map_unlockInfoSva: # [7505] 保存mapid下已经解锁的
  26. return self::unlockInfoSva();
  27. case CmdCode::map_reviceExplorerReward: # [7506] 领取探索奖励
  28. return self::reviceExplorerReward();
  29. default: # err: 未知的命令码
  30. return Resp::err(ErrCode::cmd_err);
  31. }
  32. }
  33. /**
  34. *
  35. * @return Resp
  36. */
  37. public static function reviceExplorerReward() {
  38. $mapid = req()->paras[0]; # 提取参数
  39. $newMap = ctx()->newMap();
  40. $newMap->unlockedFootholds->$mapid->exploreRewardGeted = true;
  41. $cost = GameConfig::map_scene_getItem($mapid)->exploreReward;
  42. StoreProc::AddMultiItemInStore($cost);
  43. ctx()->newMap = $newMap;
  44. UserProc::updateUserInfo();
  45. return Resp::ok(
  46. array("newMap"=>$newMap,"cost"=>$cost,)
  47. );
  48. }
  49. /**
  50. * 7505
  51. * @return Resp
  52. */
  53. public static function unlockInfoSva() {
  54. $unlockStr = req()->paras[0]; # 提取参数
  55. $newMap = ctx()->newMap();
  56. if (!StlUtil::dictHasProperty($newMap, 'unlockMapTypeList')) {
  57. $newMap->unlockMapTypeList = new \stdClass();
  58. }
  59. $mapid = explode('_', $unlockStr)[0];
  60. $type = explode('_', $unlockStr)[1];
  61. $typeid = explode('_', $unlockStr)[2];
  62. if (!StlUtil::dictHasProperty($newMap->unlockMapTypeList, $mapid)) {
  63. $newMap->unlockMapTypeList->$mapid = array();
  64. }
  65. $tag = 1;
  66. $tylist = $newMap->unlockMapTypeList->$mapid;
  67. foreach ($tylist as $str) {
  68. $slist = explode('_', $str);
  69. if($slist[0] == $mapid && $slist[1] == $type && $slist[2]==$typeid){
  70. $tag = 0;
  71. break;
  72. }
  73. }
  74. if($tag){
  75. $newMap->unlockMapTypeList->$mapid[] = $unlockStr;
  76. my_Assert(StlUtil::dictHasProperty($newMap->unlockedFootholds,$mapid), ErrCode::map_Unlocked);
  77. $explorerNum = self::countFootHoldExplorerNum($mapid, $newMap);
  78. $newMap->unlockedFootholds->$mapid->curExploreProgress = $explorerNum;
  79. //$type = explode('_', $unlockStr)[1];
  80. if ($type == 6 && $newMap->unlockedFootholds->$mapid->transmissionIsOk == false) {//临时代码,6代表传送带
  81. $newMap->unlockedFootholds->$mapid->transmissionIsOk = true;
  82. }
  83. }
  84. ctx()->newMap = $newMap;
  85. UserProc::updateUserInfo();
  86. return Resp::ok(array("newMap"=>$newMap,"tag"=>$tag,));
  87. }
  88. /*
  89. * 计算探索度值
  90. */
  91. public static function countFootHoldExplorerNum($mapid, $newMap) {
  92. $explorer = 0;
  93. if (StlUtil::dictHasProperty($newMap->unlockMapTypeList, $mapid)) {
  94. $list = $newMap->unlockMapTypeList->$mapid;
  95. $mapList = GameConfig::map_explorer_getItemArray($mapid);
  96. $tempList = array();
  97. if ($mapList != null) {
  98. foreach ($mapList as $item) {
  99. if($item->paras == null){
  100. continue;
  101. }
  102. $cmd = $item->cmd;
  103. $parasList = explode(',', $item->paras);
  104. foreach ($list as $para) {
  105. $strList = explode('_', $para);
  106. $tempStr = $strList[1].'-'.$strList[2];
  107. if(in_array($tempStr, $tempList)){
  108. continue;
  109. }
  110. if ($strList[1] == $cmd && $strList[2] == $parasList[0]) {
  111. $tempList[] = $tempStr;
  112. $explorer += $parasList[1];
  113. }
  114. }
  115. }
  116. }
  117. }
  118. return $explorer;
  119. }
  120. /**
  121. * 7504 解锁据点
  122. * @return Resp
  123. */
  124. public static function UnlockMap() {
  125. $targetMapId = req()->paras[0]; # 提取参数
  126. $newMap = ctx()->newMap();
  127. # 检查目标地图是否已经解锁
  128. my_Assert(!isset($newMap->unlockedFootholds->$targetMapId), ErrCode::map_Unlocked);
  129. $mo = GameConfig::map_scene_getItem($targetMapId);
  130. $footHold = new Ins_FootHold();
  131. $footHold->mapId = $mo->mapId;
  132. $footHold->curMapType = $mo->mapType;
  133. $this->unlockedFootholds->$targetMapId = $footHold; # 添加解锁据点数据
  134. ctx()->newMap = $newMap;
  135. UserProc::updateUserInfo();
  136. return Resp::ok($newMap);
  137. }
  138. /**
  139. * 7501 进入据点
  140. * @return Resp
  141. */
  142. public static function EnterFootHold() {
  143. $targetMapId = req()->paras[0]; # 提取参数
  144. $newMap = ctx()->newMap();
  145. # 检查目标地图是否已经解锁
  146. my_Assert(isset($newMap->unlockedFootholds->$targetMapId), ErrCode::map_NotUnlocked);
  147. $newMap->curMapId = $targetMapId;
  148. ctx()->newMap = $newMap;
  149. UserProc::updateUserInfo();
  150. return Resp::ok();
  151. }
  152. /**
  153. * 7502 开启传送阵
  154. * @return Resp
  155. */
  156. public static function FixUpTransmision() {
  157. }
  158. /**
  159. * 7503 更新探索进度
  160. * @return Resp
  161. */
  162. public static function UpdateExplorationProgress() {
  163. }
  164. }