game2006api/webapp/controller/BattleHistoryController.class.php
hujiabin 3ddb202c62 1
2024-09-18 16:41:00 +08:00

70 lines
2.3 KiB
PHP

<?php
require_once('models/BattleSettlement.php');
require_once('models/BattleHistory.php');
require_once('services/TameBattleDataService.php');
use models\BattleSettlement;
use models\BattleHistory;
class BattleHistoryController extends BaseAuthedController {
public function getBattleList(){
$accountId = getReqVal('target_id', 0);
// $room_mode = getReqVal('room_mode', 0);
$type = getReqVal('type', 0);
if (!$accountId){
$accountId = myself()->_getAccountId();
}
$singleList = BattleSettlement::getSingleList($accountId,$type);
$historyList = BattleHistory::orderBy($singleList,'desc');
$data = array();
foreach ($historyList as $k=>$history){
if ($k < 40){
array_push($data,$history);
}
}
$this->_rspData(array(
'data' => $data
));
}
public function showBattleHistory(){
$accountId = getReqVal('target_id', '');
$battleUuid = getReqVal('battle_uuid', 0);
$roomUuid = getReqVal('room_uuid', 0);
if ( !$battleUuid){
$this->_rspErr(1,'param battle_uuid error');
return;
}
if ( !$roomUuid){
$this->_rspErr(1,'param room_uuid error');
return;
}
$teamBattleDb= BattleSettlement::findTeamByTargetId($accountId,$battleUuid,$roomUuid);
if (!$teamBattleDb){
$this->_rspErr(1,'param error');
return;
}
$data = json_decode($teamBattleDb['data'],true);
$room_mode = getXVal($data,'room_mode', 0);
$list = array($data);
if ($room_mode == \services\TameBattleDataService::ROOM_MODE_MOBA){
$rows = BattleSettlement::findTeamByRoomUuid($accountId,$roomUuid);
foreach ($rows as $row){
if ($battleUuid != $row['battle_uuid']){
array_push($list,json_decode($row['data'],true));
}
}
}
$propertyChgService = new services\PropertyChgService();
$propertyChgService->addUserChg();
$this->_rspData(
array(
'info'=>$list,
'property_chg' => $propertyChgService->toDto(),
)
);
}
}