_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 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)); $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['team_rank'] = getXVal($data,'pvp_team_rank', 0); if ($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)); // $data = array( // 'reward' => $teamBattleDataService->getTeamReward() // ); // $this->_rspData($data); $this->_rspOk(); } public function test(){ // echo "当前时间=>" . time() . '|' . date('Y-m-d H:i:s',time()) ; // echo "当天时间=>" . $this->_getDaySeconds(time()) . '|' . date('Y-m-d H:i:s',$this->_getDaySeconds(time())); // echo "下一天时间=>" . ($this->_getDaySeconds(time())+3600*24) . '|' . date('Y-m-d H:i:s',$this->_getDaySeconds(time())+3600*24); // echo "当周时间=>" . $this->_getMondaySeconds() . '|' . date('Y-m-d H:i:s',$this->_getMondaySeconds()); // echo "下周时间=>" . ($this->_getMondaySeconds() + 7*24*3600) . '|' . date('Y-m-d H:i:s',$this->_getMondaySeconds() + 7*24*3600); // $this->switchAccount('james'); // $user = $this->_getOrmUserInfo(); // print_r($user); } /* 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', ''); $info = array( 'account_id' => $account_id, 'session_id' => $session_id, 'battle_uuid' => $battle_uuid, 'name' => '', 'level' =>'', 'hero_uniid' => '', 'hero_id' => '', 'weapon_uuid1' => '', 'weapon_uuid2' => '', 'parachute' => '', 'hero_skin' => '', 'skill_id' => '', 'chip_page' => array(), '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['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['presetInfo']['chip_page']); $info['chip_page'] = ChipPage::toDtoBattle($chipPageDb); }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); } 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 && DynData::getVEx($account_id, TN_RANK_STATUS, 0) == 0){ $info['match_mode'] = 1; } } } array_push($data['members'], $info); myself()->_rspData($data); } 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 getBattleHistory(){ $accountId = getReqVal('target_id', 0); $room_mode = getReqVal('room_mode', 0); $pvp_mode = getReqVal('pvp_mode', 0); if (!$accountId){ $accountId = myself()->_getAccountId(); } $singleList = BattleSettlement::getSingleList($accountId,$room_mode,$pvp_mode); $historyList = BattleHistory::orderBy($singleList,'desc'); // print_r($data);die; // $historyList = BattleHistory::orderBy(BattleHistory::getMyBattleHistoryByMode($mode),'desc'); $data = array(); foreach ($historyList as $k=>$history){ if ($k < 20){ array_push($data,BattleHistory::toDto($history)); } } $this->_rspData(array( 'data' => $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 )); } }