1187 lines
46 KiB
PHP
1187 lines
46 KiB
PHP
<?php
|
|
require_once('phpcommon/tglog.php');
|
|
require_once('models/Hero.php');
|
|
require_once('models/HeroSkin.php');
|
|
require_once('models/Gun.php');
|
|
require_once('models/Bag.php');
|
|
require_once('models/DynData.php');
|
|
require_once('models/BattleSettlement.php');
|
|
require_once('models/User.php');
|
|
require_once('models/Parachute.php');
|
|
require_once('models/ChipPage.php');
|
|
require_once('models/Battle.php');
|
|
require_once('services/BattleDataService.php');
|
|
require_once('services/TameBattleDataService.php');
|
|
require_once('services/RoomBattleDataService.php');
|
|
require_once('services/FormulaService.php');
|
|
require_once('mt/RankSeason.php');
|
|
require_once('mt/Robot.php');
|
|
require_once('mt/Skill.php');
|
|
require_once('mt/MapMode.php');
|
|
|
|
use phpcommon\SqlHelper;
|
|
use models\Hero;
|
|
use models\HeroSkin;
|
|
use models\Gun;
|
|
use models\Bag;
|
|
use models\DynData;
|
|
use models\BattleSettlement;
|
|
use models\User;
|
|
use models\Parachute;
|
|
use models\ChipPage;
|
|
use models\Battle;
|
|
use phpcommon\TGLog;
|
|
|
|
class BattleController extends BaseAuthedController {
|
|
|
|
public function preBattleCheck()
|
|
{
|
|
$this->_rspData(array(
|
|
'pre_battle_payload' => ''
|
|
));
|
|
}
|
|
|
|
/*
|
|
http post
|
|
php://input
|
|
{
|
|
"team_list": [
|
|
[
|
|
"team_id": 1,
|
|
"members": [
|
|
"account_id": ""
|
|
]
|
|
],
|
|
]
|
|
}
|
|
|
|
$channelId = phpcommon\extractChannel($account_id);
|
|
if ($chnanelId == SELFSDK_CHANNEL || $account_id == '') {
|
|
//则是机器人
|
|
}
|
|
*/
|
|
|
|
public function battleReport()
|
|
{
|
|
$userInfo = $this->_getOrmUserInfo();
|
|
if (!$userInfo) {
|
|
$this->_rspErr(1, 'Without this player1');
|
|
return;
|
|
}
|
|
$data = json_decode(file_get_contents('php://input'), true);
|
|
/*error_log(json_encode(array(
|
|
'a' => 'battleReport',
|
|
'post_data' => $data
|
|
)));*/
|
|
|
|
$teamList = array();
|
|
if ($data) {
|
|
$teamList = $data['team_list'];
|
|
}
|
|
// error_log(json_encode($teamList));
|
|
$battleDataService = new services\BattleDataService();
|
|
$battleDataService->teamList = $teamList;
|
|
$battleDataService->updateBattleData();
|
|
SqlHelper::insert(
|
|
$this->_getSelfMysql(),
|
|
't_battle_record',
|
|
array(
|
|
'account_id' => $this->_getAccountId(),
|
|
'request' => json_encode($_REQUEST),
|
|
'createtime' => $this->_getNowTime(),
|
|
'modifytime' => $this->_getNowTime(),
|
|
)
|
|
);
|
|
// error_log(json_encode($battleDataService->getReward()));
|
|
$data = array(
|
|
'reward' => $battleDataService->getReward()
|
|
);
|
|
if ( getReqVal('match_mode', 0) == services\BattleDataService::MATCH_MODE_PVP
|
|
&& mt\RankSeason::getCurrentSeason()
|
|
&& myself()->_getV(TN_RANK_STATUS, 0 ) == 0 ){
|
|
$newRank = $userInfo['rank'];
|
|
$newScore = $userInfo['score'];
|
|
$winningPro = $battleDataService->celWinningPro();
|
|
if ($winningPro){
|
|
$newScore = \services\FormulaService::calcBattleAfterRankScore($userInfo,$_REQUEST,$winningPro);
|
|
mt\Rank::calcNewRankAndScore( $newRank, $newScore);
|
|
}
|
|
$scoreInfo = array(
|
|
'old_rank' => $userInfo['rank'],
|
|
'old_score' => $userInfo['score'],
|
|
'new_rank' => $newRank,
|
|
'new_score' => $newScore,
|
|
);
|
|
$data['score_info'] = $scoreInfo;
|
|
}
|
|
$this->_rspData($data);
|
|
}
|
|
|
|
public function personalReport(){
|
|
$userInfo = $this->_getOrmUserInfo();
|
|
if (!$userInfo) {
|
|
$this->_rspErr(1, 'Without this player1');
|
|
return;
|
|
}
|
|
$this->_rspData(array(
|
|
));
|
|
}
|
|
|
|
public function mobaTeamReport(){
|
|
error_log('mobaReport');
|
|
$userInfo = $this->_getOrmUserInfo();
|
|
if (!$userInfo) {
|
|
$this->_rspErr(1, 'Without this player1');
|
|
return;
|
|
}
|
|
$data = json_decode(file_get_contents('php://input'), true);
|
|
error_log(json_encode($data));
|
|
foreach ($data['team_list'] as $teamData){
|
|
$this->_handleTeamReport($teamData);
|
|
}
|
|
|
|
$this->_rspOk();
|
|
}
|
|
|
|
private function _handleTeamReport($teamData){
|
|
$battle_uuid = getXVal($teamData,'battle_uuid', 0);
|
|
$room_uuid = getXVal($teamData,'room_uuid', 0);
|
|
$battleSettlementDb = BattleSettlement::findTeam($battle_uuid,$room_uuid);
|
|
if ($battleSettlementDb){
|
|
$this->_rspErr(1, 'Repeated request');
|
|
return;
|
|
}
|
|
SqlHelper::upsert
|
|
(myself()->_getSelfMysql(),
|
|
't_battle_input',
|
|
array(
|
|
'battle_uuid' => $battle_uuid,
|
|
'room_uuid' => $room_uuid,
|
|
),
|
|
array(
|
|
'input' => json_encode($teamData)
|
|
),
|
|
array(
|
|
'battle_uuid' => $battle_uuid,
|
|
'room_uuid' => $room_uuid,
|
|
'input' => json_encode($teamData),
|
|
'createtime' => myself()->_getNowTime(),
|
|
'modifytime' => myself()->_getNowTime(),
|
|
)
|
|
);
|
|
$teamList = array();
|
|
if ($teamData) {
|
|
$teamList = $teamData['team_list'];
|
|
}
|
|
$teamBattleDataService = new services\TameBattleDataService();
|
|
$teamBattleDataService->allInfo = $teamData;
|
|
$teamBattleDataService->teamList = $teamList;
|
|
$teamBattleDataService->teamInfo = isset($teamData['members']) ? $teamData['members'] : array();
|
|
$teamBattleDataService->addBattleSettlementTeam();
|
|
foreach ($teamData['members'] as $member){
|
|
$member['pvp_team_rank'] = getXVal($teamData,'pvp_team_rank', 0);
|
|
if ($member['account_id'] && !myself()->_isAndroidAccountId($member['account_id'])){
|
|
$this->switchAccount($member['account_id']);
|
|
$teamBattleDataService->battleInfo = $member;
|
|
$teamBattleDataService->updateBattleData();
|
|
$teamBattleDataService->addBattleSettlementSingle();
|
|
SqlHelper::insert(
|
|
$this->_getSelfMysql(),
|
|
't_battle_record',
|
|
array(
|
|
'account_id' => $this->_getAccountId(),
|
|
'request' => json_encode($member),
|
|
'createtime' => $this->_getNowTime(),
|
|
'modifytime' => $this->_getNowTime(),
|
|
)
|
|
);
|
|
}
|
|
}
|
|
$this->switchAccount(getReqVal('account_id', 0));
|
|
}
|
|
|
|
public function teamReport()
|
|
{
|
|
error_log('teamReport');
|
|
$userInfo = $this->_getOrmUserInfo();
|
|
if (!$userInfo) {
|
|
$this->_rspErr(1, 'Without this player1');
|
|
return;
|
|
}
|
|
$data = json_decode(file_get_contents('php://input'), true);
|
|
error_log(json_encode($data));
|
|
$this->_handleTeamReport($data);
|
|
// $battle_uuid = getXVal($data,'battle_uuid', 0);
|
|
// $room_uuid = getXVal($data,'room_uuid', 0);
|
|
// $battleSettlementDb = BattleSettlement::findTeam($battle_uuid,$room_uuid);
|
|
// if ($battleSettlementDb){
|
|
// $this->_rspErr(1, 'Repeated request');
|
|
// return;
|
|
// }
|
|
// SqlHelper::upsert
|
|
// (myself()->_getSelfMysql(),
|
|
// 't_battle_input',
|
|
// array(
|
|
// 'battle_uuid' => $battle_uuid,
|
|
// 'room_uuid' => $room_uuid,
|
|
// ),
|
|
// array(
|
|
// 'input' => json_encode($data)
|
|
// ),
|
|
// array(
|
|
// 'battle_uuid' => $battle_uuid,
|
|
// 'room_uuid' => $room_uuid,
|
|
// 'input' => json_encode($data),
|
|
// 'createtime' => myself()->_getNowTime(),
|
|
// 'modifytime' => myself()->_getNowTime(),
|
|
// )
|
|
// );
|
|
// $teamList = array();
|
|
// if ($data) {
|
|
// $teamList = $data['team_list'];
|
|
// }
|
|
// $teamBattleDataService = new services\TameBattleDataService();
|
|
// $teamBattleDataService->allInfo = $data;
|
|
// $teamBattleDataService->teamList = $teamList;
|
|
// $teamBattleDataService->teamInfo = isset($data['members']) ? $data['members'] : array();
|
|
//
|
|
//
|
|
// $teamBattleDataService->addBattleSettlementTeam();
|
|
// foreach ($data['members'] as $member){
|
|
// $member['pvp_team_rank'] = getXVal($data,'pvp_team_rank', 0);
|
|
// if ($member['account_id'] && !myself()->_isAndroidAccountId($member['account_id'])){
|
|
// $this->switchAccount($member['account_id']);
|
|
// $teamBattleDataService->battleInfo = $member;
|
|
// $teamBattleDataService->updateBattleData();
|
|
// $teamBattleDataService->addBattleSettlementSingle();
|
|
// SqlHelper::insert(
|
|
// $this->_getSelfMysql(),
|
|
// 't_battle_record',
|
|
// array(
|
|
// 'account_id' => $this->_getAccountId(),
|
|
// 'request' => json_encode($member),
|
|
// 'createtime' => $this->_getNowTime(),
|
|
// 'modifytime' => $this->_getNowTime(),
|
|
// )
|
|
// );
|
|
// }
|
|
//
|
|
// }
|
|
//
|
|
// $this->switchAccount(getReqVal('account_id', 0));
|
|
$this->_rspOk();
|
|
}
|
|
|
|
public function roomReport(){
|
|
error_log('roomReport');
|
|
$userInfo = $this->_getOrmUserInfo();
|
|
if (!$userInfo) {
|
|
$this->_rspErr(1, 'Without this player1');
|
|
return;
|
|
}
|
|
$input = json_decode(file_get_contents('php://input'), true);
|
|
if (myself()->_getAccountId() == '6513_2006_U1JcRueKMQxN9BDw8p7pu61gfdzsS7G3') {
|
|
error_log(json_encode($input));
|
|
}
|
|
$roomBattleDataService = new services\RoomBattleDataService();
|
|
$roomBattleDataService->mapMode = getXVal($input,'map_mode', 0);
|
|
error_log('roomReportMode:'.getXVal($input,'map_mode', 0));
|
|
$roomBattleDataService->inputData = $input;
|
|
$room_uuid = getXVal($input,'room_uuid', 0);
|
|
foreach ($input["team_list"] as $teamData){
|
|
foreach ($teamData['members'] as $member){
|
|
$roomBattleDataService->maxKill = max($roomBattleDataService->maxKill,getXVal($member,'kills', 0));
|
|
$roomBattleDataService->maxAssist = max($roomBattleDataService->maxAssist,getXVal($member,'pvp_assist', 0));
|
|
$roomBattleDataService->maxDamage = max($roomBattleDataService->maxDamage,getXVal($member,'damage_out', 0));
|
|
$roomBattleDataService->maxRecover = max($roomBattleDataService->maxRecover,getXVal($member,'recover_hp', 0));
|
|
$roomBattleDataService->maxLevel = max($roomBattleDataService->maxLevel,getXVal($member,'hero_lv', 1));
|
|
$aliveTime = getXVal($member,'alive_time', 0) / 1000;
|
|
$roomBattleDataService->maxAlive = max($roomBattleDataService->maxAlive,$aliveTime);
|
|
}
|
|
}
|
|
$realUserNum = 0;
|
|
//对赌模式统计真人数
|
|
if ($roomBattleDataService->mapMode == mt\MapMode::BET_MODE){
|
|
foreach ($input["team_list"] as $teamData){
|
|
foreach ($teamData['members'] as $member){
|
|
if(!myself()->_isAndroidAccountId(getXVal($member,'account_id', 0))){
|
|
$realUserNum += 1;
|
|
}
|
|
}
|
|
}
|
|
$roomBattleDataService->realUserCount = $realUserNum;
|
|
}
|
|
//排位模式计算个人排名
|
|
if ($roomBattleDataService->mapMode == mt\MapMode::RANKING_MODE){
|
|
foreach ($input["team_list"] as $teamData){
|
|
foreach ($teamData['members'] as $member){
|
|
$ExpScore = $roomBattleDataService->_calBattleScore($member);
|
|
array_push($roomBattleDataService->teamExpScoreSort,array(
|
|
'account_id' => getXVal($member,'account_id', 0),
|
|
'expScore' => $ExpScore
|
|
));
|
|
}
|
|
}
|
|
usort($roomBattleDataService->teamExpScoreSort,function ($a,$b){
|
|
if ($a['expScore'] == $b['expScore']) {
|
|
return 0;
|
|
}
|
|
return ($a['expScore'] > $b['expScore']) ? -1 : 1;
|
|
});
|
|
}
|
|
|
|
foreach ($input["team_list"] as $teamData){
|
|
$battle_uuid = getXVal($teamData,'battle_uuid', 0);
|
|
$battleSettlementDb = BattleSettlement::findTeam($battle_uuid,$room_uuid);
|
|
if ($battleSettlementDb){
|
|
$roomBattleDataService->teamData = $teamData;
|
|
$roomBattleDataService->battleSettlementDb = $battleSettlementDb;
|
|
$roomBattleDataService->settlementReward();
|
|
}
|
|
}
|
|
$this->switchAccount(getReqVal('account_id', 0));
|
|
$this->updateRecentBattle($input['team_list']);
|
|
$this->_rspOk();
|
|
}
|
|
|
|
private function updateRecentBattle($teamList)
|
|
{
|
|
$realPlayerHash = array();
|
|
$realPlayerHashCopy = array();
|
|
foreach ($teamList as $team) {
|
|
foreach ($team['members'] as $member) {
|
|
if (!myself()->_isAndroidAccountId($member['account_id'])) {
|
|
$realPlayerHash[$member['account_id']] = 1;
|
|
$realPlayerHashCopy[$member['account_id']] = 1;
|
|
}
|
|
}
|
|
}
|
|
error_log(json_encode($realPlayerHash));
|
|
$accountIdPair = array();
|
|
foreach ($realPlayerHash as $accountId => $val) {
|
|
foreach ($realPlayerHashCopy as $accountIdCopy => $valCopy) {
|
|
if ($accountId != $accountIdCopy) {
|
|
$accountId1 = $accountId;
|
|
$accountId2 = $accountIdCopy;
|
|
if ($accountId > $accountIdCopy) {
|
|
$accountId1 = $accountIdCopy;
|
|
$accountId2 = $accountId;
|
|
}
|
|
$key = $accountId . '|' . $accountId2;
|
|
if (!array_key_exists($key, $accountIdPair)) {
|
|
$accountIdPair[$key] = array($accountId1, $accountId2);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
error_log(json_encode($accountIdPair));
|
|
$nowTime = myself()->_getNowTime();
|
|
foreach ($accountIdPair as $pair) {
|
|
$accountId1 = $pair[0];
|
|
$accountId2 = $pair[1];
|
|
SqlHelper::Upsert(
|
|
myself()->_getRelationDbMysql(),
|
|
't_recent_battle',
|
|
array(
|
|
'account_id1' => $accountId1,
|
|
'account_id2' => $accountId2,
|
|
),
|
|
array(
|
|
'last_battle_time' => $nowTime,
|
|
),
|
|
array(
|
|
'account_id1' => $accountId1,
|
|
'account_id2' => $accountId2,
|
|
'last_battle_time' => $nowTime,
|
|
'createtime' => $nowTime,
|
|
'modifytime' => $nowTime,
|
|
)
|
|
);
|
|
}
|
|
}
|
|
|
|
/*
|
|
http post
|
|
php://input
|
|
{
|
|
}
|
|
*/
|
|
|
|
public function reportSettlement()
|
|
{
|
|
$battleUuid = getReqVal('battle_uuid', '');
|
|
$data = file_get_contents('php://input');
|
|
BattleSettlement::add($battleUuid, $data);
|
|
myself()->_rspOk();
|
|
}
|
|
|
|
public function getBattleData()
|
|
{
|
|
error_log(json_encode($_REQUEST));
|
|
$data = 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' => '',
|
|
'weapon_dto1' => '',
|
|
'weapon_dto2' => '',
|
|
'is_valid_battle' => 0,
|
|
//'payload' => json_encode($member['cmjoin']),
|
|
'errcode' => 0,
|
|
'errmsg' => '',
|
|
);
|
|
if (!phpcommon\isValidSessionId($account_id, $session_id)) {
|
|
$info['errcode'] = 50;
|
|
$info['errmsg'] = 'invalid session_id';
|
|
}else{
|
|
{
|
|
$userDb = User::find($account_id);
|
|
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($account_id);
|
|
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);
|
|
}
|
|
|
|
}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);
|
|
$info['hero_dto']['avatar_info'] = Hero::avatarInfo($heroDb);
|
|
} else {
|
|
$info['errcode'] = 51;
|
|
$info['errmsg'] = 'paramater error';
|
|
}
|
|
}
|
|
|
|
// {
|
|
// 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);
|
|
myself()->_rspData($data);
|
|
}
|
|
|
|
public function getCustomBattleData()
|
|
{
|
|
$sign = '';
|
|
$customData = array();
|
|
{
|
|
$rawData = file_get_contents('php://input');
|
|
error_log($rawData);
|
|
$sign = strstr($rawData, '|', true);
|
|
$customData = strstr($rawData, '|');
|
|
$customData = substr($customData, 1);
|
|
error_log(json_encode(array(
|
|
'sign' => $sign,
|
|
'customData' => $customData
|
|
)));
|
|
if (md5($customData . HALL_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'];
|
|
$roomUuid = $customData['room_uuid'];
|
|
$startTime = $customData['start_time'];
|
|
|
|
$data = array(
|
|
'sign' => $sign,
|
|
'zone_id' => $zoneId,
|
|
'node_id' => $nodeId,
|
|
'room_uuid' => $roomUuid,
|
|
'start_time' => $startTime,
|
|
'team_list' => array(),
|
|
'ob_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);
|
|
}
|
|
foreach ($customData['ob_list'] 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($data['ob_list'], $info);
|
|
}
|
|
error_log(json_encode($data));
|
|
myself()->_rspData($data);
|
|
}
|
|
|
|
public function getNormalBattleData()
|
|
{
|
|
$version = getReqVal('version', 0);
|
|
$ignoreAndroid = false;
|
|
if ($version < 1) {
|
|
$ignoreAndroid = true;
|
|
}
|
|
$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);
|
|
}
|
|
|
|
$currSeason = mt\RankSeason::getCurrentSeason();
|
|
error_log(json_encode($customData));
|
|
$zoneId = $customData['zone_id'];
|
|
$nodeId = $customData['node_id'];
|
|
$modeId = $customData['mode_id'];
|
|
$mapId = $customData['map_id'];
|
|
$roomUuid = $customData['room_uuid'];
|
|
$startTime = $customData['start_time'];
|
|
|
|
$data = array(
|
|
'sign' => $sign,
|
|
'zone_id' => $zoneId,
|
|
'node_id' => $nodeId,
|
|
'mode_id' => $modeId,
|
|
'map_id' => $mapId,
|
|
'room_uuid' => $roomUuid,
|
|
'start_time' => $startTime,
|
|
'match_mode' => $currSeason ? 1 : 0,
|
|
'team_list' => array()
|
|
);
|
|
$mapModeMeta = mt\MapMode::find($modeId);
|
|
if (empty($mapModeMeta)) {
|
|
myself()->_rspErr(2, 'map mode error');
|
|
return;
|
|
}
|
|
$r = myself()->_getRedis($roomUuid);
|
|
if (!$this->checkTicket($r, $customData, $mapModeMeta)) {
|
|
myself()->_rspErr(2, 'map mode error');
|
|
return;
|
|
}
|
|
|
|
$currSeason = mt\RankSeason::getCurrentSeason();
|
|
foreach ($customData['team_list'] as $team) {
|
|
if ($ignoreAndroid) {
|
|
$isAllAndroid = true;
|
|
foreach ($team['members'] as $member) {
|
|
if (!$member['is_android']) {
|
|
$isAllAndroid = false;
|
|
break;
|
|
}
|
|
}
|
|
if ($isAllAndroid) {
|
|
continue;
|
|
}
|
|
}
|
|
$teamInfo = array(
|
|
'team_uuid' => $team['team_uuid'],
|
|
'members' => array()
|
|
);
|
|
foreach ($team['members'] as $member) {
|
|
if ($ignoreAndroid && $member['is_android']) {
|
|
continue;
|
|
}
|
|
if ($member['is_android']) {
|
|
$info = $this->getAndroidInfo($member);
|
|
array_push($teamInfo['members'], $info);
|
|
} else {
|
|
$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['head_id'] = $userDb['head_id'];
|
|
$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['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,$member['hero_uniid']);
|
|
if ($heroDb) {
|
|
$info['is_valid_battle'] = 1;
|
|
$info['hero_dto'] = Hero::toDto($heroDb);
|
|
$info['hero_dto']['chip_page'] = ChipPage::toDtoBattle($chipPageDb);
|
|
} 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));
|
|
$this->decTicket($r, $customData, $mapModeMeta);
|
|
myself()->_rspData($data);
|
|
}
|
|
|
|
public function getMobaBattleData()
|
|
{
|
|
$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 . HALL_KEY) != $sign) {
|
|
myself()->_rspErr(1, 'sign error');
|
|
return;
|
|
}
|
|
$customData = json_decode($customData, true);
|
|
}
|
|
|
|
$zoneId = $customData['zone_id'];
|
|
$nodeId = $customData['node_id'];
|
|
$roomUuid = $customData['room_uuid'];
|
|
$startTime = $customData['start_time'];
|
|
|
|
$data = array(
|
|
'sign' => $sign,
|
|
'zone_id' => $zoneId,
|
|
'node_id' => $nodeId,
|
|
'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);
|
|
}
|
|
|
|
private function genInitBattleData()
|
|
{
|
|
$accountId = myself()->_getAccountId();
|
|
$sessionId = myself()->_getSessionId();
|
|
$battleUuid = '';
|
|
$currentGetStar = myself()->_getDailyV(TN_DAILY_GET_STAR_NUM, 0);
|
|
$info = array(
|
|
'account_id' => $accountId,
|
|
'session_id' => $sessionId,
|
|
'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' => '',
|
|
);
|
|
return $info;
|
|
}
|
|
|
|
public function getBattleDataNew()
|
|
{
|
|
error_log(json_encode($_REQUEST));
|
|
$members = json_decode(getReqVal('members', ''), true);
|
|
$data = array(
|
|
'members' => array()
|
|
);
|
|
$currSeason = mt\RankSeason::getCurrentSeason();
|
|
foreach ($members as $member) {
|
|
$userDb = User::find($member['account_id']);
|
|
$info = array(
|
|
'account_id' => $member['account_id'],
|
|
'session_id' => $member['session_id'],
|
|
'hero_uniid' => $member['hero_uniid'],
|
|
'weapon_uuid1' => $member['weapon_uuid1'],
|
|
'weapon_uuid2' => $member['weapon_uuid2'],
|
|
'battle_uuid' => $member['battle_uuid'],
|
|
'parachute' => $userDb['parachute']?$userDb['parachute']:Parachute::$parachute,
|
|
'hero_dto' => '',
|
|
'weapon_dto1' => '',
|
|
'weapon_dto2' => '',
|
|
'level' =>$userDb['level'],
|
|
|
|
'is_valid_battle' => 0,
|
|
//'payload' => json_encode($member['cmjoin']),
|
|
'errcode' => 0,
|
|
'errmsg' => '',
|
|
);
|
|
if (!phpcommon\isValidSessionId($member['account_id'], $member['session_id'])) {
|
|
$info['errcode'] = 50;
|
|
$info['errmsg'] = 'invalid session_id';
|
|
}else{
|
|
{
|
|
$heroDb = Hero::findByAccountId($member['account_id'],
|
|
$member['hero_uniid']);
|
|
if ($heroDb) {
|
|
$info['is_valid_battle'] = 1;
|
|
$info['hero_dto'] = Hero::toDto($heroDb);
|
|
{//选用皮肤id
|
|
$skinDb = HeroSkin::findBx($heroDb['hero_id']);
|
|
if ($skinDb){
|
|
$info['hero_dto']['skin_id'] = $skinDb['skin_id'];
|
|
}
|
|
}
|
|
} else {
|
|
$info['errcode'] = 51;
|
|
$info['errmsg'] = 'paramater error';
|
|
}
|
|
}
|
|
{
|
|
for ($i = 1; $i <= 2; ++$i) {
|
|
if (isset($member['weapon_uuid' . $i])) {
|
|
$gunDb = Gun::findByAccountId($member['account_id'],
|
|
$member['weapon_uuid' . $i]);
|
|
if ($gunDb) {
|
|
$info['weapon_dto' . $i] = Gun::toDto($gunDb);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
{
|
|
$itemDb = Bag::findEx($member['account_id'], V_ITEM_REVIVE_COIN);
|
|
$info['revive_coin'] = $itemDb && $itemDb['item_num'] > 0 ? $itemDb['item_num'] : 0;
|
|
}
|
|
{
|
|
$info['match_mode'] = 0;
|
|
if ($currSeason && DynData::getVEx($member['account_id'], TN_RANK_STATUS, 0) == 0){
|
|
$info['match_mode'] = 1;
|
|
}
|
|
}
|
|
}
|
|
array_push($data['members'], $info);
|
|
|
|
}
|
|
// $attr = Hero::getChipAttr($info['hero_dto']['chip_ids']);
|
|
myself()->_rspData($data);
|
|
|
|
}
|
|
|
|
public function showBattleHistory(){
|
|
$accountId = getReqVal('target_id', '');
|
|
$battleUuid = getReqVal('battle_uuid', 0);
|
|
$roomUuid = getReqVal('room_uuid', 0);
|
|
error_log('showBattleHistory '.json_encode($_REQUEST));
|
|
if ( !$battleUuid){
|
|
$this->_rspErr(1,'param battle_uuid error');
|
|
return;
|
|
}
|
|
if ( !$roomUuid){
|
|
$this->_rspErr(1,'param room_uuid error');
|
|
return;
|
|
}
|
|
$row = BattleSettlement::findTeamByTargetId($accountId,$battleUuid,$roomUuid);
|
|
if (!$row){
|
|
$this->_rspErr(1,'param error');
|
|
return;
|
|
}
|
|
$data = $row;
|
|
$data['data'] = json_decode($row['data'],true);
|
|
$propertyChgService = new services\PropertyChgService();
|
|
$propertyChgService->addUserChg();
|
|
$this->_rspData(
|
|
array(
|
|
'info'=>$data,
|
|
'property_chg' => $propertyChgService->toDto(),
|
|
)
|
|
);
|
|
}
|
|
|
|
public function decReviveCoin()
|
|
{
|
|
$num = getReqVal('num', 1);
|
|
$itemDb = Bag::find(V_ITEM_REVIVE_COIN);
|
|
if (!$itemDb || $itemDb['item_num'] < $num) {
|
|
myself()->_rspErr(1, 'not enought item');
|
|
return;
|
|
}
|
|
Bag::decItem(V_ITEM_REVIVE_COIN, $num);
|
|
$itemDb = Bag::find(V_ITEM_REVIVE_COIN);
|
|
$reviveCoin = $itemDb && $itemDb['item_num'] > 0 ? $itemDb['item_num'] : 0;
|
|
myself()->_rspData(array(
|
|
'revive_coin' => $reviveCoin
|
|
));
|
|
}
|
|
|
|
private function getAndroidInfo($member)
|
|
{
|
|
$robotMeta = mt\Robot::get($member['robot_id']);
|
|
$skillList = mt\Skill::getPresetSkill();
|
|
$info = array(
|
|
'account_id' => $member['account_id'],
|
|
'name' => $robotMeta['name'],
|
|
'is_valid_battle' => 1,
|
|
'errcode' => 0,
|
|
'errmsg' => '',
|
|
'level' => 1,
|
|
'is_android' => 1,
|
|
'skill_id' => $skillList[rand() % count($skillList)]['skill_id'],
|
|
'robot_id' => $member['robot_id'],
|
|
'hero_dto' => array(
|
|
'hero_uniid' => '',
|
|
'hero_id' => $robotMeta['hero_id']
|
|
)
|
|
);
|
|
return $info;
|
|
}
|
|
|
|
private function checkTicket($r, $customData, $mapModeMeta)
|
|
{
|
|
if ($mapModeMeta['map_mode'] == 501) {
|
|
error_log("checkTick error :501");
|
|
return false;
|
|
}
|
|
$itemId = $mapModeMeta['admission_item_id'];
|
|
if (empty($itemId)) {
|
|
return true;
|
|
}
|
|
if (!$mapModeMeta['is_open']) {
|
|
return false;
|
|
}
|
|
$roomUuid = $customData['room_uuid'];
|
|
if ($r->get(DEC_BATTLE_TICKET . $roomUuid)) {
|
|
return true;
|
|
}
|
|
if (!empty($mapModeMeta['daily_open_time']) && !empty($mapModeMeta['daily_end_time'])) {
|
|
$dailyOpenTimeOffset = myself()->_getDaySecondsOffset(strtotime("2024-6-22 ".$mapModeMeta['daily_open_time']));
|
|
$dailyEndTimeOffset = myself()->_getDaySecondsOffset(strtotime("2024-6-22 ".$mapModeMeta['daily_end_time']));
|
|
$nowTimeOffset = myself()->_getDaySecondsOffset(myself()->_getNowTime());
|
|
error_log(json_encode(array(
|
|
'dailyOpenTimeOffset' => $dailyOpenTimeOffset,
|
|
'dailyEndTimeOffset' => $dailyEndTimeOffset,
|
|
'nowTimeOffset' => $nowTimeOffset,
|
|
'isOpen' => $nowTimeOffset >= $dailyOpenTimeOffset && $nowTimeOffset <= $dailyEndTimeOffset
|
|
)));
|
|
if (!($nowTimeOffset >= $dailyOpenTimeOffset && $nowTimeOffset <= $dailyEndTimeOffset)) {
|
|
return false;
|
|
}
|
|
}
|
|
foreach ($customData['team_list'] as $team) {
|
|
foreach ($team['members'] as $member) {
|
|
if (!$member['is_android']) {
|
|
$itemDb = Bag::findEx($member['account_id'], $itemId);
|
|
if (empty($itemDb) || $itemDb['item_num'] <= 0) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private function decTicket($r, $customData, $mapModeMeta)
|
|
{
|
|
$itemId = $mapModeMeta['admission_item_id'];
|
|
if (empty($itemId)) {
|
|
return;
|
|
}
|
|
$roomUuid = $customData['room_uuid'];
|
|
foreach ($customData['team_list'] as $team) {
|
|
foreach ($team['members'] as $member) {
|
|
if (!$member['is_android']) {
|
|
$itemDb = Bag::findEx($member['account_id'], $itemId);
|
|
if (!empty($itemDb) || $itemDb['item_num'] > 0) {
|
|
Bag::decItemByUnIidEx($member['account_id'], $itemDb['idx'], 1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
$r->setPx(DEC_BATTLE_TICKET . $roomUuid, 1, 1000 * 3600);
|
|
}
|
|
|
|
}
|