123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- <?php
- namespace loyalsoft;
- /**
- * Description of MapProc
- * 地图数据处理逻辑
- * @author gwang
- */
- class MapProc {
- /**
- * 地图处理逻辑分发
- * 所有的Proc中必须有这样一个方法
- */
- static function procMain() {
- switch (req()->cmd) {
- case CmdCode::map_EnterFootHold: # [7501] 进入据点
- return self::EnterFootHold();
- case CmdCode::map_FixUpTransmission: # [7502] 开启传送阵
- return self::FixUpTransmision();
- case CmdCode::map_UpdateExplorerationProgress: # [7503] 更新探索进度
- return self::UpdateExplorationProgress();
- case CmdCode::map_UnlockMap: # [7504] 解锁据点
- return self::UnlockMap();
- // case CmdCode::map_getUnlockInfoList: # [7505] 获取mapid下已经解锁的列表
- // return self::getUnlockInfoList();
- case CmdCode::map_unlockInfoSva: # [7505] 保存mapid下已经解锁的
- return self::unlockInfoSva();
- case CmdCode::map_reviceExplorerReward: # [7506] 领取探索奖励
- return self::reviceExplorerReward();
- default: # err: 未知的命令码
- return Resp::err(ErrCode::cmd_err);
- }
- }
- /**
- *
- * @return Resp
- */
- public static function reviceExplorerReward() {
- $mapid = req()->paras[0]; # 提取参数
- $newMap = ctx()->newMap();
- $newMap->unlockedFootholds->$mapid->exploreRewardGeted = true;
- StoreProc::AddMultiItemInStore(GameConfig::map_scene_getItem($mapid)->exploreReward);
- ctx()->newMap = $newMap;
- UserProc::updateUserInfo();
- return Resp::ok($newMap);
- }
- /**
- * 7505
- * @return Resp
- */
- public static function unlockInfoSva() {
- $unlockStr = req()->paras[0]; # 提取参数
- $newMap = ctx()->newMap();
- if (!StlUtil::dictHasProperty($newMap, 'unlockMapTypeList')) {
- $newMap->unlockMapTypeList = new \stdClass();
- }
- $mapid = explode('_', $unlockStr)[0];
- if (!StlUtil::dictHasProperty($newMap->unlockMapTypeList, $mapid)) {
- $newMap->unlockMapTypeList->$mapid = array();
- }
- $newMap->unlockMapTypeList->$mapid[] = $unlockStr;
- $explorerNum = self::countFootHoldExplorerNum($mapid, $newMap);
- $newMap->unlockedFootholds->$mapid->curExploreProgress = $explorerNum;
- $type = explode('_', $unlockStr)[1];
- if ($type == 6 && $newMap->unlockedFootholds->$mapid->transmissionIsOk == false) {//临时代码,6代表传送带
- $newMap->unlockedFootholds->$mapid->transmissionIsOk = true;
- }
- ctx()->newMap = $newMap;
- UserProc::updateUserInfo();
- return Resp::ok($newMap);
- }
- /*
- * 计算探索度值
- */
- public static function countFootHoldExplorerNum($mapid, $newMap) {
- $explorer = 0;
- if (StlUtil::dictHasProperty($newMap->unlockMapTypeList, $mapid)) {
- $list = $newMap->unlockMapTypeList->$mapId;
- $mapList = GameConfig::map_explorer_getItemArray($mapid);
- if ($mapList != null) {
- foreach ($map as $item) {
- $cmd = $item->cmd;
- $parasList = explode(',', $item->paras);
- foreach ($list as $para) {
- $strList = explode('_', $para);
- if ($strList[1] == $cmd && $strList[2] == $parasList[0]) {
- $explorer += $parasList[1];
- }
- }
- }
- }
- }
- return intval($explorer / 100);
- }
- /**
- * 7504 解锁据点
- * @return Resp
- */
- public static function UnlockMap() {
- $targetMapId = req()->paras[0]; # 提取参数
- $newMap = ctx()->newMap();
- # 检查目标地图是否已经解锁
- my_Assert(!isset($newMap->unlockedFootholds->$targetMapId), ErrCode::map_Unlocked);
- $mo = GameConfig::map_scene_getItem($targetMapId);
- $footHold = new Ins_FootHold();
- $footHold->mapId = $mo->mapId;
- $footHold->curMapType = $mo->mapType;
- $this->unlockedFootholds->$targetMapId = $footHold; # 添加解锁据点数据
- ctx()->newMap = $newMap;
- UserProc::updateUserInfo();
- return Resp::ok($newMap);
- }
- /**
- * 7501 进入据点
- * @return Resp
- */
- public static function EnterFootHold() {
- $targetMapId = req()->paras[0]; # 提取参数
- $newMap = ctx()->newMap();
- # 检查目标地图是否已经解锁
- my_Assert(isset($newMap->unlockedFootholds->$targetMapId), ErrCode::map_NotUnlocked);
- $newMap->curMapId = $targetMapId;
- ctx()->newMap = $newMap;
- UserProc::updateUserInfo();
- return Resp::ok();
- }
- /**
- * 7502 开启传送阵
- * @return Resp
- */
- public static function FixUpTransmision() {
-
- }
- /**
- * 7503 更新探索进度
- * @return Resp
- */
- public static function UpdateExplorationProgress() {
-
- }
- }
|