This commit is contained in:
aozhiwei 2023-09-21 16:27:29 +08:00
parent c761d426fb
commit db0c5eac48
3 changed files with 88 additions and 76 deletions

View File

@ -137,6 +137,9 @@ class Battle(object):
'response': [ 'response': [
_common.RspHead(), _common.RspHead(),
['sign', '', '签名'], ['sign', '', '签名'],
['zone_id', '', 'zone_id'],
['node_id', '', 'node_id'],
['start_time', '', 'start_time'],
['room_uuid', '', '房间id'], ['room_uuid', '', '房间id'],
['!team_list', [_common.BattleTeam()], '队伍数据'], ['!team_list', [_common.BattleTeam()], '队伍数据'],
] ]

View File

@ -65,6 +65,14 @@ class BaseAuthedController extends BaseController {
$this->mysqlConn = null; $this->mysqlConn = null;
} }
public function switchOnlineAccount($accountId){
$this->accountId = $accountId;
$this->mysqlConn = null;
$r = $this->_getRedis($this->_getAccountId());
$myself->sessionId = $r->get(LAST_SESSION_KEY . $this->_getAccountId());
return !empty($myself->sessionId);
}
public function _handlePre() public function _handlePre()
{ {
// if (SERVER_ENV == _ONLINE) { // if (SERVER_ENV == _ONLINE) {

View File

@ -341,48 +341,31 @@ class BattleController extends BaseAuthedController {
} }
} }
$zoneId = $customData['zone_id'];
$nodeId = $customData['node_id'];
$roomUuid = $customData['room_uuid'];
$startTime = $customData['start_time'];
$data = array( $data = array(
'sign' => $sign,
'zone_id' => $zoneId,
'node_id' => $nodeId,
'room_uuid' => $roomUuid,
'members' => array() 'members' => array()
); );
$currSeason = mt\RankSeason::getCurrentSeason();
$account_id = getReqVal('account_id', '');
$session_id = getReqVal('session_id', '');
$battle_uuid = getReqVal('battle_uuid', '');
$current_get_star = myself()->_getDailyV(TN_DAILY_GET_STAR_NUM, 0);
$info = array(
'account_id' => $account_id,
'session_id' => $session_id,
'battle_uuid' => $battle_uuid,
'current_get_star' => $current_get_star,
'elo' => 0,
'rank' => 0,
'name' => '',
'level' =>'',
'hero_uniid' => '',
'hero_id' => '',
'weapon_uuid1' => '',
'weapon_uuid2' => '',
'parachute' => '',
'hero_skin' => '',
'skill_id' => '',
'chip_page' => array(),
'battle_times' => '',
'hero_dto' => '', $currSeason = mt\RankSeason::getCurrentSeason();
'weapon_dto1' => '', foreach ($customData['members'] as $team) {
'weapon_dto2' => '', foreach ($team['members'] as $member) {
'is_valid_battle' => 0, $accountId = $member['account_id'];
//'payload' => json_encode($member['cmjoin']), $switchOk = $this->switchOnlineAccount($accountId);
'errcode' => 0, if (!$switchOk) {
'errmsg' => '', myself()->_rspErr(1, 'data error');
); return;
if (!phpcommon\isValidSessionId($account_id, $session_id)) { }
$info['errcode'] = 50; $info = $this->genInitBattleData();
$info['errmsg'] = 'invalid session_id'; $userDb = User::find($accountId);
}else{ if ($userDb) {
{
$userDb = User::find($account_id);
if ($userDb){
$userPresetInfo = User::toPreset($userDb); $userPresetInfo = User::toPreset($userDb);
$info['elo'] = $userDb['elo']; $info['elo'] = $userDb['elo'];
$info['rank'] = $userDb['rank']; $info['rank'] = $userDb['rank'];
@ -405,50 +388,68 @@ class BattleController extends BaseAuthedController {
$info['battle_times'] = getXVal($seasonBattleData, 'total_battle_times', 0); $info['battle_times'] = getXVal($seasonBattleData, 'total_battle_times', 0);
} }
}else{ $heroDb = Hero::findByAccountId($account_id,$info['hero_uniid']);
$info['errcode'] = 51; if ($heroDb) {
$info['errmsg'] = 'paramater error'; $info['is_valid_battle'] = 1;
} $info['hero_dto'] = Hero::toDto($heroDb);
} } else {
$info['errcode'] = 51;
{ $info['errmsg'] = 'paramater error';
$heroDb = Hero::findByAccountId($account_id,$info['hero_uniid']); }
if ($heroDb) {
$info['is_valid_battle'] = 1; {
$info['hero_dto'] = Hero::toDto($heroDb); $itemDb = Bag::findEx($account_id, V_ITEM_REVIVE_COIN);
} else { $info['revive_coin'] = $itemDb && $itemDb['item_num'] > 0 ? $itemDb['item_num'] : 0;
$info['errcode'] = 51; }
$info['errmsg'] = 'paramater error';
} {
} $info['match_mode'] = 0;
if ($currSeason){
// { $info['match_mode'] = 1;
// for ($i = 1; $i <= 2; ++$i) { }
// if (isset($info['weapon_uuid' . $i])) { }
// $gunDb = Gun::findByAccountId($account_id, $info['weapon_uuid' . $i]);
// if ($gunDb) {
// $info['weapon_dto' . $i] = Gun::toDto($gunDb);
// }
// }
// }
// }
{
$itemDb = Bag::findEx($account_id, 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($data['members'], $info);
} }
} }
array_push($data['members'], $info);
myself()->_rspData($data); myself()->_rspData($data);
} }
private function genInitBattleData()
{
$accountId = myself()->_getAccountId();
$sessionId = myself()->_getSessionId();
$battleUuuid = '';
$currentGetStar = myself()->_getDailyV(TN_DAILY_GET_STAR_NUM, 0);
$info = array(
'account_id' => $accountId,
'session_id' => $sessionIid,
'battle_uuid' => $battleUuid,
'current_get_star' => $currentGetStar,
'elo' => 0,
'rank' => 0,
'name' => '',
'level' =>'',
'hero_uniid' => '',
'hero_id' => '',
'weapon_uuid1' => '',
'weapon_uuid2' => '',
'parachute' => '',
'hero_skin' => '',
'skill_id' => '',
'chip_page' => array(),
'battle_times' => '',
'hero_dto' => '',
'weapon_dto1' => '',
'weapon_dto2' => '',
'is_valid_battle' => 0,
//'payload' => json_encode($member['cmjoin']),
'errcode' => 0,
'errmsg' => '',
);
}
public function getBattleDataNew() public function getBattleDataNew()
{ {
error_log(json_encode($_REQUEST)); error_log(json_encode($_REQUEST));