add avatar
This commit is contained in:
parent
4373194f91
commit
ac9fd117e4
@ -28,7 +28,7 @@ class Avatar(object):
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['!list', [AvatarInfo()], '装饰列表']
|
||||
['!list', [_common.AvatarInfo()], '装饰列表']
|
||||
]
|
||||
},{
|
||||
'name': 'equip',
|
||||
@ -55,19 +55,31 @@ class Avatar(object):
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
]
|
||||
},{
|
||||
'name': 'remove',
|
||||
'desc': '卸下装饰物品',
|
||||
'group': 'Avatar',
|
||||
'url': 'webapp/index.php?c=Avatar&a=remove',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['avatar_uniid', '', '装饰唯一id'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
]
|
||||
},{
|
||||
'name': 'clearAvatar',
|
||||
'desc': '全部卸下',
|
||||
'group': 'Avatar',
|
||||
'url': 'webapp/index.php?c=Avatar&a=clearAvatar',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['hero_uniid', '', '英雄唯一id'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
]
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
|
||||
class AvatarInfo(object):
|
||||
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['account_id', '', 'account_id'],
|
||||
['token_id', '', 'token_id'],
|
||||
['item_id', 0, 'item_id'],
|
||||
['item_type', 0, '1:翅膀'],
|
||||
['status', 0, '0:为穿戴 1:已穿戴'],
|
||||
['hero_idx', 0, '穿戴的英雄唯一id'],
|
||||
]
|
@ -272,6 +272,7 @@ class Hero(object):
|
||||
['advanced_count', 0, '进阶次数'],
|
||||
['offer_reward_state', 0, '是否悬赏中'],
|
||||
['tags', '', '1:Gen状态'],
|
||||
['!avatarInfo', [AvatarInfo()], '装饰信息'],
|
||||
|
||||
]
|
||||
|
||||
@ -1465,3 +1466,16 @@ class StakingPreview(object):
|
||||
['time', 0, '天数'],
|
||||
['interest', 0, '利息'],
|
||||
]
|
||||
|
||||
class AvatarInfo(object):
|
||||
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['avatar_uniid', '', '装饰唯一id'],
|
||||
['account_id', '', 'account_id'],
|
||||
['token_id', '', 'token_id'],
|
||||
['item_id', 0, 'item_id'],
|
||||
['item_type', 0, '1:翅膀'],
|
||||
['status', 0, '0:为穿戴 1:已穿戴'],
|
||||
['hero_uniid', 0, '穿戴的英雄唯一id'],
|
||||
]
|
@ -19,7 +19,7 @@ class AvatarController extends BaseAuthedController {
|
||||
public function avatarList(){
|
||||
$avatarList = array();
|
||||
Avatar::getAvatarList(function ($row) use (&$avatarList){
|
||||
array_push($avatarList,$row);
|
||||
array_push($avatarList,Avatar::toDto($row));
|
||||
});
|
||||
$this->_rspData(array(
|
||||
'list' => $avatarList
|
||||
@ -100,6 +100,10 @@ class AvatarController extends BaseAuthedController {
|
||||
return;
|
||||
}
|
||||
$avatarDbs = Avatar::getAvatarByHeroIdx($heroUniid);
|
||||
if (!$avatarDbs){
|
||||
$this->_rspErr(1, 'Meaningless operation');
|
||||
return;
|
||||
}
|
||||
foreach ($avatarDbs as $avatarDb){
|
||||
Avatar::update($avatarDb['idx'],array(
|
||||
'hero_idx' => null,
|
||||
|
@ -15,6 +15,7 @@ require_once('models/UserSeasonRing.php');
|
||||
require_once('models/Parachute.php');
|
||||
require_once('models/Chip.php');
|
||||
require_once('models/Pass.php');
|
||||
require_once('models/Avatar.php');
|
||||
require_once('mt/Parameter.php');
|
||||
require_once('mt/RankSeason.php');
|
||||
require_once('mt/LevelUp.php');
|
||||
@ -36,6 +37,7 @@ use models\Parachute;
|
||||
use models\UserSeasonRing;
|
||||
use models\Chip;
|
||||
use models\Pass;
|
||||
use models\Avatar;
|
||||
use services\LogService;
|
||||
|
||||
class BaseAuthedController extends BaseController {
|
||||
@ -547,6 +549,11 @@ class BaseAuthedController extends BaseController {
|
||||
$this->_openRandomBox($itemMeta,$awardService,$propertyService);
|
||||
}
|
||||
break;
|
||||
case mt\Item::AVATAR_TYPE:
|
||||
{
|
||||
Avatar::addAvatar($itemMeta);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
$this->_addLog('additems', 'invalid_item', array(
|
||||
|
@ -293,6 +293,7 @@ class BattleController extends BaseAuthedController {
|
||||
if ($heroDb) {
|
||||
$info['is_valid_battle'] = 1;
|
||||
$info['hero_dto'] = Hero::toDto($heroDb);
|
||||
$info['hero_dto']['avatar_info'] = Hero::avatarInfo($heroDb);
|
||||
} else {
|
||||
$info['errcode'] = 51;
|
||||
$info['errmsg'] = 'paramater error';
|
||||
|
@ -88,6 +88,7 @@ class HeroController extends BaseAuthedController {
|
||||
$resetLv_state = $this->_getDailyV(TN_DAILY_RESET_HERO_LEVEL_STATE, $unique_id);
|
||||
|
||||
$hero = Hero::toDto($heroDb);
|
||||
$hero['avatarInfo'] = Hero::avatarInfo($heroDb);
|
||||
$hero['resetLv_state'] = $resetLv_state;
|
||||
$this->_rspData(array(
|
||||
'data' => $hero
|
||||
|
@ -42,7 +42,21 @@ class Avatar extends BaseModel
|
||||
'hero_idx' => $heroUniid,
|
||||
)
|
||||
);
|
||||
return $rows;
|
||||
$avatarList = array();
|
||||
if (count($rows) > 0){
|
||||
foreach ($rows as $row){
|
||||
$row['avatar_uniid'] = $row['idx'];
|
||||
if ($row['account_id'] != myself()->_getAccountId()) {
|
||||
$openId = myself()->_getAddress();
|
||||
if (NftService::isAvatarOwner($openId, $row['token_id'])) {
|
||||
array_push($avatarList,$row);
|
||||
}
|
||||
}else{
|
||||
array_push($avatarList,$row);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $avatarList;
|
||||
}
|
||||
|
||||
public static function getOneByType($heroUniid,$itemType){
|
||||
@ -54,6 +68,15 @@ class Avatar extends BaseModel
|
||||
'item_type' => $itemType,
|
||||
)
|
||||
);
|
||||
if ($row) {
|
||||
$row['avatar_uniid'] = $row['idx'];
|
||||
if ($row['account_id'] != myself()->_getAccountId()) {
|
||||
$openId = myself()->_getAddress();
|
||||
if (!NftService::isAvatarOwner($openId, $row['token_id'])) {
|
||||
$row = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $row;
|
||||
}
|
||||
|
||||
@ -83,6 +106,19 @@ class Avatar extends BaseModel
|
||||
}
|
||||
}
|
||||
|
||||
public static function toDto($row){
|
||||
$dto = array(
|
||||
'idx' => $row['idx'],
|
||||
'avatar_uniid' => $row['idx'],
|
||||
'token_id' => $row['token_id'],
|
||||
'hero_uniid' => $row['hero_idx'],
|
||||
'item_id' => $row['item_id'],
|
||||
'item_type' => $row['item_type'],
|
||||
'status' => $row['status'],
|
||||
);
|
||||
return $dto;
|
||||
}
|
||||
|
||||
public static function addAvatar($avatarMeta){
|
||||
SqlHelper::insert(
|
||||
myself()->_getSelfMysql(),
|
||||
|
@ -11,6 +11,7 @@ require_once('mt/Item.php');
|
||||
require_once('models/HeroSkin.php');
|
||||
require_once('models/Chip.php');
|
||||
require_once('models/User.php');
|
||||
require_once('models/Avatar.php');
|
||||
require_once('models/ChipPlugin.php');
|
||||
require_once('services/NftService.php');
|
||||
require_once('services/FormulaService.php');
|
||||
@ -313,6 +314,17 @@ class Hero extends BaseModel {
|
||||
return $dto;
|
||||
}
|
||||
|
||||
public static function avatarInfo($row){
|
||||
$avatarDbs = Avatar::getAvatarByHeroIdx($row['idx']);
|
||||
$avatarInfos = array();
|
||||
if ($avatarDbs){
|
||||
foreach ($avatarDbs as $avatarDb){
|
||||
array_push($avatarInfos,Avatar::toDto($avatarDb));
|
||||
}
|
||||
}
|
||||
return $avatarInfos;
|
||||
}
|
||||
|
||||
public static function addFreeHero($heroMeta)
|
||||
{
|
||||
return self::internalAddHero(
|
||||
|
Loading…
x
Reference in New Issue
Block a user