From 30e3e0240aaa0a540c308468d802c08037e95172 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 19 Mar 2024 11:58:12 +0800 Subject: [PATCH 1/2] 1 --- webapp/controller/BattleController.class.php | 106 +++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/webapp/controller/BattleController.class.php b/webapp/controller/BattleController.class.php index 666eb63e..1ca2b374 100644 --- a/webapp/controller/BattleController.class.php +++ b/webapp/controller/BattleController.class.php @@ -433,6 +433,112 @@ class BattleController extends BaseAuthedController { myself()->_rspData($data); } + public function getNormalBattleData() + { + $sign = ''; + $customData = array(); + { + $rawData = file_get_contents('php://input'); + error_log($rawData); + $headStr = strstr($rawData, '|', true); + $sign = strstr($headStr, ':', true); + $customData = strstr($rawData, '|'); + $customData = substr($customData, 1); + error_log(json_encode(array( + 'sign' => $sign, + 'customData' => $customData + ))); + if (md5($customData . MATCH_KEY) != $sign) { + myself()->_rspErr(1, 'sign error'); + return; + } + $customData = json_decode($customData, true); + } + + error_log(json_encode($customData)); + $zoneId = $customData['zone_id']; + $nodeId = $customData['node_id']; + $mapId = $customData['map_id']; + $roomUuid = $customData['room_uuid']; + $startTime = $customData['start_time']; + + $data = array( + 'sign' => $sign, + 'zone_id' => $zoneId, + 'node_id' => $nodeId, + 'map_id' => $mapId, + 'room_uuid' => $roomUuid, + 'start_time' => $startTime, + 'team_list' => array() + ); + + $currSeason = mt\RankSeason::getCurrentSeason(); + foreach ($customData['team_list'] as $team) { + $teamInfo = array( + 'team_uuid' => $team['team_uuid'], + 'members' => array() + ); + foreach ($team['members'] as $member) { + $accountId = $member['account_id']; + $switchOk = $this->switchOnlineAccount($accountId); + if (!$switchOk) { + myself()->_rspErr(1, 'data error'); + return; + } + $info = $this->genInitBattleData(); + $userDb = User::find($accountId); + if ($userDb) { + $userPresetInfo = User::toPreset($userDb); + $info['elo'] = $userDb['elo']; + $info['rank'] = $userDb['rank']; + $info['name'] = $userPresetInfo['name']; + $info['level'] = $userPresetInfo['level']; + $info['parachute'] = $userPresetInfo['parachute']; + $info['hero_uniid'] = $userPresetInfo['hero_uniId']; + $info['hero_id'] = $userPresetInfo['hero_id']; + $info['hero_skin'] = $userPresetInfo['hero_skin']; + $info['skill_id'] = $userPresetInfo['presetInfo']['skill_id']; + $info['weapon_uuid1'] = $userPresetInfo['presetInfo']['weapon_uid1']; + $info['weapon_uuid2'] = $userPresetInfo['presetInfo']['weapon_uid2']; + $chipPageDb = ChipPage::find($userPresetInfo['hero_uniId']); + $info['chip_page'] = ChipPage::toDtoBattle($chipPageDb); + $info['honor_info'] = $userPresetInfo['honor_info']; + $battleDb = Battle::find($accountId); + if ($battleDb){ + $battleData = json_decode($battleDb['battle_data'], true); + $seasonBattleData = isset($battleData) ? getXVal($battleData, 'data', array()) : array(); + $info['battle_times'] = getXVal($seasonBattleData, 'total_battle_times', 0); + } + + $heroDb = Hero::findByAccountId($accountId,$info['hero_uniid']); + if ($heroDb) { + $info['is_valid_battle'] = 1; + $info['hero_dto'] = Hero::toDto($heroDb); + } else { + $info['errcode'] = 51; + $info['errmsg'] = 'paramater error'; + } + + { + $itemDb = Bag::findEx($accountId, V_ITEM_REVIVE_COIN); + $info['revive_coin'] = $itemDb && $itemDb['item_num'] > 0 ? $itemDb['item_num'] : 0; + } + + { + $info['match_mode'] = 0; + if ($currSeason){ + $info['match_mode'] = 1; + } + } + } + array_push($teamInfo['members'], $info); + } + array_push($data['team_list'], $teamInfo); + } + error_log(json_encode($data)); + myself()->_rspData($data); + } + public function getMobaBattleData() { $sign = ''; From 6e4673fa12a859d336f27884d8fc8b7d4ceeaa4b Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 19 Mar 2024 15:36:10 +0800 Subject: [PATCH 2/2] 1 --- webapp/controller/UserController.class.php | 33 +++++++++++++++++++++- webapp/mt/Map.php | 24 ++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 webapp/mt/Map.php diff --git a/webapp/controller/UserController.class.php b/webapp/controller/UserController.class.php index 88ae4382..7c2d9928 100644 --- a/webapp/controller/UserController.class.php +++ b/webapp/controller/UserController.class.php @@ -23,6 +23,7 @@ require_once('mt/Rank.php'); require_once('mt/Item.php'); require_once('mt/PveGeminiMode.php'); require_once('mt/PveGemini.php'); +require_once('mt/Map.php'); require_once('services/AwardService.php'); require_once('services/PropertyChgService.php'); @@ -454,8 +455,37 @@ class UserController extends BaseAuthedController { )); } + public function getMapConf() + { + $mapId = getReqVal('map_id', 0); + $mapInfo = array( + 'map_id' => 0, + 'is_moba' => 0, + 'is_open' => 0 + ); + if (empty($mapId)) { + $mapMeta = mt\Map::get($mapId); + if ($mapMeta) { + $mapInfo = $mapMeta; + } + } + myself()->_rspData($mapInfo); + } + public function getBattleInfo() { + $mapId = getReqVal('map_id', 0); + $mapInfo = array( + 'map_id' => 0, + 'is_moba' => 0, + 'is_open' => 0 + ); + if (empty($mapId)) { + $mapMeta = mt\Map::get($mapId); + if ($mapMeta) { + $mapInfo = $mapMeta; + } + } $userDb = SqlHelper::ormSelectOne (myself()->_getSelfMysql(), 't_user', @@ -482,7 +512,8 @@ class UserController extends BaseAuthedController { myself()->_rspData(array( 'info' => array( 'user_info' => $userInfo, - 'hero_info' => $heroInfo + 'hero_info' => $heroInfo, + 'map_info' => $mapMeta ) )); } diff --git a/webapp/mt/Map.php b/webapp/mt/Map.php new file mode 100644 index 00000000..8636327a --- /dev/null +++ b/webapp/mt/Map.php @@ -0,0 +1,24 @@ +