MapProc.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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 = req()->userInfo->game->newMap();
  40. $newMap->unlockedFootholds->$mapid->exploreRewardGeted = true;
  41. StoreProc::AddMultiItemInStore(GameConfig::map_scene_getItem($mapid)->exploreReward);
  42. req()->userInfo->game->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 = req()->userInfo->game->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. req()->userInfo->game->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. {
  78. $list = $newMap->unlockMapTypeList->$mapId;
  79. $mapList = GameConfig::map_explorer_getItemArray($mapid);
  80. if ($mapList != null)
  81. {
  82. foreach ($map as $item) {
  83. $cmd = $item->cmd;
  84. $parasList = explode(',', $item->paras);
  85. foreach ($list as $para){
  86. $strList = explode('_', $para);
  87. if ($strList[1] == $cmd && $strList[2] == $parasList[0])
  88. {
  89. $explorer += $parasList[1];
  90. }
  91. }
  92. }
  93. }
  94. }
  95. return intval($explorer/100);
  96. }
  97. /**
  98. * 7504 解锁据点
  99. * @return Resp
  100. */
  101. public static function UnlockMap() {
  102. $targetMapId = req()->paras[0]; # 提取参数
  103. $newMap = req()->userInfo->game->newMap();
  104. # 检查目标地图是否已经解锁
  105. my_Assert(!isset($newMap->unlockedFootholds->$targetMapId), ErrCode::map_Unlocked);
  106. $mo = GameConfig::map_scene_getItem($targetMapId);
  107. $footHold = new Ins_FootHold();
  108. $footHold->mapId = $mo->mapId;
  109. $footHold->curMapType = $mo->mapType;
  110. $this->unlockedFootholds->$targetMapId = $footHold; # 添加解锁据点数据
  111. req()->userInfo->game->newMap = $newMap;
  112. UserProc::updateUserInfo();
  113. return Resp::ok($newMap);
  114. }
  115. /**
  116. * 7501 进入据点
  117. * @return Resp
  118. */
  119. public static function EnterFootHold() {
  120. $targetMapId = req()->paras[0]; # 提取参数
  121. $newMap = req()->userInfo->game->newMap();
  122. # 检查目标地图是否已经解锁
  123. my_Assert(isset($newMap->unlockedFootholds->$targetMapId), ErrCode::map_NotUnlocked);
  124. $newMap->curMapId = $targetMapId;
  125. req()->userInfo->game->newMap = $newMap;
  126. UserProc::updateUserInfo();
  127. return Resp::ok();
  128. }
  129. /**
  130. * 7502 开启传送阵
  131. * @return Resp
  132. */
  133. public static function FixUpTransmision() {
  134. }
  135. /**
  136. * 7503 更新探索进度
  137. * @return Resp
  138. */
  139. public static function UpdateExplorationProgress() {
  140. }
  141. }