MapProc.php 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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] 领取探索奖励cmd_store_huichengQuanUse
  28. return self::reviceExplorerReward();
  29. case CmdCode::map_huichengQuanUse: # [7507]
  30. return self::huichengQuanUse();
  31. case CmdCode::map_huichengQuanEnd: # [7508]
  32. return self::huichengQuanEnd();
  33. default: # err: 未知的命令码
  34. return Resp::err(ErrCode::cmd_err);
  35. }
  36. }
  37. /**
  38. * [7507]
  39. * @return Resp
  40. */
  41. public static function huichengQuanUse() {
  42. $mapId = req()->paras[0];
  43. $itemId = req()->paras[1]; # 提取参数
  44. $newMap = ctx()->newMap(true);
  45. StoreProc::removeItemFromStore(ctx()->store, $itemId);
  46. $zoneId = GameConfig::map_scene_getItem($mapId)->zoneId;
  47. $dic = GameConfig::map_scene();
  48. my_Assert($dic != null, ErrCode::err_const_no);
  49. $item = GameConfig::map_scene_zoneid_getItemArray($zoneId)[0];
  50. $newMap->curMapId = $item->mapId;
  51. $newMap->huichengquanRecord[] = $item->mapId;
  52. ctx()->newMap = $newMap;
  53. UserProc::updateUserInfo();
  54. return Resp::ok(
  55. array("newMap" => $newMap,)
  56. );
  57. }
  58. /**
  59. * [7508] 回城券的传送阵结束
  60. * @return Resp
  61. */
  62. public static function huichengQuanEnd() {
  63. $mapid = req()->paras[0]; # 提取参数
  64. $newMap = ctx()->newMap();
  65. //$initMapid = 1001;
  66. // my_Assert(in_array($mapid,$newMap->huichengquanRecord), ErrCode::map_NotChuanSongZhen);
  67. if(in_array($mapid, $newMap->huichengquanRecord)){
  68. StlUtil::arrayRemove($newMap->huichengquanRecord, $mapid);
  69. }
  70. ctx()->newMap = $newMap;
  71. UserProc::updateUserInfo();
  72. return Resp::ok(
  73. array("newMap" => $newMap,)
  74. );
  75. }
  76. /**
  77. * [7506] 领取探索奖励
  78. * @return Resp
  79. */
  80. public static function reviceExplorerReward() {
  81. $mapid = req()->paras[0]; # 提取参数
  82. $newMap = ctx()->newMap();
  83. $newMap->unlockedFootholds->$mapid->exploreRewardGeted = true;
  84. $cost = GameConfig::map_scene_getItem($mapid)->exploreReward;
  85. StoreProc::AddMultiItemInStore($cost);
  86. ctx()->newMap = $newMap;
  87. UserProc::updateUserInfo();
  88. return Resp::ok(
  89. array("newMap" => $newMap, "cost" => $cost,)
  90. );
  91. }
  92. /**
  93. * 7505
  94. * @return Resp
  95. */
  96. public static function unlockInfoSva() {
  97. $unlockStr = req()->paras[0]; # 提取参数
  98. $newMap = ctx()->newMap();
  99. if (!StlUtil::dictHasProperty($newMap, 'unlockMapTypeList')) {
  100. $newMap->unlockMapTypeList = new \stdClass();
  101. }
  102. $mapid = explode('_', $unlockStr)[0];
  103. $type = explode('_', $unlockStr)[1];
  104. $typeid = explode('_', $unlockStr)[2];
  105. if (!StlUtil::dictHasProperty($newMap->unlockMapTypeList, $mapid)) {
  106. $newMap->unlockMapTypeList->$mapid = array();
  107. }
  108. $tag = 1;
  109. $tylist = $newMap->unlockMapTypeList->$mapid;
  110. foreach ($tylist as $str) {
  111. $slist = explode('_', $str);
  112. if ($slist[0] == $mapid && $slist[1] == $type && $slist[2] == $typeid) {
  113. $tag = 0;
  114. break;
  115. }
  116. }
  117. $num = 0;
  118. if ($tag) {
  119. $newMap->unlockMapTypeList->$mapid[] = $unlockStr;
  120. my_Assert(StlUtil::dictHasProperty($newMap->unlockedFootholds, $mapid), ErrCode::map_Unlocked);
  121. $arr = self::countFootHoldExplorerNum($mapid, $type, $typeid, $newMap);
  122. $explorerNum = $arr[0];
  123. $num = $arr[1];
  124. $newMap->unlockedFootholds->$mapid->curExploreProgress = $explorerNum;
  125. if ($type == Enum_ExploreType::Npc && $newMap->unlockedFootholds->$mapid->transmissionIsOk == false) {
  126. $subtype = GameConfig::npc_getItem($typeid)->subtype;
  127. if ($subtype == Enum_ExploreSubType::Teleporter) {//传送带
  128. $newMap->unlockedFootholds->$mapid->transmissionIsOk = true;
  129. }
  130. }
  131. }
  132. ctx()->newMap = $newMap;
  133. UserProc::updateUserInfo();
  134. return Resp::ok(array("newMap" => $newMap, "tag" => $tag, 'num' => $num,));
  135. }
  136. /*
  137. * 计算探索度值
  138. */
  139. public static function countFootHoldExplorerNum($mapid, $type, $id, $newMap) {
  140. $explorer = 0;
  141. $num = 0;
  142. $retArr = array();
  143. if (StlUtil::dictHasProperty($newMap->unlockMapTypeList, $mapid)) {
  144. $list = $newMap->unlockMapTypeList->$mapid;
  145. $mapList = GameConfig::map_explorer_getItemArray($mapid);
  146. $tempList = array();
  147. if ($mapList != null) {
  148. foreach ($mapList as $item) {
  149. if ($item->paras == null) {
  150. continue;
  151. }
  152. $cmd = $item->cmd;
  153. $parasList = explode(',', $item->paras);
  154. if ($type == $cmd && $id == $parasList[0]) {
  155. $num = $parasList[1];
  156. }
  157. foreach ($list as $para) {
  158. $strList = explode('_', $para);
  159. $tempStr = $strList[1] . '-' . $strList[2];
  160. if (in_array($tempStr, $tempList)) {
  161. continue;
  162. }
  163. if ($strList[1] == $cmd && $strList[2] == $parasList[0]) {
  164. $tempList[] = $tempStr;
  165. $explorer += $parasList[1];
  166. }
  167. }
  168. }
  169. }
  170. }
  171. $retArr[] = $explorer;
  172. $retArr[] = $num;
  173. return $retArr;
  174. }
  175. /**
  176. * 7504 解锁地图
  177. * @return Resp
  178. */
  179. public static function UnlockMap() {
  180. $targetMapId = req()->paras[0]; # 提取参数
  181. $newMap = ctx()->newMap();
  182. # 检查目标地图是否已经解锁
  183. my_Assert(!isset($newMap->unlockedFootholds->$targetMapId), ErrCode::map_Unlocked);
  184. $mo = GameConfig::map_scene_getItem($targetMapId);
  185. $footHold = new Ins_FootHold();
  186. $footHold->mapId = $mo->mapId;
  187. $footHold->curMapType = $mo->mapType;
  188. $this->unlockedFootholds->$targetMapId = $footHold; # 添加解锁据点数据
  189. ctx()->newMap = $newMap;
  190. UserProc::updateUserInfo();
  191. return Resp::ok($newMap);
  192. }
  193. /**
  194. * 7501 进入据点
  195. * @return Resp
  196. */
  197. public static function EnterFootHold() {
  198. $targetMapId = req()->paras[0]; # 提取参数
  199. $newMap = ctx()->newMap();
  200. # 检查目标地图是否已经解锁
  201. my_Assert(isset($newMap->unlockedFootholds->$targetMapId), ErrCode::map_NotUnlocked);
  202. $newMap->curMapId = $targetMapId;
  203. ctx()->newMap = $newMap;
  204. UserProc::updateUserInfo();
  205. return Resp::ok();
  206. }
  207. /**
  208. * 7502 开启传送阵
  209. * @return Resp
  210. */
  211. public static function FixUpTransmision() {
  212. }
  213. /**
  214. * 7503 更新探索进度
  215. * @return Resp
  216. */
  217. public static function UpdateExplorationProgress() {
  218. }
  219. }