gun ok
This commit is contained in:
parent
a037de92f4
commit
4871084992
@ -92,16 +92,9 @@ class GunController extends BaseAuthedController {
|
|||||||
public function gunList()
|
public function gunList()
|
||||||
{
|
{
|
||||||
$gunList = array();
|
$gunList = array();
|
||||||
SqlHelper::ormSelect(
|
Gun::getGunList(function ($row) use(&$gunList) {
|
||||||
$this->_getSelfMysql(),
|
array_push($gunList, Gun::toDto($row));
|
||||||
't_gun',
|
});
|
||||||
array(
|
|
||||||
'account_id' => $this->_getAccountId()
|
|
||||||
),
|
|
||||||
function ($row) use(&$gunList) {
|
|
||||||
array_push($gunList, Gun::toDto($row));
|
|
||||||
}
|
|
||||||
);
|
|
||||||
$this->_rspData(array(
|
$this->_rspData(array(
|
||||||
'gun_list' => $gunList
|
'gun_list' => $gunList
|
||||||
));
|
));
|
||||||
|
@ -5,6 +5,7 @@ namespace models;
|
|||||||
require_once('mt/GunLevel.php');
|
require_once('mt/GunLevel.php');
|
||||||
require_once('mt/GunQuality.php');
|
require_once('mt/GunQuality.php');
|
||||||
require_once('models/GunSkin.php');
|
require_once('models/GunSkin.php');
|
||||||
|
require_once('services/NftService.php');
|
||||||
|
|
||||||
use mt;
|
use mt;
|
||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
@ -24,31 +25,55 @@ class Gun extends BaseModel {
|
|||||||
myself()->_getSelfMysql(),
|
myself()->_getSelfMysql(),
|
||||||
't_gun',
|
't_gun',
|
||||||
array(
|
array(
|
||||||
'account_id' => myself()->_getAccountId(),
|
|
||||||
'idx' => $gunUniId,
|
'idx' => $gunUniId,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if ($row) {
|
if ($row) {
|
||||||
$row['gun_uniid'] = $row['idx'];
|
$row['gun_uniid'] = $row['idx'];
|
||||||
|
if ($row['account_id'] != myself()->_getAccountId()) {
|
||||||
|
if (!services\NftService::isEquipOwner($row['token_id'])) {
|
||||||
|
$row = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getValidGun($gunId)
|
public static function getValidGun($gunId)
|
||||||
{
|
{
|
||||||
$row = SqlHelper::ormSelectOne(
|
$gunList = array();
|
||||||
myself()->_getSelfMysql(),
|
self::getGunList(function ($row) use($gunId, &$gunList) {
|
||||||
|
if ($row['gun_id'] == $gunId && $row['state'] == self::GETED_STATE) {
|
||||||
|
array_push($gunList, self::toDto($row));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return !empty($gunList) ? $gunList[0] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getGunList($cb)
|
||||||
|
{
|
||||||
|
SqlHelper::ormSelect(
|
||||||
|
$this->_getSelfMysql(),
|
||||||
't_gun',
|
't_gun',
|
||||||
array(
|
array(
|
||||||
'account_id' => myself()->_getAccountId(),
|
'account_id' => $this->_getAccountId()
|
||||||
'gun_id' => $gunId,
|
),
|
||||||
'state' => self::GETED_STATE,
|
function ($row) use($cb) {
|
||||||
)
|
$cb($row);
|
||||||
|
}
|
||||||
);
|
);
|
||||||
if ($row) {
|
foreach (services\NftService::getEquips() as $nftDb) {
|
||||||
$row['gun_uniid'] = $row['idx'];
|
$row = SqlHelper::ormSelectOne(
|
||||||
|
myself()->_getSelfMysql(),
|
||||||
|
't_gun',
|
||||||
|
array(
|
||||||
|
'token_id' => $nftDb['token_id'],
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if ($row) {
|
||||||
|
$cb($row);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $row;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function toDto($row)
|
public static function toDto($row)
|
||||||
@ -145,15 +170,16 @@ class Gun extends BaseModel {
|
|||||||
|
|
||||||
public static function update($gunUniId, $fieldsKv)
|
public static function update($gunUniId, $fieldsKv)
|
||||||
{
|
{
|
||||||
SqlHelper::update
|
if (self::find($gunUniId)) {
|
||||||
(myself()->_getSelfMysql(),
|
SqlHelper::update
|
||||||
't_gun',
|
(myself()->_getSelfMysql(),
|
||||||
array(
|
't_gun',
|
||||||
'account_id' => myself()->_getAccountId(),
|
array(
|
||||||
'idx' => $gunUniId,
|
'idx' => $gunUniId,
|
||||||
),
|
),
|
||||||
$fieldsKv
|
$fieldsKv
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ class Hero extends BaseModel {
|
|||||||
array(
|
array(
|
||||||
'account_id' => $this->_getAccountId()
|
'account_id' => $this->_getAccountId()
|
||||||
),
|
),
|
||||||
function ($row) {
|
function ($row) use($cb) {
|
||||||
$cb($row);
|
$cb($row);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -12,9 +12,29 @@ class NftService extends BaseService {
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function isEquipOwner($tokenId)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function isChipOwner($tokenId)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static function getHeros()
|
public static function getHeros()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getEquips()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getChips()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user