MapProc.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. if (!StlUtil::dictHasProperty($newMap->unlockMapTypeList, $mapid)) {
  61. $newMap->unlockMapTypeList->$mapid = array();
  62. }
  63. $newMap->unlockMapTypeList->$mapid[] = $unlockStr;
  64. my_Assert(StlUtil::dictHasProperty($newMap->unlockedFootholds,$mapid), ErrCode::map_Unlocked);
  65. $explorerNum = self::countFootHoldExplorerNum($mapid, $newMap);
  66. $newMap->unlockedFootholds->$mapid->curExploreProgress = $explorerNum;
  67. $type = explode('_', $unlockStr)[1];
  68. if ($type == 6 && $newMap->unlockedFootholds->$mapid->transmissionIsOk == false) {//临时代码,6代表传送带
  69. $newMap->unlockedFootholds->$mapid->transmissionIsOk = true;
  70. }
  71. ctx()->newMap = $newMap;
  72. UserProc::updateUserInfo();
  73. return Resp::ok($newMap);
  74. }
  75. /*
  76. * 计算探索度值
  77. */
  78. public static function countFootHoldExplorerNum($mapid, $newMap) {
  79. $explorer = 0;
  80. if (StlUtil::dictHasProperty($newMap->unlockMapTypeList, $mapid)) {
  81. $list = $newMap->unlockMapTypeList->$mapid;
  82. $mapList = GameConfig::map_explorer_getItemArray($mapid);
  83. $tempList = array();
  84. if ($mapList != null) {
  85. foreach ($mapList as $item) {
  86. if($item->paras == null){
  87. continue;
  88. }
  89. $cmd = $item->cmd;
  90. $parasList = explode(',', $item->paras);
  91. foreach ($list as $para) {
  92. $strList = explode('_', $para);
  93. $tempStr = $strList[1].'-'.$strList[2];
  94. if(in_array($tempStr, $tempList)){
  95. continue;
  96. }
  97. if ($strList[1] == $cmd && $strList[2] == $parasList[0]) {
  98. $tempList[] = $tempStr;
  99. $explorer += $parasList[1];
  100. }
  101. }
  102. }
  103. }
  104. }
  105. return $explorer;
  106. }
  107. /**
  108. * 7504 解锁据点
  109. * @return Resp
  110. */
  111. public static function UnlockMap() {
  112. $targetMapId = req()->paras[0]; # 提取参数
  113. $newMap = ctx()->newMap();
  114. # 检查目标地图是否已经解锁
  115. my_Assert(!isset($newMap->unlockedFootholds->$targetMapId), ErrCode::map_Unlocked);
  116. $mo = GameConfig::map_scene_getItem($targetMapId);
  117. $footHold = new Ins_FootHold();
  118. $footHold->mapId = $mo->mapId;
  119. $footHold->curMapType = $mo->mapType;
  120. $this->unlockedFootholds->$targetMapId = $footHold; # 添加解锁据点数据
  121. ctx()->newMap = $newMap;
  122. UserProc::updateUserInfo();
  123. return Resp::ok($newMap);
  124. }
  125. /**
  126. * 7501 进入据点
  127. * @return Resp
  128. */
  129. public static function EnterFootHold() {
  130. $targetMapId = req()->paras[0]; # 提取参数
  131. $newMap = ctx()->newMap();
  132. # 检查目标地图是否已经解锁
  133. my_Assert(isset($newMap->unlockedFootholds->$targetMapId), ErrCode::map_NotUnlocked);
  134. $newMap->curMapId = $targetMapId;
  135. ctx()->newMap = $newMap;
  136. UserProc::updateUserInfo();
  137. return Resp::ok();
  138. }
  139. /**
  140. * 7502 开启传送阵
  141. * @return Resp
  142. */
  143. public static function FixUpTransmision() {
  144. }
  145. /**
  146. * 7503 更新探索进度
  147. * @return Resp
  148. */
  149. public static function UpdateExplorationProgress() {
  150. }
  151. }