MapProc.php 5.6 KB

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