From 30e3e0240aaa0a540c308468d802c08037e95172 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 19 Mar 2024 11:58:12 +0800 Subject: [PATCH] 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 = '';