This commit is contained in:
aozhiwei 2022-05-23 16:20:41 +08:00
parent 66b404bc2f
commit 6a59eaf735
2 changed files with 37 additions and 9 deletions

View File

@ -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,7 +70,9 @@ class BattleController extends BaseAuthedController {
$info['errcode'] = 50;
$info['errmsg'] = 'invalid session_id';
} else {
$heroDb = Hero::findByAccountId($member['account_id'], $member['hero_uniid']);
{
$heroDb = Hero::findByAccountId($member['account_id'],
$member['hero_uniid']);
if ($heroDb) {
$info['is_valid_battle'] = 1;
$info['hero_dto'] = json_encode(Hero::toDto($heroDb));
@ -73,6 +81,16 @@ class BattleController extends BaseAuthedController {
$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);
}
error_log(json_encode($data));

View File

@ -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,
)
);