game2006api/webapp/controller/BattleController.class.php
aozhiwei 6ed02245ef 1
2022-04-01 09:08:17 +08:00

66 lines
1.7 KiB
PHP

<?php
require_once('services/BattleDataService.php');
use phpcommon\SqlHelper;
class BattleController extends BaseAuthedController {
public function preBattleCheck()
{
$this->_rspData(array(
'pre_battle_payload' => ''
));
}
public function battleReport()
{
$userInfo = $this->_getOrmUserInfo();
if (!$userInfo) {
$this->_rspErr(1, 'Without this player1');
return;
}
$battleDataService = new services\BattleDataService();
$battleDataService->updateBattleData();
SqlHelper::insert(
$this->_getSelfMysql(),
't_battle_record',
array(
'account_id' => $this->_getAccountId(),
'request' => json_encode($_REQUEST),
'createtime' => $this->_getNowTime(),
'modifytime' => $this->_getNowTime(),
)
);
$this->_rspOk();
}
public function getBattleData()
{
$mode = getReqVal('mode', '');
$members = json_decode(getReqVal('members', ''), true);
$self = null;
{
foreach ($members as $member) {
if ($member['account_id'] == myself()->_getAccountId()) {
$self = $member;
}
}
if (!$self) {
myself()->_rspErr(1, 'data error');
return;
}
}
$data = array(
'members' => array()
);
foreach ($members as $member) {
$info = array();
array_push($data['members'], $info);
}
myself()->_rspData($data());
}
}