1
This commit is contained in:
parent
66b404bc2f
commit
6a59eaf735
@ -1,10 +1,12 @@
|
||||
<?php
|
||||
|
||||
require_once('models/Hero.php');
|
||||
require_once('models/Gun.php');
|
||||
require_once('services/BattleDataService.php');
|
||||
|
||||
use phpcommon\SqlHelper;
|
||||
use models\Hero;
|
||||
use models\Gun;
|
||||
|
||||
class BattleController extends BaseAuthedController {
|
||||
|
||||
@ -52,8 +54,12 @@ class BattleController extends BaseAuthedController {
|
||||
'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']),
|
||||
@ -64,13 +70,25 @@ class BattleController extends BaseAuthedController {
|
||||
$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'] = json_encode(Hero::toDto($heroDb));
|
||||
} else {
|
||||
$info['errcode'] = 51;
|
||||
$info['errmsg'] = 'paramater error';
|
||||
{
|
||||
$heroDb = Hero::findByAccountId($member['account_id'],
|
||||
$member['hero_uniid']);
|
||||
if ($heroDb) {
|
||||
$info['is_valid_battle'] = 1;
|
||||
$info['hero_dto'] = json_encode(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_uniid' . $i]);
|
||||
if ($gunDb) {
|
||||
$info['weapon_dto' . $i] = json_encode(Gun::toDto($gunDb));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
array_push($data['members'], $info);
|
||||
|
@ -41,13 +41,23 @@ class Gun extends BaseModel {
|
||||
return $row;
|
||||
}
|
||||
|
||||
public static function findByAccountId($accountId, $gunUniId)
|
||||
{
|
||||
return self::internalFind($accountId, $gunUniId);
|
||||
}
|
||||
|
||||
public static function findByUniId($gunUniId)
|
||||
{
|
||||
return self::internalFind(myself()->_getAccountId(), $gunUniId);
|
||||
}
|
||||
|
||||
private static function internalFind($accountId, $gunUniId)
|
||||
{
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
myself()->_getSelfMysql(),
|
||||
myself()->_getMysql($accountId),
|
||||
't_gun',
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'account_id' => $accountId,
|
||||
'idx' => $gunUniId,
|
||||
)
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user