164 lines
5.6 KiB
PHP
164 lines
5.6 KiB
PHP
<?php
|
|
|
|
require_once('models/Hero.php');
|
|
require_once('models/Gun.php');
|
|
require_once('models/Chip.php');
|
|
require_once('services/BattleDataService.php');
|
|
|
|
use phpcommon\SqlHelper;
|
|
use models\Hero;
|
|
use models\Gun;
|
|
use models\Chip;
|
|
|
|
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->_rspData($battleDataService->getReward());
|
|
}
|
|
|
|
public function battleReportNew()
|
|
{
|
|
}
|
|
|
|
public function getBattleData()
|
|
{
|
|
$mode = getReqVal('mode', '');
|
|
$members = json_decode(getReqVal('members', ''), true);
|
|
|
|
$data = array(
|
|
'members' => array()
|
|
);
|
|
error_log(json_encode($_REQUEST));
|
|
error_log(json_encode($members));
|
|
foreach ($members as $member) {
|
|
$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'],
|
|
'hero_dto' => '',
|
|
'weapon_dto1' => '',
|
|
'weapon_dto2' => '',
|
|
|
|
'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);
|
|
} else {
|
|
$info['errcode'] = 51;
|
|
$info['errmsg'] = 'paramater error';
|
|
}
|
|
}
|
|
{
|
|
for ($i = 1; $i <= 2; ++$i) {
|
|
$gunDb = Gun::findByAccountId($member['account_id'],
|
|
$member['weapon_uuid' . $i]);
|
|
if ($gunDb) {
|
|
$info['weapon_dto' . $i] = Gun::toDto($gunDb);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
array_push($data['members'], $info);
|
|
}
|
|
error_log(json_encode($data));
|
|
myself()->_rspData($data);
|
|
}
|
|
|
|
public function getBattleDataNew()
|
|
{
|
|
$members = json_decode(getReqVal('members', ''), true);
|
|
$data = array(
|
|
'members' => array()
|
|
);
|
|
foreach ($members as $member) {
|
|
$info = array(
|
|
'account_id' => $member['account_id'],
|
|
'session_id' => $member['session_id'],
|
|
'hero_uniid' => $member['hero_uniid'],
|
|
'weapon_uniid1' => $member['weapon_uniid1'],
|
|
'weapon_uniid2' => $member['weapon_uniid2'],
|
|
'battle_uuid' => $member['battle_uuid'],
|
|
'hero_dto' => '',
|
|
'weapon_dto1' => '',
|
|
'weapon_dto2' => '',
|
|
|
|
'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);
|
|
} else {
|
|
$info['errcode'] = 51;
|
|
$info['errmsg'] = 'paramater error';
|
|
}
|
|
}
|
|
{
|
|
for ($i = 1; $i <= 2; ++$i) {
|
|
if (isset($member['weapon_uniid' . $i])) {
|
|
$gunDb = Gun::findByAccountId($member['account_id'],
|
|
$member['weapon_uniid' . $i]);
|
|
if ($gunDb) {
|
|
$info['weapon_dto' . $i] = Gun::toDto($gunDb);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
array_push($data['members'], $info);
|
|
|
|
}
|
|
// $attr = Hero::getChipAttr($info['hero_dto']['chip_ids']);
|
|
myself()->_rspData($data);
|
|
}
|
|
|
|
}
|