Merge branch 'hjb' of git.kingsome.cn:server/game2006api into hjb
This commit is contained in:
commit
ba691ba72f
@ -281,6 +281,7 @@ class AAMarket(object):
|
||||
'permission': _common.LoginRequired,
|
||||
'is_json_params': True,
|
||||
'params': [
|
||||
['to_address', '', '目标address'],
|
||||
['!hero_uniids', [''], '英雄uniid列表(目前只支持1个)'],
|
||||
],
|
||||
'response': [
|
||||
|
74
doc/HeroSkin.py
Normal file
74
doc/HeroSkin.py
Normal file
@ -0,0 +1,74 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import _common
|
||||
|
||||
class HeroSkin(object):
|
||||
|
||||
def __init__(self):
|
||||
self.apis = [
|
||||
{
|
||||
'name': 'skinList',
|
||||
'desc': '皮肤列表',
|
||||
'group': 'HeroSkin',
|
||||
'url': 'webapp/index.php?c=HeroSkin&a=skinList',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['skin_id', 0, '皮肤itemId'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['!skin_list', [_common.HeroSkin()], '英雄皮肤列表']
|
||||
]
|
||||
},{
|
||||
'name': 'skinDetails',
|
||||
'desc': '皮肤详情',
|
||||
'group': 'HeroSkin',
|
||||
'url': 'webapp/index.php?c=HeroSkin&a=skinDetails',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['skin_uniid', 0, '皮肤uniid'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['data', _common.HeroSkin(), '皮肤详情']
|
||||
]
|
||||
},{
|
||||
'name': 'takeonSkin',
|
||||
'desc': '皮肤穿戴',
|
||||
'group': 'HeroSkin',
|
||||
'url': 'webapp/index.php?c=HeroSkin&a=takeonSkin',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['hero_uniid', 0, '英雄uniid'],
|
||||
['skin_uniid', 0, '皮肤uniid'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
]
|
||||
},{
|
||||
'name': 'demountSkin',
|
||||
'desc': '皮肤卸下',
|
||||
'group': 'HeroSkin',
|
||||
'url': 'webapp/index.php?c=HeroSkin&a=demountSkin',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['hero_uniid', 0, '英雄uniid'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
]
|
||||
},{
|
||||
'name': 'synSkin',
|
||||
'desc': '皮肤合成',
|
||||
'group': 'HeroSkin',
|
||||
'url': 'webapp/index.php?c=HeroSkin&a=synSkin',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['skin_id', 0, '皮肤itemId'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['property_chg', _common.PropertyChg(), '属性变更'],
|
||||
]
|
||||
},
|
||||
]
|
@ -11,7 +11,7 @@ class Other(object):
|
||||
'url': 'webapp/index.php?c=Other&a=tag',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['types', '', '红点类型(!!!注意由于红点的计算量较大,最好并发分批取红点状态)","分割 1:英雄 2:芯片 3:背包 4:签到 5:算力'],
|
||||
['types', '', '红点类型(!!!注意由于红点的计算量较大,最好并发分批取红点状态)","分割 1:英雄 2:芯片 3:背包 4:签到 5:算力 6:皮肤'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
@ -24,7 +24,7 @@ class Other(object):
|
||||
'url': 'webapp/index.php?c=Other&a=cancelTag',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['type', '', '1:英雄 2:芯片 3:背包 5:算力'],
|
||||
['type', '', '1:英雄 2:芯片 3:背包 5:算力 6:皮肤'],
|
||||
['item_unnid', '', 'item_unnid'],
|
||||
],
|
||||
'response': [
|
||||
|
@ -329,9 +329,16 @@ class HeroSkin(object):
|
||||
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['idx', 0, 'uniid'],
|
||||
['account_id', 0, 'account_id'],
|
||||
['skin_id', 0, '英雄皮肤id'],
|
||||
['is_have', 0, '是否拥有 1:拥有 0:未拥有'],
|
||||
['use_state', 0, '选中状态 1:选中 0:未选中'],
|
||||
['hero_uniid', 0, '所穿戴的英雄 0=未穿戴'],
|
||||
['skin_state', 0, ' 0=封装,1=解封'],
|
||||
['used', 0, ' 0=未使用,1=使用中'],
|
||||
['is_old', 0, ' 0:展示红点 1:不用展示'],
|
||||
['!rand_attr', [Attr()], ' 战斗属性'],
|
||||
['lucky', 0, '幸运值'],
|
||||
['wealth', 0, '财富值'],
|
||||
]
|
||||
|
||||
class Item(object):
|
||||
|
@ -194,15 +194,18 @@ CREATE TABLE `t_hero_skin` (
|
||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`account_id` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT 'account_id',
|
||||
`skin_id` int(11) NOT NULL DEFAULT '0' COMMENT '英雄皮肤id',
|
||||
`hero_id` int(11) NOT NULL DEFAULT '0' COMMENT '英雄id',
|
||||
`skin_state` int(11) NOT NULL DEFAULT '0' COMMENT '英雄皮肤状态 0=已经购,1 = 试用状态',
|
||||
`hero_uniid` int(11) NOT NULL DEFAULT '0' COMMENT '英雄uniid',
|
||||
`skin_state` int(11) NOT NULL DEFAULT '0' COMMENT '英雄皮肤状态 0=封装,1=解封',
|
||||
`used` int(11) NOT NULL DEFAULT '0' COMMENT '使用状态 0=未使用,1=使用中',
|
||||
`get_from` int(11) NOT NULL DEFAULT '0' COMMENT '获得方式 0 = 系统赠送 1 = 金币购买',
|
||||
`consume_num` int(11) NOT NULL DEFAULT '0' COMMENT '消耗货币的具体数量',
|
||||
`try_expire_at` int(11) NOT NULL DEFAULT '0' COMMENT '试用截止时间',
|
||||
`rand_attr` mediumblob COMMENT '随机属性',
|
||||
`wealth_attr` mediumblob COMMENT '财富值属性',
|
||||
`is_old` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0:展示红点 1:不用展示 ',
|
||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
PRIMARY KEY (`idx`),
|
||||
UNIQUE KEY `account_id_skinid` (`account_id`, `skin_id`)
|
||||
PRIMARY KEY (`idx`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
@ -1885,4 +1888,4 @@ CREATE TABLE `t_server_task_battle_count` (
|
||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
PRIMARY KEY (`idx`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
@ -7,7 +7,7 @@ CREATE TABLE `t_hero_skin` (
|
||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`account_id` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT 'account_id',
|
||||
`skin_id` int(11) NOT NULL DEFAULT '0' COMMENT '英雄皮肤id',
|
||||
`hero_id` int(11) NOT NULL DEFAULT '0' COMMENT '英雄id',
|
||||
`hero_uniid` int(11) NOT NULL DEFAULT '0' COMMENT '英雄uniid',
|
||||
`skin_state` int(11) NOT NULL DEFAULT '0' COMMENT '英雄皮肤状态 0=封装,1=解封',
|
||||
`used` int(11) NOT NULL DEFAULT '0' COMMENT '使用状态 0=未使用,1=使用中',
|
||||
`get_from` int(11) NOT NULL DEFAULT '0' COMMENT '获得方式 0 = 系统赠送 1 = 金币购买',
|
||||
@ -15,10 +15,10 @@ CREATE TABLE `t_hero_skin` (
|
||||
`try_expire_at` int(11) NOT NULL DEFAULT '0' COMMENT '试用截止时间',
|
||||
`rand_attr` mediumblob COMMENT '随机属性',
|
||||
`wealth_attr` mediumblob COMMENT '财富值属性',
|
||||
`is_old` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0:展示红点 1:不用展示 ',
|
||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
PRIMARY KEY (`idx`),
|
||||
UNIQUE KEY `account_id_skinid` (`account_id`, `skin_id`)
|
||||
PRIMARY KEY (`idx`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
insert into version (version) values(2024052101);
|
||||
|
@ -88,8 +88,9 @@ class BaseAuthedController extends BaseController {
|
||||
// }
|
||||
// }
|
||||
if (SERVER_ENV == _ONLINE) {
|
||||
//phpcommon\sendError(1001, 'session expiration');
|
||||
//die();
|
||||
phpcommon\sendError(1001, 'session expiration');
|
||||
die();
|
||||
return;
|
||||
}
|
||||
$this->accountId = getReqVal('account_id', '');
|
||||
$this->sessionId = getReqVal('session_id', '');
|
||||
|
@ -1013,7 +1013,7 @@ class BattleController extends BaseAuthedController {
|
||||
$info['is_valid_battle'] = 1;
|
||||
$info['hero_dto'] = Hero::toDto($heroDb);
|
||||
{//选用皮肤id
|
||||
$skinDb = HeroSkin::findBx($heroDb['hero_id']);
|
||||
$skinDb = HeroSkin::find($heroDb['skin_id']);
|
||||
if ($skinDb){
|
||||
$info['hero_dto']['skin_id'] = $skinDb['skin_id'];
|
||||
}
|
||||
|
@ -124,6 +124,8 @@ class BlockChainController extends BaseAuthedController {
|
||||
switch ($type) {
|
||||
case 1:
|
||||
{
|
||||
myself()->_rspErr(1, 'server internal error');
|
||||
return;
|
||||
$heroDb = Hero::find($uniid);
|
||||
if (!$heroDb) {
|
||||
myself()->_rspErr(1, 'hero not found');
|
||||
@ -145,7 +147,7 @@ class BlockChainController extends BaseAuthedController {
|
||||
myself()->_getNowTime(),
|
||||
myself()->_getAddress()
|
||||
);
|
||||
Hero::safeUpdateTokenId($heroDb['hero_uniid'], $tokenId);
|
||||
Hero::safeUpdateTokenId(myself()->_getAccountId(), $heroDb['hero_uniid'], $tokenId);
|
||||
$heroDb = Hero::find($uniid);
|
||||
if (!$heroDb) {
|
||||
myself()->_rspErr(1, 'hero not found');
|
||||
|
@ -79,50 +79,6 @@ class HeroController extends BaseAuthedController {
|
||||
));
|
||||
}
|
||||
|
||||
public function skinList()
|
||||
{
|
||||
$heroId = getReqVal('hero_id',0);
|
||||
if (!$heroId){
|
||||
$this->_rspErr(1, "param null");
|
||||
return;
|
||||
}
|
||||
$itemMeta = \mt\Item::get($heroId);
|
||||
if (!$itemMeta || $itemMeta['type']!=\mt\Item::HERO_TYPE){
|
||||
$this->_rspErr(1, "param error");
|
||||
return;
|
||||
}
|
||||
$skinList = array();
|
||||
$skinMeta = \mt\Item::getMetaListByType(\mt\Item::HERO_SKIN_TYPE);
|
||||
if ($skinMeta){
|
||||
foreach ($skinMeta as $value){
|
||||
if ($value['playerid'] == $heroId){
|
||||
array_push($skinList,HeroSkin::toDto($value));
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->_rspData(array(
|
||||
'skin_list' => $skinList
|
||||
));
|
||||
}
|
||||
|
||||
public function takeonSkin()
|
||||
{
|
||||
$heroUniId = getReqVal('hero_uniid', 0);
|
||||
$skinId = getReqVal('skin_id', 0);
|
||||
$heroDb = Hero::find($heroUniId);
|
||||
$heroSkinDb = HeroSkin::find($skinId);
|
||||
if (!$heroDb) {
|
||||
$this->_rspErr(1, "You don't have the hero yet");
|
||||
return;
|
||||
}
|
||||
$itemMeta = \mt\Item::get($skinId);
|
||||
if ($itemMeta['isdefaultskin'] != 1 && !$heroSkinDb) {
|
||||
$this->_rspErr(2, "You don't have the skin yet");
|
||||
return;
|
||||
}
|
||||
HeroSkin::takeonSkin( $skinId,$heroDb['hero_id']);
|
||||
$this->_rspOk();
|
||||
}
|
||||
|
||||
/*
|
||||
升阶预览
|
||||
|
155
webapp/controller/HeroSkinController.class.php
Normal file
155
webapp/controller/HeroSkinController.class.php
Normal file
@ -0,0 +1,155 @@
|
||||
<?php
|
||||
require_once('mt/Item.php');
|
||||
require_once('mt/DressAttribute.php');
|
||||
require_once('models/Hero.php');
|
||||
require_once('models/HeroSkin.php');
|
||||
|
||||
require_once('services/AwardService.php');
|
||||
require_once('services/PropertyChgService.php');
|
||||
require_once('services/LogService.php');
|
||||
|
||||
use phpcommon\SqlHelper;
|
||||
use models\Hero;
|
||||
use models\HeroSkin;
|
||||
use services\LogService;
|
||||
|
||||
class HeroSkinController extends BaseAuthedController {
|
||||
|
||||
public function skinList()
|
||||
{
|
||||
$skinId = trim(getReqVal('skin_id', 0));
|
||||
$itemMeta = \mt\Item::get($skinId);
|
||||
if ($itemMeta['type'] != \mt\Item::HERO_SKIN_TYPE){
|
||||
$this->_rspErr(1, 'skin_id error');
|
||||
return;
|
||||
}
|
||||
$skinList = array();
|
||||
HeroSkin::getSkinList($skinId,function ($row) use(&$skinList) {
|
||||
array_push($skinList, $row);
|
||||
});
|
||||
$this->_rspData(array(
|
||||
'skin_list' => $skinList
|
||||
));
|
||||
}
|
||||
|
||||
public function skinDetails()
|
||||
{
|
||||
$skinUniid = trim(getReqVal('skin_uniid', 0));
|
||||
if ( ! $skinUniid) {
|
||||
$this->_rspErr(1, 'Please enter instructions');
|
||||
return;
|
||||
}
|
||||
$heroSkinDb = HeroSkin::find($skinUniid);
|
||||
if (! $heroSkinDb){
|
||||
$this->_rspErr(1, "You don't have the hero yet");
|
||||
return;
|
||||
}
|
||||
$skin = HeroSkin::toDto($heroSkinDb);
|
||||
$this->_rspData(array(
|
||||
'data' => $skin
|
||||
));
|
||||
}
|
||||
|
||||
public function takeonSkin()
|
||||
{
|
||||
$heroUniid = getReqVal('hero_uniid', 0);
|
||||
$skinUniid = getReqVal('skin_uniid', 0);
|
||||
$heroDb = Hero::find($heroUniid);
|
||||
$heroSkinDb = HeroSkin::find($skinUniid);
|
||||
if (!$heroDb) {
|
||||
$this->_rspErr(1, "You don't have the hero yet");
|
||||
return;
|
||||
}
|
||||
if (!$heroSkinDb) {
|
||||
$this->_rspErr(1, "You don't have the hero skin yet");
|
||||
return;
|
||||
}
|
||||
if ($heroDb['skin_id']){
|
||||
HeroSkin::update($heroDb['skin_id'],array(
|
||||
'used'=>HeroSkin::NO_USE,
|
||||
'hero_uniid'=>0,
|
||||
'modifytime'=>myself()->_getNowTime(),
|
||||
));
|
||||
}
|
||||
Hero::update($heroUniid,array(
|
||||
'skin_id' => $skinUniid,
|
||||
'modifytime'=>myself()->_getNowTime()
|
||||
));
|
||||
HeroSkin::update($skinUniid,array(
|
||||
'used'=>HeroSkin::USED,
|
||||
'skin_state'=>HeroSkin::NO_LOCK,
|
||||
'hero_uniid'=>$heroUniid,
|
||||
'modifytime'=>myself()->_getNowTime(),
|
||||
));
|
||||
$this->_rspOk();
|
||||
}
|
||||
|
||||
public function demountSkin(){
|
||||
$heroUniid = getReqVal('hero_uniid', 0);
|
||||
$heroDb = Hero::find($heroUniid);
|
||||
if (!$heroDb) {
|
||||
$this->_rspErr(1, "You don't have the hero yet");
|
||||
return;
|
||||
}
|
||||
if (!$heroDb['skin_id']){
|
||||
$this->_rspErr(1, "Useless operation");
|
||||
return;
|
||||
}
|
||||
Hero::update($heroUniid,array(
|
||||
'skin_id' => 0,
|
||||
'modifytime'=>myself()->_getNowTime()
|
||||
));
|
||||
HeroSkin::update($heroDb['skin_id'],array(
|
||||
'used'=>HeroSkin::NO_USE,
|
||||
'skin_state'=>HeroSkin::NO_LOCK,
|
||||
'hero_uniid'=>0,
|
||||
'modifytime'=>myself()->_getNowTime(),
|
||||
));
|
||||
$this->_rspOk();
|
||||
}
|
||||
|
||||
public function synSkin(){
|
||||
$skinId = trim(getReqVal('skin_id', 0));
|
||||
$itemMeta = \mt\Item::get($skinId);
|
||||
if ($itemMeta['type'] != \mt\Item::HERO_SKIN_TYPE){
|
||||
$this->_rspErr(1, 'skin_id error');
|
||||
return;
|
||||
}
|
||||
$dressMeta = mt\DressAttribute::get($skinId);
|
||||
if (!$dressMeta){
|
||||
$this->_rspErr(1, 'skin_id error');
|
||||
return;
|
||||
}
|
||||
$needItem = explode(':',$dressMeta['needItem']);
|
||||
$costItems = array(
|
||||
array(
|
||||
'item_id' => $needItem[0],
|
||||
'item_num' => $needItem[1]
|
||||
),
|
||||
);
|
||||
$lackItem = null;
|
||||
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
|
||||
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
|
||||
return;
|
||||
}
|
||||
$this->_decItems($costItems);
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
$propertyChgService->addBagChg();
|
||||
HeroSkin::addSkin($itemMeta);
|
||||
$lastIdx = SqlHelper::getLastInsertId( myself()->_getSelfMysql());
|
||||
$skinDb = HeroSkin::find($lastIdx);
|
||||
$propertyChgService->addHeroSkinChg();
|
||||
$event = array(
|
||||
'ID' => 'heroSkin',
|
||||
'SUB_ID' => 'synthesis',
|
||||
'SUB_KEY' => 'heroSkin_synthesis',
|
||||
'cost_fragment' => $costItems,
|
||||
'result' => 1,
|
||||
'outcome_skin' => $skinDb,
|
||||
);
|
||||
LogService::burialPointEvent($event);
|
||||
$this->_rspData(array(
|
||||
'property_chg' => $propertyChgService->toDto(),
|
||||
));
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@ require_once('models/RewardsCec.php');
|
||||
require_once('models/GlobalData.php');
|
||||
require_once('models/HashRate.php');
|
||||
require_once('models/Hero.php');
|
||||
require_once('models/HeroSkin.php');
|
||||
require_once('models/Chip.php');
|
||||
require_once('models/Bag.php');
|
||||
|
||||
@ -32,6 +33,7 @@ use models\RewardsCec;
|
||||
use models\GlobalData;
|
||||
use models\HashRate;
|
||||
use models\Hero;
|
||||
use models\HeroSkin;
|
||||
use models\Chip;
|
||||
use models\Bag;
|
||||
|
||||
@ -41,6 +43,7 @@ class OtherController extends BaseAuthedController {
|
||||
const BAG = 3;
|
||||
const SIGN = 4;
|
||||
const HASH_RATE = 5;
|
||||
const HERO_SKIN = 6;
|
||||
|
||||
public function tag()
|
||||
{
|
||||
@ -117,6 +120,20 @@ class OtherController extends BaseAuthedController {
|
||||
'state' => $state,
|
||||
));
|
||||
}
|
||||
break;
|
||||
case self::HERO_SKIN :{
|
||||
$res = myself()->_getSelfMysql()->execQueryOne("SELECT COUNT(idx) as totalNum FROM t_hero_skin WHERE account_id=:account AND is_old=:is_old LIMIT 1",array(
|
||||
'account' => myself()->_getAccountId(),
|
||||
'is_old' => 0,
|
||||
));
|
||||
if ($res['totalNum']){
|
||||
$state = 1;
|
||||
}
|
||||
array_push($list,array(
|
||||
'type' => self::HERO_SKIN,
|
||||
'state' => $state,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -182,6 +199,18 @@ class OtherController extends BaseAuthedController {
|
||||
}
|
||||
}
|
||||
break;
|
||||
case self::HERO_SKIN :{
|
||||
$skinDb = HeroSkin::find($unnid);
|
||||
if (!$skinDb){
|
||||
$this->_rspErr(1, 'param item_unnid error');
|
||||
return;
|
||||
}
|
||||
HeroSkin::update($unnid,array(
|
||||
'is_old' => 1
|
||||
));
|
||||
$propertyChgService->addHeroSkinChg();
|
||||
}
|
||||
break;
|
||||
default:{
|
||||
$this->_rspErr(4, 'param type error');
|
||||
return;
|
||||
|
110
webapp/controller/OutAppMintController.class.php
Normal file
110
webapp/controller/OutAppMintController.class.php
Normal file
@ -0,0 +1,110 @@
|
||||
<?php
|
||||
use phpcommon\SqlHelper;
|
||||
require_once('models/Nft.php');
|
||||
require_once('models/User.php');
|
||||
require_once('models/Hero.php');
|
||||
require_once('models/BuyRecord.php');
|
||||
require_once('services/NftService.php');
|
||||
require_once('mt/NftDesc.php');
|
||||
require_once('mt/Hero.php');
|
||||
require_once('mt/EconomyAttribute.php');
|
||||
|
||||
use models\Nft;
|
||||
use models\User;
|
||||
use models\Hero;
|
||||
use models\BuyRecord;
|
||||
|
||||
class OutAppMintController extends BaseController {
|
||||
|
||||
public function mintHero()
|
||||
{
|
||||
error_log(json_encode($_REQUEST));
|
||||
$accountId = getReqVal('account_id', '');
|
||||
//$accountAddress = User::findUserAddress($accountId);
|
||||
//$accountAddress = '0x0c6c7399f1b6b19e96950ef294685bfd0dc46434';
|
||||
$accountAddress = getReqVal('account_address', '');
|
||||
$toAddress = getReqVal('to_address', '');
|
||||
$uniid = getReqVal('uniid', 0);
|
||||
error_log(json_encode(array(
|
||||
'accoutn_id' => $accountId,
|
||||
'uuid' => $uniid
|
||||
)));
|
||||
$heroDb = Hero::findByAccountIdEx($accountId, $uniid);
|
||||
if (!$heroDb) {
|
||||
myself()->_rspErr(1, 'hero not found');
|
||||
return;
|
||||
}
|
||||
/*
|
||||
if (!$heroDb['seal_type']) {
|
||||
myself()->_rspErr(1, 'hero no seal');
|
||||
return;
|
||||
}*/
|
||||
$isMint = true;
|
||||
$tokenId = $heroDb['token_id'];
|
||||
if ($heroDb['token_id'] && $heroDb['activate']) {
|
||||
myself()->_rspErr(1, 'hero already on chain');
|
||||
return;
|
||||
$isMint = false;
|
||||
} else if (empty($tokenId) ){
|
||||
$tokenId = BuyRecord::genOrderId
|
||||
(
|
||||
GAME_ID,
|
||||
phpcommon\BC_FUNC_CREATION,
|
||||
myself()->_getNowTime(),
|
||||
$accountAddress
|
||||
);
|
||||
Hero::safeUpdateTokenId($accountId, $heroDb['idx'], $tokenId);
|
||||
$heroDb = Hero::findByAccountIdEx($accountId, $uniid);
|
||||
if (!$heroDb) {
|
||||
myself()->_rspErr(1, 'hero not found');
|
||||
return;
|
||||
}
|
||||
if ($heroDb['token_id'] != $tokenId) {
|
||||
myself()->_rspErr(500, 'server internal error');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'c' => 'BcService',
|
||||
'a' => 'mintHero',
|
||||
'account_id' => $accountId,
|
||||
'account_address' => $accountAddress,
|
||||
'token_ids' => $tokenId,
|
||||
'nft_address' => NORMAL_HERO_CONTRACT_ADDRESS,
|
||||
'to_address' => $toAddress,
|
||||
'net_id' => NET_ID
|
||||
);
|
||||
error_log(json_encode($params));
|
||||
{
|
||||
$url = self::getWeb3ServiceUrl();
|
||||
$response = '';
|
||||
if (!phpcommon\HttpClient::get
|
||||
($url,
|
||||
$params,
|
||||
$response)) {
|
||||
myself()->_rspErr(500, 'server internal error');
|
||||
die();
|
||||
return;
|
||||
}
|
||||
error_log($response);
|
||||
$rspObj = json_decode($response, true);
|
||||
if ($rspObj['errcode'] == 0) {
|
||||
myself()->_rspData(array(
|
||||
'trans_id' => '',
|
||||
'trans_req' => $rspObj['trans_req']
|
||||
));
|
||||
} else {
|
||||
myself()->_rspErr(500, 'server internal error');
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function getWeb3ServiceUrl()
|
||||
{
|
||||
$web3ServiceCluster = require_once('../config/web3service.cluster.php');
|
||||
return $web3ServiceCluster[rand() % count($web3ServiceCluster)];
|
||||
}
|
||||
|
||||
}
|
@ -442,4 +442,65 @@ class OutAppNftController extends BaseController {
|
||||
return $quality;
|
||||
}
|
||||
|
||||
public function getHeroList()
|
||||
{
|
||||
$accountId = getReqVal('account_id', '');
|
||||
$rows = SqlHelper::ormSelect(
|
||||
myself()->_getMysql($accountId),
|
||||
't_hero',
|
||||
array(
|
||||
'account_id' => $accountId,
|
||||
)
|
||||
);
|
||||
$rspData = array(
|
||||
'rows' => array()
|
||||
);
|
||||
foreach ($rows as $row) {
|
||||
$info = array(
|
||||
'uniid' => '',
|
||||
'net_id' => 0,
|
||||
'contract_address' => '',
|
||||
'token_id' => '',
|
||||
'owner_address' => '',
|
||||
'meta_url' => '',
|
||||
'name' => '',
|
||||
'item_id' => 0,
|
||||
'type' => 0,
|
||||
'image' => '',
|
||||
'on_sale' => 0,
|
||||
'detail' => array()
|
||||
);
|
||||
$heroDb = $row;
|
||||
$info['uniid'] = $heroDb['idx'];
|
||||
$heroAttrs = emptyReplace(json_decode($heroDb['wealth_attr'], true), array());
|
||||
$heroResult = \mt\EconomyAttribute::getAttrValue($heroAttrs);
|
||||
$wealth = $heroResult['wealth'];
|
||||
$wealth_rate = $heroResult['wealth_rate'];
|
||||
$lucky = $heroResult['lucky'];
|
||||
$lucky_rate = $heroResult['lucky_rate'];
|
||||
$heroAbility = Hero::abilityInfo($heroDb);
|
||||
$heroMeta = \mt\Hero::get($heroDb['hero_id']);
|
||||
if ($heroMeta) {
|
||||
$itemMeta = \mt\Item::get($heroDb['hero_id']);
|
||||
$heroAtteMeta = \mt\EconomyAttribute::findByGrade($itemMeta['relationship'],$heroDb['quality']);
|
||||
//$info['meta_url'] = NFT_META_URL . '/hero/meta/' . $nftDb['net_id'] . '/' . $nftDb['token_id'];
|
||||
$info['name'] = $heroMeta['name'];
|
||||
$info['item_id'] = $heroMeta['id'];
|
||||
$info['type'] = Nft::HERO_TYPE;
|
||||
$info['image'] = 'https://res2.counterfire.games/nft/meta/' . $heroMeta['id'] . '_' . $this->getRealHeroQuality($heroDb) . '.gif';
|
||||
$info['detail']['quality'] = $this->getRealHeroQuality($heroDb);
|
||||
$info['detail']['max_mining_days'] = $heroAtteMeta['validTime'];
|
||||
$info['detail']['wealth'] = floor($wealth * (1+$wealth_rate));
|
||||
$info['detail']['lucky'] = floor($lucky * (1+$lucky_rate));
|
||||
$info['detail']['hp'] = $heroAbility['hp'];
|
||||
$info['detail']['atk'] = $heroAbility['attack'];
|
||||
$info['detail']['def'] = $heroAbility['defence'];
|
||||
$info['detail']['block'] = $heroAbility['block'];
|
||||
$info['detail']['crit'] = $heroAbility['critical'];
|
||||
}
|
||||
array_push($rspData['rows'], $info);
|
||||
}
|
||||
myself()->_rspData($rspData);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -127,8 +127,7 @@ class RankingController extends BaseAuthedController {
|
||||
$heroDb = Hero::findByAccountId($row['account_id'],$row['hero_id']);
|
||||
|
||||
if ($heroDb){
|
||||
$heroItemId = $heroDb['hero_id'];
|
||||
$skinDb = HeroSkin::findByAccountId($row['account_id'],$heroItemId);
|
||||
$skinDb = HeroSkin::findByAccountId($row['account_id'],$heroDb['skin_id']);
|
||||
$hero_skin = $skinDb ? $skinDb['skin_id']:0;
|
||||
}
|
||||
|
||||
|
@ -72,6 +72,22 @@ class Hero extends BaseModel {
|
||||
return self::internalFind($accountId, User::findUserAddress($accountId), $heroUniId);
|
||||
}
|
||||
|
||||
public static function findByAccountIdEx($accountId, $heroUniId)
|
||||
{
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
myself()->_getMysql($accountId),
|
||||
't_hero',
|
||||
array(
|
||||
'idx' => $heroUniId,
|
||||
'account_id' => $accountId,
|
||||
)
|
||||
);
|
||||
if ($row) {
|
||||
$row['hero_uniid'] = $row['idx'];
|
||||
}
|
||||
return $row;
|
||||
}
|
||||
|
||||
public static function findByTokenId($tokenId)
|
||||
{
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
@ -258,7 +274,7 @@ class Hero extends BaseModel {
|
||||
if ($row['idx'] == $userDb['hero_id'] && self::findByAccountId(myself()->_getAccountId(),$userDb['hero_id'])){
|
||||
$isSelect = 1;
|
||||
}
|
||||
$skinDb = HeroSkin::findBx($row['hero_id']);
|
||||
$skinDb = HeroSkin::find($row['skin_id']);
|
||||
// $attribute = self::celHeroWealthUpLimit($row);
|
||||
{
|
||||
$heroMeta = \mt\Item::get($row['hero_id']);
|
||||
@ -381,6 +397,15 @@ class Hero extends BaseModel {
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($row['skin_id']){
|
||||
$skinDb= HeroSkin::find($row['skin_id']);
|
||||
$skinAttrs = emptyReplace(json_decode($skinDb['wealth_attr'], true), array());
|
||||
$skinResult = \mt\EconomyAttribute::getAttrValue($skinAttrs);
|
||||
$wealth += $skinResult['wealth'];
|
||||
$wealth_rate += $skinResult['wealth_rate'];
|
||||
$lucky += $skinResult['lucky'];
|
||||
$lucky_rate += $skinResult['lucky_rate'];
|
||||
}
|
||||
return array(
|
||||
"wealth" => floor($wealth * (1+$wealth_rate)),
|
||||
"lucky" => floor($lucky * (1+$lucky_rate)),
|
||||
@ -584,14 +609,7 @@ class Hero extends BaseModel {
|
||||
|
||||
public static function internalAddHero($conn, $heroMeta, $accountId, $tokenId,$quality = 1)
|
||||
{
|
||||
$skinItemMeta = \mt\Item::getMetaListByType(\mt\Item::HERO_SKIN_TYPE);
|
||||
if ($skinItemMeta){
|
||||
foreach ($skinItemMeta as $value){
|
||||
if ($value['playerid'] == $heroMeta['id'] && $value['isdefaultskin'] ==1){
|
||||
HeroSkin::addSkin($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$randAttr = self::getRandAttr($heroMeta['id']) ;
|
||||
$attribute = \mt\EconomyAttribute::getAttribute($heroMeta['relationship'], $quality);
|
||||
$seal_type = 0;
|
||||
@ -671,18 +689,17 @@ class Hero extends BaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
public static function safeUpdateTokenId($heroUniId, $tokenId)
|
||||
public static function safeUpdateTokenId($accountId, $heroUniId, $tokenId)
|
||||
{
|
||||
if (self::find($heroUniId)) {
|
||||
myself()->_getSelfMysql()->execScript(
|
||||
'UPDATE t_hero SET token_id=:token_id ' .
|
||||
'WHERE idx=:idx AND token_id IS NULL;',
|
||||
array(
|
||||
':idx' => $heroUniId,
|
||||
':token_id' => $tokenId,
|
||||
)
|
||||
);
|
||||
}
|
||||
myself()->_getMysql($accountId)->execScript(
|
||||
'UPDATE t_hero SET token_id=:token_id ' .
|
||||
'WHERE idx=:idx AND account_id=:account_id AND token_id IS NULL;',
|
||||
array(
|
||||
':idx' => $heroUniId,
|
||||
':account_id' => $accountId,
|
||||
':token_id' => $tokenId,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function updateByTokenId($tokenId, $fieldsKv)
|
||||
|
@ -3,97 +3,28 @@
|
||||
namespace models;
|
||||
|
||||
require_once('mt/Hero.php');
|
||||
require_once('mt/DressAttribute.php');
|
||||
require_once('mt/BattleRandAttribute.php');
|
||||
require_once('mt/EconomyAttribute.php');
|
||||
|
||||
use mt;
|
||||
use phpcommon\SqlHelper;
|
||||
|
||||
class HeroSkin extends BaseModel {
|
||||
|
||||
const GETED_STATE = 0;
|
||||
const TRY_USING_STATE = 1;
|
||||
const USED = 1;
|
||||
const NO_USE = 0;
|
||||
|
||||
public static function find($skinId)
|
||||
{
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
myself()->_getSelfMysql(),
|
||||
't_hero_skin',
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'skin_id' => $skinId
|
||||
)
|
||||
);
|
||||
return $row;
|
||||
}
|
||||
const LOCK = 0;
|
||||
const NO_LOCK = 1;
|
||||
|
||||
public static function findBx($heroId)
|
||||
{
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
myself()->_getSelfMysql(),
|
||||
't_hero_skin',
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'hero_id' => $heroId
|
||||
)
|
||||
);
|
||||
return $row;
|
||||
}
|
||||
public static function findByAccountId($accountId, $heroId)
|
||||
{
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
myself()->_getSelfMysql(),
|
||||
't_hero_skin',
|
||||
array(
|
||||
'account_id' => $accountId,
|
||||
'hero_id' => $heroId
|
||||
)
|
||||
);
|
||||
return $row;
|
||||
}
|
||||
|
||||
public static function takeonSkin($skinId,$heroId){
|
||||
$row = self::findBx($heroId);
|
||||
SqlHelper::update(
|
||||
myself()->_getSelfMysql(),
|
||||
't_hero_skin',
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'skin_id' => $row['skin_id']
|
||||
),
|
||||
array(
|
||||
'hero_id'=>0
|
||||
)
|
||||
);
|
||||
SqlHelper::upsert(
|
||||
myself()->_getSelfMysql(),
|
||||
't_hero_skin',
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'skin_id' => $skinId
|
||||
),
|
||||
array(
|
||||
'hero_id'=>$heroId
|
||||
),
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'skin_id' => $skinId,
|
||||
'skin_state' => 0,
|
||||
'get_from' => 0,
|
||||
'consume_num' => 0,
|
||||
'try_expire_at' => 0,
|
||||
'hero_id' => $heroId,
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public static function getSkinList($cb){
|
||||
public static function getSkinList($skinId,$cb){
|
||||
SqlHelper::ormSelect(
|
||||
myself()->_getSelfMysql(),
|
||||
't_hero_skin',
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId()
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'skin_id' => $skinId
|
||||
),
|
||||
function ($row) use($cb) {
|
||||
$cb($row);
|
||||
@ -101,51 +32,121 @@ class HeroSkin extends BaseModel {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public static function toDto($meta)
|
||||
public static function find($uniid)
|
||||
{
|
||||
$row = self::find($meta['id']);
|
||||
$is_have = 0;
|
||||
$use_state = 0;
|
||||
if ($row || $meta['isdefaultskin'] == 1){
|
||||
$is_have = 1;
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
myself()->_getSelfMysql(),
|
||||
't_hero_skin',
|
||||
array(
|
||||
'idx' => $uniid,
|
||||
)
|
||||
);
|
||||
if ($row && $row['account_id'] != myself()->_getAccountId()) {
|
||||
$row = null;
|
||||
}
|
||||
if ($row && $row['hero_id']){
|
||||
$use_state = 1;
|
||||
return $row;
|
||||
}
|
||||
|
||||
public static function findByAccountId($accountId, $uniid)
|
||||
{
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
myself()->_getSelfMysql(),
|
||||
't_hero_skin',
|
||||
array(
|
||||
'idx' => $uniid,
|
||||
)
|
||||
);
|
||||
if ($row && $row['account_id'] != $accountId) {
|
||||
$row = null;
|
||||
}
|
||||
return $row;
|
||||
}
|
||||
|
||||
public static function update($skinUniid,$fieldsKv){
|
||||
if (self::find($skinUniid)){
|
||||
SqlHelper::update(
|
||||
myself()->_getSelfMysql(),
|
||||
't_hero_skin',
|
||||
array(
|
||||
'idx' => $skinUniid,
|
||||
),
|
||||
$fieldsKv
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static function toDto($row)
|
||||
{
|
||||
$attr = emptyReplace(json_decode($row['rand_attr'], true), array());
|
||||
|
||||
return array(
|
||||
'skin_id'=>$meta['id'],
|
||||
'is_have' => $is_have,
|
||||
'use_state' => $use_state,
|
||||
'idx' => $row['idx'],
|
||||
'skin_uniid' => $row['idx'],
|
||||
'account_id' => $row['account_id'],
|
||||
'skin_id' => $row['skin_id'],
|
||||
'hero_uniid' => $row['hero_uniid'],
|
||||
'skin_state' => $row['skin_state'],
|
||||
'used' => $row['used'],
|
||||
'is_old' => $row['is_old'],
|
||||
'rand_attr' => $attr,
|
||||
'lucky' => self::getSkinLucky($row),
|
||||
'wealth' => self::getSkinWealth($row),
|
||||
);
|
||||
}
|
||||
|
||||
public static function addSkin($itemMeta)
|
||||
{
|
||||
$heroId = 0;
|
||||
if ($itemMeta['isdefaultskin'] == 1){
|
||||
$heroId = $itemMeta['playerid'];
|
||||
$rand_attr = array();
|
||||
$wealth_attr = array();
|
||||
$dressMeta = mt\DressAttribute::get($itemMeta['id']);
|
||||
if ($dressMeta) {
|
||||
$randMeta = mt\BattleRandAttribute::getByWeight($dressMeta['battleAttribute']);
|
||||
$rand_attr = mt\BattleRandAttribute::getRandAttr($randMeta);
|
||||
$wealth_attr = \mt\EconomyAttribute::getAttribute($dressMeta['economyAttribute'], 1);
|
||||
}
|
||||
SqlHelper::upsert(
|
||||
SqlHelper::insert(
|
||||
myself()->_getSelfMysql(),
|
||||
't_hero_skin',
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'skin_id' => $itemMeta['id']
|
||||
),
|
||||
array(),
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'skin_id' => $itemMeta['id'],
|
||||
'skin_state' => 0,
|
||||
'skin_state' => self::LOCK,
|
||||
'used' => self::NO_USE,
|
||||
'get_from' => 0,
|
||||
'consume_num' => 0,
|
||||
'try_expire_at' => 0,
|
||||
'hero_id' => $heroId,
|
||||
'rand_attr' => json_encode($rand_attr),
|
||||
'wealth_attr' => json_encode($wealth_attr),
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function getSkinWealth($row){
|
||||
return self::celEconomyAttribute($row)["wealth"];
|
||||
}
|
||||
|
||||
public static function getSkinLucky($row){
|
||||
return self::celEconomyAttribute($row)["lucky"];
|
||||
}
|
||||
|
||||
private static function celEconomyAttribute($row){
|
||||
|
||||
//最大财富值和幸运值计算
|
||||
$wealth = 0;
|
||||
$wealth_rate = 0;
|
||||
$lucky = 0;
|
||||
$lucky_rate = 0;
|
||||
$heroAttrs = emptyReplace(json_decode($row['wealth_attr'], true), array());
|
||||
$heroResult = \mt\EconomyAttribute::getAttrValue($heroAttrs);
|
||||
$wealth += $heroResult['wealth'];
|
||||
$wealth_rate += $heroResult['wealth_rate'];
|
||||
$lucky += $heroResult['lucky'];
|
||||
$lucky_rate += $heroResult['lucky_rate'];
|
||||
return array(
|
||||
"wealth" => floor($wealth * (1+$wealth_rate)),
|
||||
"lucky" => floor($lucky * (1+$lucky_rate)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ class Nft extends BaseModel
|
||||
const EXPLORER_TYPE = 9; //Explorer
|
||||
const CANDY_TYPE = 10; //CANDY
|
||||
const GOLD_BULLION_TYPE = 11; //金砖
|
||||
const GCARD_HERO_TYPE = 12; //游戏内合成的nft英雄
|
||||
const RING_TYPE = 19; //戒指
|
||||
const AVATAR_TYPE = 30; //装饰
|
||||
|
||||
|
@ -212,7 +212,7 @@ class User extends BaseModel {
|
||||
$heroId = $heroDb['hero_id'];
|
||||
}
|
||||
$preset = HeroPreset::getHeroPreset($row['hero_id']);
|
||||
$skinDb = HeroSkin::findBx($heroId);
|
||||
$skinDb = HeroSkin::find($heroDb['skin_id']);
|
||||
$honorInfo = array();
|
||||
if ($row['address']){
|
||||
$honorInfo = UserHonor::info($row['address']);
|
||||
@ -236,7 +236,7 @@ class User extends BaseModel {
|
||||
'parachute' => $row['parachute'] ? $row['parachute'] : Parachute::$parachute,
|
||||
'hero_uniId' => $row['hero_id'],
|
||||
'hero_id' => $heroId,
|
||||
'hero_skin' =>$skinDb['skin_id'],
|
||||
'hero_skin' =>$skinDb ? $skinDb['skin_id']:0,
|
||||
'hero_lv' =>$heroDb['hero_lv'],
|
||||
'presetInfo' => $preset,
|
||||
'is_leader' => 0,
|
||||
|
20
webapp/mt/DressAttribute.php
Normal file
20
webapp/mt/DressAttribute.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace mt;
|
||||
|
||||
|
||||
class DressAttribute {
|
||||
public static function get($id)
|
||||
{
|
||||
return getXVal(self::getMetaList(), $id);
|
||||
}
|
||||
|
||||
protected static function getMetaList()
|
||||
{
|
||||
if (!self::$metaList) {
|
||||
self::$metaList = getMetaTable('dressAttribute@dressAttribute.php');
|
||||
}
|
||||
return self::$metaList;
|
||||
}
|
||||
|
||||
protected static $metaList;
|
||||
}
|
@ -156,21 +156,6 @@ class ShopService {
|
||||
{
|
||||
$errCode = 0;
|
||||
$errMsg = '';
|
||||
switch ($itemMeta['type']) {
|
||||
case mt\Item::HERO_SKIN_TYPE: {
|
||||
$heroSkinDb = HeroSkin::find($itemMeta['id']);
|
||||
if ($heroSkinDb) {
|
||||
$errCode = 10;
|
||||
$errMsg = 'You already have the skin';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user