MapProc.php 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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. $num = 0;
  75. if($tag){
  76. $newMap->unlockMapTypeList->$mapid[] = $unlockStr;
  77. my_Assert(StlUtil::dictHasProperty($newMap->unlockedFootholds,$mapid), ErrCode::map_Unlocked);
  78. $arr = self::countFootHoldExplorerNum($mapid,$type,$typeid, $newMap);
  79. $explorerNum = $arr[0];
  80. $num = $arr[1];
  81. $newMap->unlockedFootholds->$mapid->curExploreProgress = $explorerNum;
  82. if ($type == 2 && $newMap->unlockedFootholds->$mapid->transmissionIsOk == false) {
  83. $subtype = GameConfig::npc_getItem($typeid)->subtype;
  84. if($subtype == 4){//传送带
  85. $newMap->unlockedFootholds->$mapid->transmissionIsOk = true;
  86. }
  87. }
  88. }
  89. ctx()->newMap = $newMap;
  90. UserProc::updateUserInfo();
  91. return Resp::ok(array("newMap"=>$newMap,"tag"=>$tag,'num'=>$num,));
  92. }
  93. /*
  94. * 计算探索度值
  95. */
  96. public static function countFootHoldExplorerNum($mapid,$type,$id, $newMap) {
  97. $explorer = 0;
  98. $num = 0;
  99. $retArr = array();
  100. if (StlUtil::dictHasProperty($newMap->unlockMapTypeList, $mapid)) {
  101. $list = $newMap->unlockMapTypeList->$mapid;
  102. $mapList = GameConfig::map_explorer_getItemArray($mapid);
  103. $tempList = array();
  104. if ($mapList != null) {
  105. foreach ($mapList as $item) {
  106. if($item->paras == null){
  107. continue;
  108. }
  109. $cmd = $item->cmd;
  110. $parasList = explode(',', $item->paras);
  111. if($type == $cmd && $id == $parasList[0]){
  112. $num = $parasList[1];
  113. }
  114. foreach ($list as $para) {
  115. $strList = explode('_', $para);
  116. $tempStr = $strList[1].'-'.$strList[2];
  117. if(in_array($tempStr, $tempList)){
  118. continue;
  119. }
  120. if ($strList[1] == $cmd && $strList[2] == $parasList[0]) {
  121. $tempList[] = $tempStr;
  122. $explorer += $parasList[1];
  123. }
  124. }
  125. }
  126. }
  127. }
  128. $retArr[] = $explorer;
  129. $retArr[] = $num;
  130. return $retArr;
  131. }
  132. /**
  133. * 7504 解锁据点
  134. * @return Resp
  135. */
  136. public static function UnlockMap() {
  137. $targetMapId = req()->paras[0]; # 提取参数
  138. $newMap = ctx()->newMap();
  139. # 检查目标地图是否已经解锁
  140. my_Assert(!isset($newMap->unlockedFootholds->$targetMapId), ErrCode::map_Unlocked);
  141. $mo = GameConfig::map_scene_getItem($targetMapId);
  142. $footHold = new Ins_FootHold();
  143. $footHold->mapId = $mo->mapId;
  144. $footHold->curMapType = $mo->mapType;
  145. $this->unlockedFootholds->$targetMapId = $footHold; # 添加解锁据点数据
  146. ctx()->newMap = $newMap;
  147. UserProc::updateUserInfo();
  148. return Resp::ok($newMap);
  149. }
  150. /**
  151. * 7501 进入据点
  152. * @return Resp
  153. */
  154. public static function EnterFootHold() {
  155. $targetMapId = req()->paras[0]; # 提取参数
  156. $newMap = ctx()->newMap();
  157. # 检查目标地图是否已经解锁
  158. my_Assert(isset($newMap->unlockedFootholds->$targetMapId), ErrCode::map_NotUnlocked);
  159. $newMap->curMapId = $targetMapId;
  160. ctx()->newMap = $newMap;
  161. UserProc::updateUserInfo();
  162. return Resp::ok();
  163. }
  164. /**
  165. * 7502 开启传送阵
  166. * @return Resp
  167. */
  168. public static function FixUpTransmision() {
  169. }
  170. /**
  171. * 7503 更新探索进度
  172. * @return Resp
  173. */
  174. public static function UpdateExplorationProgress() {
  175. }
  176. }