MapProc.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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]; #使用传送门的场景的地图id
  43. $x = req()->paras[1]; # 提取参数
  44. $y = req()->paras[2];
  45. $z = req()->paras[3];
  46. $newMap = ctx()->newMap(true);
  47. $curMapId = $newMap->curMapId;
  48. $itemId = 0;
  49. $dic = ctx()->store()->items;
  50. foreach ($dic as $id => $num) {
  51. $subType = GameConfig::item_base_getItem($id)->subType;
  52. if($subType == 344){
  53. $itemId = $id;
  54. break;
  55. }
  56. }
  57. my_Assert($itemId != 0, ErrCode::err_const_no);
  58. StoreProc::removeItemFromStore(ctx()->store, $itemId);
  59. $gateZone = GameConfig::gate_zone();
  60. my_Assert($gateZone != null, ErrCode::err_const_no);
  61. foreach ($gateZone as $zoneid => $val) {
  62. $list = explode(',', $val->contains);
  63. if(in_array($curMapId, $list)){
  64. $mid = $list[0];
  65. break;
  66. }
  67. }
  68. $newMap->curMapId = $mid;
  69. $data = new Ins_ChuansongzhenMapData();
  70. $data->mapId = $mid;
  71. $data->lastMapId = $mapId;
  72. $data->position_x = $x;
  73. $data->position_y = $y;
  74. $data->position_z = $z;
  75. $newMap->huichengquanRecord->$mid = $data;
  76. ctx()->newMap = $newMap;
  77. UserProc::updateUserInfo();
  78. return Resp::ok(
  79. array("newMap" => $newMap,)
  80. );
  81. }
  82. /**
  83. * [7508] 回城券的传送阵结束
  84. * @return Resp
  85. */
  86. public static function huichengQuanEnd() {
  87. //$mapid = req()->paras[0]; # 提取参数
  88. $newMap = ctx()->newMap();
  89. $curMapId = $newMap->curMapId;
  90. // $zoneId = GameConfig::map_scene_getItem($curMapId)->zoneId;
  91. // $item = GameConfig::map_scene_zoneid_getItemArray($zoneId)[0];
  92. $lastMapid = $curMapId;
  93. $gateZone = GameConfig::gate_zone();
  94. my_Assert($gateZone != null, ErrCode::err_const_no);
  95. foreach ($gateZone as $zoneid => $val) {
  96. $list = explode(',', $val->contains);
  97. if(in_array($curMapId, $list)){
  98. $lastMapid = $list[0];
  99. break;
  100. }
  101. }
  102. if(StlUtil::dictHasProperty($newMap->huichengquanRecord, $lastMapid)){
  103. StlUtil::dictRemove($newMap->huichengquanRecord, $lastMapid);
  104. }
  105. ctx()->newMap = $newMap;
  106. UserProc::updateUserInfo();
  107. return Resp::ok(
  108. array("newMap" => $newMap,)
  109. );
  110. }
  111. /**
  112. * [7506] 领取探索奖励
  113. * @return Resp
  114. */
  115. public static function reviceExplorerReward() {
  116. $mapid = req()->paras[0]; # 提取参数
  117. $newMap = ctx()->newMap();
  118. $newMap->unlockedFootholds->$mapid->exploreRewardGeted = true;
  119. $cost = GameConfig::gate_getItem($mapid)->exploreReward;
  120. StoreProc::AddMultiItemInStore($cost);
  121. ctx()->newMap = $newMap;
  122. UserProc::updateUserInfo();
  123. return Resp::ok(
  124. array("newMap" => $newMap, "cost" => $cost,)
  125. );
  126. }
  127. /**
  128. * 7505
  129. * @return Resp
  130. */
  131. public static function unlockInfoSva() {
  132. $unlockStr = req()->paras[0]; # 提取参数
  133. $newMap = ctx()->newMap();
  134. if (!StlUtil::dictHasProperty($newMap, 'unlockMapTypeList')) {
  135. $newMap->unlockMapTypeList = new \stdClass();
  136. }
  137. $mapid = explode('_', $unlockStr)[0];
  138. $type = explode('_', $unlockStr)[1];
  139. $typeid = explode('_', $unlockStr)[2];
  140. if (!StlUtil::dictHasProperty($newMap->unlockMapTypeList, $mapid)) {
  141. $newMap->unlockMapTypeList->$mapid = array();
  142. }
  143. $tag = 1;
  144. $tylist = $newMap->unlockMapTypeList->$mapid;
  145. foreach ($tylist as $str) {
  146. $slist = explode('_', $str);
  147. if ($slist[0] == $mapid && $slist[1] == $type && $slist[2] == $typeid) {
  148. $tag = 0;
  149. break;
  150. }
  151. }
  152. $num = 0;
  153. if ($tag) {
  154. $newMap->unlockMapTypeList->$mapid[] = $unlockStr;
  155. my_Assert(StlUtil::dictHasProperty($newMap->unlockedFootholds, $mapid), ErrCode::map_Unlocked);
  156. $newMap->curMapId = $mapid;
  157. $arr = self::countFootHoldExplorerNum($mapid, $type, $typeid, $newMap);
  158. $explorerNum = $arr[0];
  159. $num = $arr[1];
  160. $newMap->unlockedFootholds->$mapid->curExploreProgress = $explorerNum;
  161. if ($type == Enum_ExploreType::Npc && $newMap->unlockedFootholds->$mapid->transmissionIsOk == false) {
  162. $subtype = GameConfig::npc_getItem($typeid)->subtype;
  163. if ($subtype == Enum_ExploreSubType::Teleporter) {//传送带
  164. $newMap->unlockedFootholds->$mapid->transmissionIsOk = true;
  165. }
  166. }
  167. }
  168. ctx()->newMap = $newMap;
  169. UserProc::updateUserInfo();
  170. return Resp::ok(array("newMap" => $newMap, "tag" => $tag, 'num' => $num,));
  171. }
  172. /*
  173. * 计算探索度值
  174. */
  175. public static function countFootHoldExplorerNum($mapid, $type, $id, $newMap) {
  176. $explorer = 0;
  177. $num = 0;
  178. $retArr = array();
  179. if (StlUtil::dictHasProperty($newMap->unlockMapTypeList, $mapid)) {
  180. $list = $newMap->unlockMapTypeList->$mapid;
  181. $mapList = GameConfig::map_explorer_getItemArray($mapid);
  182. $tempList = array();
  183. if ($mapList != null) {
  184. foreach ($mapList as $item) {
  185. if ($item->paras == null) {
  186. continue;
  187. }
  188. $cmd = $item->cmd;
  189. $parasList = explode(',', $item->paras);
  190. if ($type == $cmd && $id == $parasList[0]) {
  191. $num = $parasList[1];
  192. }
  193. foreach ($list as $para) {
  194. $strList = explode('_', $para);
  195. $tempStr = $strList[1] . '-' . $strList[2];
  196. if (in_array($tempStr, $tempList)) {
  197. continue;
  198. }
  199. if ($strList[1] == $cmd && $strList[2] == $parasList[0]) {
  200. $tempList[] = $tempStr;
  201. $explorer += $parasList[1];
  202. }
  203. }
  204. }
  205. }
  206. }
  207. $retArr[] = $explorer;
  208. $retArr[] = $num;
  209. return $retArr;
  210. }
  211. /**
  212. * 7504 解锁地图
  213. * @return Resp
  214. */
  215. public static function UnlockMap() {
  216. $targetMapId = req()->paras[0]; # 提取参数
  217. $newMap = ctx()->newMap();
  218. # 检查目标地图是否已经解锁
  219. my_Assert(!isset($newMap->unlockedFootholds->$targetMapId), ErrCode::map_Unlocked);
  220. $mo = GameConfig::gate_getItem($targetMapId);
  221. $footHold = new Ins_FootHold();
  222. $footHold->mapId = $mo->gateId;
  223. $footHold->curMapType = $mo->mapType;
  224. $this->unlockedFootholds->$targetMapId = $footHold; # 添加解锁据点数据
  225. ctx()->newMap = $newMap;
  226. UserProc::updateUserInfo();
  227. return Resp::ok($newMap);
  228. }
  229. /**
  230. * 7501 进入据点
  231. * @return Resp
  232. */
  233. public static function EnterFootHold() {
  234. $targetMapId = req()->paras[0]; # 提取参数
  235. $newMap = ctx()->newMap();
  236. # 检查目标地图是否已经解锁
  237. my_Assert(isset($newMap->unlockedFootholds->$targetMapId), ErrCode::map_NotUnlocked);
  238. $newMap->curMapId = $targetMapId;
  239. ctx()->newMap = $newMap;
  240. UserProc::updateUserInfo();
  241. return Resp::ok();
  242. }
  243. /**
  244. * 7502 开启传送阵
  245. * @return Resp
  246. */
  247. public static function FixUpTransmision() {
  248. }
  249. /**
  250. * 7503 更新探索进度
  251. * @return Resp
  252. */
  253. public static function UpdateExplorationProgress() {
  254. }
  255. }