123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335 |
- <?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] 领取探索奖励cmd_store_huichengQuanUse
- return self::reviceExplorerReward();
- case CmdCode::map_huichengQuanUse: # [7507]
- return self::huichengQuanUse();
- case CmdCode::map_huichengQuanEnd: # [7508]
- return self::huichengQuanEnd();
- default: # err: 未知的命令码
- return Resp::err(ErrCode::cmd_err);
- }
- }
- /**
- * [7507]
- * @return Resp
- */
- public static function huichengQuanUse() {
- $mapId = req()->paras[0]; #使用传送门的场景的地图id
- $x = req()->paras[1]; # 提取参数
- $y = req()->paras[2];
- $z = req()->paras[3];
- $newMap = ctx()->newMap(true);
- //$curMapId = $newMap->curMapId;
-
- $itemId = 0;
- $dic = ctx()->store()->items;
- foreach ($dic as $id => $num) {
- $subType = GameConfig::item_base_getItem($id)->subType;
- if($subType == 344){
- $itemId = $id;
- break;
- }
- }
- my_Assert($itemId != 0, ErrCode::err_const_no);
-
- StoreProc::removeItemFromStore(ctx()->store, $itemId);
- //找据点,地图在gate_zone里有配置;没有的就算是副本--暂时先这么着
- // $gateZone = GameConfig::gate_zone();
- // my_Assert($gateZone != null, ErrCode::err_const_no);
- // foreach ($gateZone as $zoneid => $val) {
- // $list = explode(',', $val->contains);
- // if(in_array($curMapId, $list)){
- // $mid = $list[0];
- // break;
- // }
- // }
- $curFootholdId = $newMap->curFootholdId;
- if($curFootholdId == null){
- $curFootholdId = 503099;
- }
- $newMap->curMapId = $curFootholdId;
-
- $data = new Ins_ChuansongzhenMapData();
- $data->mapId = $curFootholdId;
- $data->lastMapId = $mapId;
- $data->position_x = $x;
- $data->position_y = $y;
- $data->position_z = $z;
- $newMap->huichengquanRecord->$mapId = $data;
-
- $newMap->lastMapId = $mapId;
-
- ctx()->newMap = $newMap;
- UserProc::updateUserInfo();
- return Resp::ok(
- array("newMap" => $newMap,)
- );
- }
-
- /**
- * [7508] 回城券的传送阵结束
- * @return Resp
- */
- public static function huichengQuanEnd() {
- //$mapid = req()->paras[0]; # 提取参数
- $newMap = ctx()->newMap();
- $curMapId = $newMap->curMapId;
-
-
- $lastMapid = $newMap->lastMapId;
- // $lastMapid = $curMapId;
- // $gateZone = GameConfig::gate_zone();
- // my_Assert($gateZone != null, ErrCode::err_const_no);
- // foreach ($gateZone as $zoneid => $val) {
- // $list = explode(',', $val->contains);
- // if(in_array($curMapId, $list)){
- // $lastMapid = $list[0];
- // break;
- // }
- // }
-
-
-
- if(StlUtil::dictHasProperty($newMap->huichengquanRecord, $lastMapid)){
- StlUtil::dictRemove($newMap->huichengquanRecord, $lastMapid);
- }
-
- ctx()->newMap = $newMap;
- UserProc::updateUserInfo();
- return Resp::ok(
- array("newMap" => $newMap,)
- );
- }
-
- /**
- * [7506] 领取探索奖励
- * @return Resp
- */
- public static function reviceExplorerReward() {
- $mapid = req()->paras[0]; # 提取参数
- $newMap = ctx()->newMap();
- $newMap->unlockedFootholds->$mapid->exploreRewardGeted = true;
- $cost = GameConfig::gate_getItem($mapid)->exploreReward;
- StoreProc::AddMultiItemInStore($cost);
- ctx()->newMap = $newMap;
- UserProc::updateUserInfo();
- return Resp::ok(
- array("newMap" => $newMap, "cost" => $cost,)
- );
- }
- /**
- * 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];
- $type = explode('_', $unlockStr)[1];
- $typeid = explode('_', $unlockStr)[2];
- if (!StlUtil::dictHasProperty($newMap->unlockMapTypeList, $mapid)) {
- $newMap->unlockMapTypeList->$mapid = array();
- }
- $tag = 1;
- $tylist = $newMap->unlockMapTypeList->$mapid;
- foreach ($tylist as $str) {
- $slist = explode('_', $str);
- if ($slist[0] == $mapid && $slist[1] == $type && $slist[2] == $typeid) {
- $tag = 0;
- break;
- }
- }
- $num = 0;
- if ($tag) {
- $newMap->unlockMapTypeList->$mapid[] = $unlockStr;
- my_Assert(StlUtil::dictHasProperty($newMap->unlockedFootholds, $mapid), ErrCode::map_Unlocked);
- $newMap->curMapId = $mapid;
-
- $arr = self::countFootHoldExplorerNum($mapid, $type, $typeid, $newMap);
- $explorerNum = $arr[0];
- $num = $arr[1];
- $newMap->unlockedFootholds->$mapid->curExploreProgress = $explorerNum;
- if ($type == Enum_ExploreType::Npc && $newMap->unlockedFootholds->$mapid->transmissionIsOk == false) {
- $subtype = GameConfig::npc_getItem($typeid)->subtype;
- if ($subtype == Enum_ExploreSubType::Teleporter) {//传送带
- $newMap->unlockedFootholds->$mapid->transmissionIsOk = true;
- }
- }
-
- $mapArr = GameConfig::map_explorer_getItemArray($mapid);
- foreach ($mapArr as $mapItem) {
- $paras = explode(',', $mapItem->paras);
- if($mapItem->cmd == $type && $paras[0] == $typeid){
- ctx()->base(true)->Add_Exp($mapItem->exp);
- break;
- }
- }
- }
- ctx()->newMap = $newMap;
- UserProc::updateUserInfo();
- return Resp::ok(array("newMap" => $newMap, "tag" => $tag, 'num' => $num,"exp"=> ctx()->baseInfo->xp,"maxXp"=> ctx()->baseInfo->maxXp,"level"=> ctx()->baseInfo->level,));
- }
- /*
- * 计算探索度值
- */
- public static function countFootHoldExplorerNum($mapid, $type, $id, $newMap) {
- $explorer = 0;
- $num = 0;
- $retArr = array();
- if (StlUtil::dictHasProperty($newMap->unlockMapTypeList, $mapid)) {
- $list = $newMap->unlockMapTypeList->$mapid;
- $mapList = GameConfig::map_explorer_getItemArray($mapid);
- $tempList = array();
- if ($mapList != null) {
- foreach ($mapList as $item) {
- if ($item->paras == null) {
- continue;
- }
- $cmd = $item->cmd;
- $parasList = explode(',', $item->paras);
- if ($type == $cmd && $id == $parasList[0]) {
- $num = $parasList[1];
- }
- foreach ($list as $para) {
- $strList = explode('_', $para);
- $tempStr = $strList[1] . '-' . $strList[2];
- if (in_array($tempStr, $tempList)) {
- continue;
- }
- if ($strList[1] == $cmd && $strList[2] == $parasList[0]) {
- $tempList[] = $tempStr;
- $explorer += $parasList[1];
- }
- }
- }
- }
- }
- $retArr[] = $explorer;
- $retArr[] = $num;
-
- return $retArr;
- }
- /**
- * 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::gate_getItem($targetMapId);
- $footHold = new Ins_FootHold();
- $footHold->mapId = $mo->gateId;
- $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();
-
- if(!StlUtil::dictHasProperty($newMap->unlockedFootholds,$targetMapId)){
- $mo = GameConfig::gate_getItem($targetMapId);
- $footHold = new Ins_FootHold();
- $footHold->mapId = $mo->gateId;
- $footHold->curMapType = $mo->mapType;
- $newMap->unlockedFootholds->$targetMapId = $footHold; # 初始化解锁新手村据点数据
- }
-
- # 检查目标地图是否已经解锁
- my_Assert(isset($newMap->unlockedFootholds->$targetMapId), ErrCode::map_NotUnlocked);
- $newMap->curMapId = $targetMapId;
-
- $gateZone = GameConfig::gate_zone();
- my_Assert($gateZone != null, ErrCode::err_const_no);
- foreach ($gateZone as $zoneid => $val) {
- $list = explode(',', $val->contains);
- if(in_array($targetMapId, $list)){
- $mid = $list[0];
- break;
- }
- }
-
- if($mid != null){//更新据点id
- $newMap->curFootholdId = $mid;
- }
-
- ctx()->newMap = $newMap;
- UserProc::updateUserInfo();
- return Resp::ok($newMap);
- }
- /**
- * 7502 开启传送阵
- * @return Resp
- */
- public static function FixUpTransmision() {
-
- }
- /**
- * 7503 更新探索进度
- * @return Resp
- */
- public static function UpdateExplorationProgress() {
-
- }
- }
|