1
This commit is contained in:
parent
bb1bf94ff5
commit
0856cd5a4b
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
require_once('models/Hero.php');
|
||||
require_once('services/BattleDataService.php');
|
||||
|
||||
use phpcommon\SqlHelper;
|
||||
use models\Hero;
|
||||
|
||||
class BattleController extends BaseAuthedController {
|
||||
|
||||
@ -39,27 +41,41 @@ class BattleController extends BaseAuthedController {
|
||||
{
|
||||
$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()
|
||||
);
|
||||
error_log(json_encode($members));
|
||||
foreach ($members as $member) {
|
||||
$info = array();
|
||||
$info = array(
|
||||
'account_id' => $member['account_id'],
|
||||
'session_id' => $member['session_id'],
|
||||
'hero_uniid' => $member['hero_uniid'],
|
||||
'battle_uuid' => $member['battle_uuid'],
|
||||
'hero_dto' => '',
|
||||
|
||||
'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'] = json_encode($Hero::toDto($heroDb));
|
||||
} else {
|
||||
$info['errcode'] = 51;
|
||||
$info['errmsg'] = 'paramater error';
|
||||
}
|
||||
}
|
||||
array_push($data['members'], $info);
|
||||
}
|
||||
myself()->_rspData($data());
|
||||
error_log(json_encode($data));
|
||||
myself()->_rspData($data);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,9 +24,19 @@ class Hero extends BaseModel {
|
||||
const QUALITY_LOCK = 2;
|
||||
|
||||
public static function find($heroUniId)
|
||||
{
|
||||
return self::internalFind(myself()->_getAccountId(), $heroUniId);
|
||||
}
|
||||
|
||||
public static function findByAccountId($accountId, $heroUniId)
|
||||
{
|
||||
return self::internalFind($accountId, $heroUniId);
|
||||
}
|
||||
|
||||
private static function internalFind($accountId, $heroUniId)
|
||||
{
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
myself()->_getSelfMysql(),
|
||||
myself()->_getMysql($accountId),
|
||||
't_hero',
|
||||
array(
|
||||
'idx' => $heroUniId,
|
||||
@ -34,8 +44,9 @@ class Hero extends BaseModel {
|
||||
);
|
||||
if ($row) {
|
||||
$row['hero_uniid'] = $row['idx'];
|
||||
if ($row['account_id'] != myself()->_getAccountId()) {
|
||||
if (!NftService::isHeroOwner(myself()->_getOpenId(), $row['token_id'])) {
|
||||
if ($row['account_id'] != $accountId) {
|
||||
$openId = phpcommon\extractOpenId($accountId);
|
||||
if (!NftService::isHeroOwner($opneId, $row['token_id'])) {
|
||||
$row = null;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user