英雄皮肤
This commit is contained in:
parent
b8e082a83f
commit
59ec4c358a
@ -26,6 +26,7 @@ class Hero(object):
|
|||||||
'url': 'webapp/index.php?c=Hero&a=skinList',
|
'url': 'webapp/index.php?c=Hero&a=skinList',
|
||||||
'params': [
|
'params': [
|
||||||
_common.ReqHead(),
|
_common.ReqHead(),
|
||||||
|
['hero_id', 0, '英雄itemId'],
|
||||||
],
|
],
|
||||||
'response': [
|
'response': [
|
||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
|
@ -245,10 +245,9 @@ class Hero(object):
|
|||||||
['lock_type', 0, '0:无锁 1:升级 2:升阶 3:派遣中'],
|
['lock_type', 0, '0:无锁 1:升级 2:升阶 3:派遣中'],
|
||||||
['unlock_lefttime', 0, '解锁剩余时间(单位秒)'],
|
['unlock_lefttime', 0, '解锁剩余时间(单位秒)'],
|
||||||
['unlock_time', 0, '使用解锁utc时间(升级或者升阶触发),锁定期间不可战斗和做其他操作,配合lock_type使用'],
|
['unlock_time', 0, '使用解锁utc时间(升级或者升阶触发),锁定期间不可战斗和做其他操作,配合lock_type使用'],
|
||||||
['current_pvp_get_ceg', 0, '当前pvp获取的ceg数量'],
|
['current_get_gold', 0, '当前获取的gold数量'],
|
||||||
['current_pve_get_ceg', 0, '当前pve获取的ceg数量'],
|
['last_get_gold_time', 0, '最后一次获取gold时间'],
|
||||||
['last_pvp_get_ceg_time', 0, '最后一次获取pvp获取ceg时间'],
|
['gold_uplimit', 0, '每天gold上限'],
|
||||||
['last_pve_get_ceg_time', 0, '最后一次获取pve获取ceg时间'],
|
|
||||||
['unlock_trade_time', 0, '出售解锁utc时间(升级或者升阶完成后触发),只锁交易,其他的操作仍可进行,和lock_type无关是独立的锁!!!'],
|
['unlock_trade_time', 0, '出售解锁utc时间(升级或者升阶完成后触发),只锁交易,其他的操作仍可进行,和lock_type无关是独立的锁!!!'],
|
||||||
['advanced_count', 0, '进阶次数'],
|
['advanced_count', 0, '进阶次数'],
|
||||||
['offer_reward_state', 0, '是否悬赏中'],
|
['offer_reward_state', 0, '是否悬赏中'],
|
||||||
@ -289,8 +288,8 @@ class HeroSkin(object):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.fields = [
|
self.fields = [
|
||||||
['skin_id', 0, '英雄皮肤id'],
|
['skin_id', 0, '英雄皮肤id'],
|
||||||
['skin_state', 0, '英雄皮肤状态 0=已经购,1 = 试用状态'],
|
['is_have', 0, '是否拥有 1:拥有 0:未拥有'],
|
||||||
['try_expire_at', 0, '试用到期时间(utc时间)'],
|
['use_state', 0, '选中状态 1:选中 0:未选中'],
|
||||||
]
|
]
|
||||||
|
|
||||||
class Item(object):
|
class Item(object):
|
||||||
|
@ -184,6 +184,7 @@ CREATE TABLE `t_hero_skin` (
|
|||||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||||
`account_id` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT 'account_id',
|
`account_id` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT 'account_id',
|
||||||
`skin_id` int(11) NOT NULL DEFAULT '0' COMMENT '英雄皮肤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 = 试用状态',
|
`skin_state` int(11) NOT NULL DEFAULT '0' COMMENT '英雄皮肤状态 0=已经购,1 = 试用状态',
|
||||||
`get_from` 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 '消耗货币的具体数量',
|
`consume_num` int(11) NOT NULL DEFAULT '0' COMMENT '消耗货币的具体数量',
|
||||||
|
@ -75,6 +75,299 @@ 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;
|
||||||
|
}
|
||||||
|
if (!$heroSkinDb) {
|
||||||
|
$this->_rspErr(2, "You don't have the skin yet");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
HeroSkin::takeonSkin( $skinId,$heroDb['hero_id']);
|
||||||
|
$this->_rspOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function upgradeLevelPreview(){
|
||||||
|
$heroUniId = getReqVal('hero_uniid', 0);
|
||||||
|
$heroDb = Hero::find($heroUniId);
|
||||||
|
if (!$heroDb) {
|
||||||
|
$this->_rspErr(1, 'hero does not exist');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$heroMeta = mt\Hero::get($heroDb['hero_id']);
|
||||||
|
if (!$heroMeta) {
|
||||||
|
$this->_rspErr(100, 'server internal error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$nextLevelMeta = mt\HeroLevelAttr::getByLevel($heroDb['hero_lv'] + 1);
|
||||||
|
if (!$nextLevelMeta) {
|
||||||
|
$this->_rspErr(5, "It's already the highest level");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$meta = mt\HeroLevel::get($heroDb['hero_lv'] + 1);
|
||||||
|
$costItems = array(
|
||||||
|
array(
|
||||||
|
'item_id' => V_ITEM_GOLD,
|
||||||
|
'item_num' => $meta['gold']
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'item_id' => V_ITEM_DIAMOND,
|
||||||
|
'item_num' => $meta['diamond']
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$newHeroDb = $heroDb;
|
||||||
|
$newHeroDb['hero_lv'] += 1;
|
||||||
|
$attrs = mt\HeroLevelAttr::addRandAttrNew($heroDb,0);
|
||||||
|
$newHeroDb['rand_attr'] = json_encode($attrs);
|
||||||
|
|
||||||
|
$heroDto = Hero::toDto($heroDb);
|
||||||
|
$newHeroDto = Hero::toDto($newHeroDb);
|
||||||
|
$this->_rspData(array(
|
||||||
|
|
||||||
|
'old_hero' => $heroDto,
|
||||||
|
'new_hero' => $newHeroDto,
|
||||||
|
'cost' => $costItems
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function upgradeLv()
|
||||||
|
{
|
||||||
|
$heroUniId = getReqVal('hero_uniid', 0);
|
||||||
|
$costHeroUniId = getReqVal('cost_hero_uniid', 0);
|
||||||
|
$heroDb = Hero::find($heroUniId);
|
||||||
|
$oldHero = Hero::toDto($heroDb);
|
||||||
|
$costHeroDb = Hero::findEx($costHeroUniId);
|
||||||
|
if (!$heroDb) {
|
||||||
|
$this->_rspErr(100, 'param error or null');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($heroDb['hero_lv'] == Hero::LV_1 ||
|
||||||
|
$heroDb['hero_lv'] == Hero::LV_2 ||
|
||||||
|
$heroDb['hero_lv'] == Hero::LV_3 ){
|
||||||
|
if (! $costHeroDb){
|
||||||
|
$this->_rspErr(100, 'material param error or null');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($costHeroDb['token_id']){
|
||||||
|
$this->_rspErr(100, 'NFT cannot be a material');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($costHeroDb['state'] == Hero::FREE_STATE){
|
||||||
|
$this->_rspErr(100, 'Unable to use free hero');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch ($heroDb['hero_lv']){
|
||||||
|
case Hero::LV_1:{
|
||||||
|
if ($heroDb['hero_lv'] < $costHeroDb['hero_lv']){
|
||||||
|
$this->_rspErr(100, 'Grade discrepancy');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};break;
|
||||||
|
case Hero::LV_2:{
|
||||||
|
if ($heroDb['hero_lv'] < $costHeroDb['hero_lv'] && $costHeroDb['hero_lv'] <= Hero::LV_1){
|
||||||
|
$this->_rspErr(100, 'Grade discrepancy');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};break;
|
||||||
|
case Hero::LV_3:{
|
||||||
|
if ($heroDb['hero_lv'] < $costHeroDb['hero_lv'] && $costHeroDb['hero_lv'] <= Hero::LV_2){
|
||||||
|
$this->_rspErr(100, 'Grade discrepancy');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$heroMeta = mt\Hero::get($heroDb['hero_id']);
|
||||||
|
if (!$heroMeta) {
|
||||||
|
$this->_rspErr(100, 'server internal error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$nextLevelMeta = mt\HeroLevelAttr::getByLevel($heroDb['hero_lv'] + 1);
|
||||||
|
if (!$nextLevelMeta) {
|
||||||
|
$this->_rspErr(5, "It's already the highest level");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//升级所需消耗
|
||||||
|
$meta = mt\HeroLevel::get($heroDb['hero_lv'] + 1);
|
||||||
|
$costItems = array(
|
||||||
|
array(
|
||||||
|
'item_id' => V_ITEM_GOLD,
|
||||||
|
'item_num' => $meta['gold']
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'item_id' => V_ITEM_DIAMOND,
|
||||||
|
'item_num' => $meta['diamond']
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$lackItem = null;
|
||||||
|
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
|
||||||
|
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->_decItems($costItems);
|
||||||
|
|
||||||
|
$attrs = mt\HeroLevelAttr::addRandAttrNew($heroDb,1);
|
||||||
|
Hero::update($heroUniId, array(
|
||||||
|
'hero_lv' => $heroDb['hero_lv'] + 1,
|
||||||
|
'rand_attr' => json_encode($attrs),
|
||||||
|
'state' => Hero::GETED_STATE,
|
||||||
|
));
|
||||||
|
if ($costHeroDb){
|
||||||
|
Hero::update($costHeroUniId, array(
|
||||||
|
'account_id' => myself()->_getAccountId() . '!!!',
|
||||||
|
));
|
||||||
|
}
|
||||||
|
if ($heroDb['hero_lv'] + 1 > myself()->_getV(TN_HERO_MAX_LEVEL, 0)) {
|
||||||
|
myself()->_setV(TN_HERO_MAX_LEVEL, 0, $heroDb['hero_lv'] + 1);
|
||||||
|
}
|
||||||
|
$newHero = Hero::toDto(Hero::find($heroUniId));
|
||||||
|
$propertyChgService = new services\PropertyChgService();
|
||||||
|
$propertyChgService->addHeroChg();
|
||||||
|
$propertyChgService->addUserChg();
|
||||||
|
$this->_rspData(array(
|
||||||
|
'property_chg' => $propertyChgService->toDto(),
|
||||||
|
'old_hero' => $oldHero,
|
||||||
|
'new_hero' => $newHero,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function presetHero(){
|
||||||
|
$heroId = getReqVal('hero_uid',0);
|
||||||
|
$heroDb = Hero::find($heroId);
|
||||||
|
if (! $heroDb){
|
||||||
|
$this->_rspErr(1, "You don't have the hero yet");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$row = SqlHelper::ormSelectOne(
|
||||||
|
$this->_getSelfMysql(),
|
||||||
|
't_hero_preset',
|
||||||
|
array(
|
||||||
|
'account_id' => $this->_getAccountId(),
|
||||||
|
'hero_uid' => $heroId,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if ($row){
|
||||||
|
$data = array(
|
||||||
|
'skill_id' => $row['skill_id'],
|
||||||
|
'weapon_uid1' => $row['weapon_uid1'],
|
||||||
|
'weapon_uid2' => $row['weapon_uid2'],
|
||||||
|
'chip_page' => $row['chip_page'],
|
||||||
|
);
|
||||||
|
}else{
|
||||||
|
$data = array(
|
||||||
|
'skill_id' => \mt\Skill::DEFAULT_SKILL,
|
||||||
|
'weapon_uid1' => 0,
|
||||||
|
'weapon_uid2' => 0,
|
||||||
|
'chip_page' => 1,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$this->_rspData(array(
|
||||||
|
'data' => $data,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function applyHero(){
|
||||||
|
$heroId = getReqVal('hero_uid',0);
|
||||||
|
$chipPageId = getReqVal('chip_page',0);
|
||||||
|
$weaponUid1 = getReqVal('weapon_uid1',0);
|
||||||
|
$weaponUid2 = getReqVal('weapon_uid2',0);
|
||||||
|
$skillId = getReqVal('skill_id',0);
|
||||||
|
$heroDb = Hero::find($heroId);
|
||||||
|
if (! $heroDb){
|
||||||
|
$this->_rspErr(1, "You don't have the hero yet");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$chipPageDb = ChipPage::find($chipPageId);
|
||||||
|
if (! $chipPageDb){
|
||||||
|
$this->_rspErr(1, "You don't have the chip page");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($weaponUid1){
|
||||||
|
$gunDb1 = Gun::find($weaponUid1);
|
||||||
|
if (!$gunDb1){
|
||||||
|
$this->_rspErr(1, "You don't have the gun1 yet");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($weaponUid2){
|
||||||
|
$gunDb2 = Gun::find($weaponUid2);
|
||||||
|
if (!$gunDb2){
|
||||||
|
$this->_rspErr(1, "You don't have the gun2 yet");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$skillMeta = \mt\Skill::get($skillId);
|
||||||
|
if (! $skillMeta){
|
||||||
|
$this->_rspErr(1,'skill_id parameter error');
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
SqlHelper::upsert
|
||||||
|
($this->_getSelfMysql(),
|
||||||
|
't_hero_preset',
|
||||||
|
array(
|
||||||
|
'account_id' => $this->_getAccountId(),
|
||||||
|
'hero_uid' => $heroId,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'skill_id' => $skillId,
|
||||||
|
'weapon_uid1' => $weaponUid1,
|
||||||
|
'weapon_uid2' => $weaponUid2,
|
||||||
|
'chip_page' => $chipPageId,
|
||||||
|
'modifytime' => $this->_getNowTime(),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'account_id' => $this->_getAccountId(),
|
||||||
|
'hero_uid' => $heroId,
|
||||||
|
'skill_id' => $skillId,
|
||||||
|
'weapon_uid1' => $weaponUid1,
|
||||||
|
'weapon_uid2' => $weaponUid2,
|
||||||
|
'chip_page' => $chipPageId,
|
||||||
|
'createtime' => $this->_getNowTime(),
|
||||||
|
'modifytime' => $this->_getNowTime(),
|
||||||
|
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$this->_rspOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function upgradeSkillCommon(){
|
public function upgradeSkillCommon(){
|
||||||
$heroUniId = getReqVal('hero_uniid', 0);
|
$heroUniId = getReqVal('hero_uniid', 0);
|
||||||
$skillIndex = getReqVal('skill_index', 0);
|
$skillIndex = getReqVal('skill_index', 0);
|
||||||
@ -157,42 +450,6 @@ class HeroController extends BaseAuthedController {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function skinList()
|
|
||||||
{
|
|
||||||
$skinList = array();
|
|
||||||
SqlHelper::ormSelect(
|
|
||||||
$this->_getSelfMysql(),
|
|
||||||
't_hero_skin',
|
|
||||||
array(
|
|
||||||
'account_id' => $this->_getAccountId()
|
|
||||||
),
|
|
||||||
function ($row) use(&$skinList) {
|
|
||||||
array_push($skinList, HeroSkin::toDto($row));
|
|
||||||
}
|
|
||||||
);
|
|
||||||
$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;
|
|
||||||
}
|
|
||||||
if (!$heroSkinDb) {
|
|
||||||
$this->_rspErr(2, "You don't have the skin yet");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Hero::takeonSkin($heroUniId, $skinId);
|
|
||||||
$this->_rspOk();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getUpgradeLevelList()
|
public function getUpgradeLevelList()
|
||||||
{
|
{
|
||||||
$infos = array();
|
$infos = array();
|
||||||
@ -625,51 +882,6 @@ class HeroController extends BaseAuthedController {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function upgradeLevelPreview(){
|
|
||||||
$heroUniId = getReqVal('hero_uniid', 0);
|
|
||||||
$heroDb = Hero::find($heroUniId);
|
|
||||||
if (!$heroDb) {
|
|
||||||
$this->_rspErr(1, 'hero does not exist');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$heroMeta = mt\Hero::get($heroDb['hero_id']);
|
|
||||||
if (!$heroMeta) {
|
|
||||||
$this->_rspErr(100, 'server internal error');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$nextLevelMeta = mt\HeroLevelAttr::getByLevel($heroDb['hero_lv'] + 1);
|
|
||||||
if (!$nextLevelMeta) {
|
|
||||||
$this->_rspErr(5, "It's already the highest level");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$meta = mt\HeroLevel::get($heroDb['hero_lv'] + 1);
|
|
||||||
$costItems = array(
|
|
||||||
array(
|
|
||||||
'item_id' => V_ITEM_GOLD,
|
|
||||||
'item_num' => $meta['gold']
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'item_id' => V_ITEM_DIAMOND,
|
|
||||||
'item_num' => $meta['diamond']
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$newHeroDb = $heroDb;
|
|
||||||
$newHeroDb['hero_lv'] += 1;
|
|
||||||
$attrs = mt\HeroLevelAttr::addRandAttrNew($heroDb,0);
|
|
||||||
$newHeroDb['rand_attr'] = json_encode($attrs);
|
|
||||||
|
|
||||||
$heroDto = Hero::toDto($heroDb);
|
|
||||||
$newHeroDto = Hero::toDto($newHeroDb);
|
|
||||||
$this->_rspData(array(
|
|
||||||
|
|
||||||
'old_hero' => $heroDto,
|
|
||||||
'new_hero' => $newHeroDto,
|
|
||||||
'cost' => $costItems
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function upgradeQualityOld()
|
public function upgradeQualityOld()
|
||||||
{
|
{
|
||||||
$costHeroUniId = getReqVal('cost_hero_uniid', 0);
|
$costHeroUniId = getReqVal('cost_hero_uniid', 0);
|
||||||
@ -973,189 +1185,4 @@ class HeroController extends BaseAuthedController {
|
|||||||
'old_hero'=>Hero::toDto($oldHeroDb)
|
'old_hero'=>Hero::toDto($oldHeroDb)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function upgradeLv()
|
|
||||||
{
|
|
||||||
$heroUniId = getReqVal('hero_uniid', 0);
|
|
||||||
$costHeroUniId = getReqVal('cost_hero_uniid', 0);
|
|
||||||
$heroDb = Hero::find($heroUniId);
|
|
||||||
$oldHero = Hero::toDto($heroDb);
|
|
||||||
$costHeroDb = Hero::findEx($costHeroUniId);
|
|
||||||
if (!$heroDb) {
|
|
||||||
$this->_rspErr(100, 'param error or null');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ($heroDb['hero_lv'] == Hero::LV_1 ||
|
|
||||||
$heroDb['hero_lv'] == Hero::LV_2 ||
|
|
||||||
$heroDb['hero_lv'] == Hero::LV_3 ){
|
|
||||||
if (! $costHeroDb){
|
|
||||||
$this->_rspErr(100, 'material param error or null');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ($costHeroDb['token_id']){
|
|
||||||
$this->_rspErr(100, 'NFT cannot be a material');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ($costHeroDb['state'] == Hero::FREE_STATE){
|
|
||||||
$this->_rspErr(100, 'Unable to use free hero');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ($heroDb['hero_lv'] != $costHeroDb['hero_lv']){
|
|
||||||
$this->_rspErr(100, 'You need the same level to do it');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$heroMeta = mt\Hero::get($heroDb['hero_id']);
|
|
||||||
if (!$heroMeta) {
|
|
||||||
$this->_rspErr(100, 'server internal error');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$nextLevelMeta = mt\HeroLevelAttr::getByLevel($heroDb['hero_lv'] + 1);
|
|
||||||
if (!$nextLevelMeta) {
|
|
||||||
$this->_rspErr(5, "It's already the highest level");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//升级所需消耗
|
|
||||||
$meta = mt\HeroLevel::get($heroDb['hero_lv'] + 1);
|
|
||||||
$costItems = array(
|
|
||||||
array(
|
|
||||||
'item_id' => V_ITEM_GOLD,
|
|
||||||
'item_num' => $meta['gold']
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'item_id' => V_ITEM_DIAMOND,
|
|
||||||
'item_num' => $meta['diamond']
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$lackItem = null;
|
|
||||||
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
|
|
||||||
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$this->_decItems($costItems);
|
|
||||||
|
|
||||||
$attrs = mt\HeroLevelAttr::addRandAttrNew($heroDb,1);
|
|
||||||
Hero::update($heroUniId, array(
|
|
||||||
'hero_lv' => $heroDb['hero_lv'] + 1,
|
|
||||||
'rand_attr' => json_encode($attrs),
|
|
||||||
'state' => Hero::GETED_STATE,
|
|
||||||
));
|
|
||||||
if ($costHeroDb){
|
|
||||||
Hero::update($costHeroUniId, array(
|
|
||||||
'account_id' => myself()->_getAccountId() . '!!!',
|
|
||||||
));
|
|
||||||
}
|
|
||||||
if ($heroDb['hero_lv'] + 1 > myself()->_getV(TN_HERO_MAX_LEVEL, 0)) {
|
|
||||||
myself()->_setV(TN_HERO_MAX_LEVEL, 0, $heroDb['hero_lv'] + 1);
|
|
||||||
}
|
|
||||||
$newHero = Hero::toDto(Hero::find($heroUniId));
|
|
||||||
$propertyChgService = new services\PropertyChgService();
|
|
||||||
$propertyChgService->addHeroChg();
|
|
||||||
$propertyChgService->addUserChg();
|
|
||||||
$this->_rspData(array(
|
|
||||||
'property_chg' => $propertyChgService->toDto(),
|
|
||||||
'old_hero' => $oldHero,
|
|
||||||
'new_hero' => $newHero,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function presetHero(){
|
|
||||||
$heroId = getReqVal('hero_uid',0);
|
|
||||||
$heroDb = Hero::find($heroId);
|
|
||||||
if (! $heroDb){
|
|
||||||
$this->_rspErr(1, "You don't have the hero yet");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$row = SqlHelper::ormSelectOne(
|
|
||||||
$this->_getSelfMysql(),
|
|
||||||
't_hero_preset',
|
|
||||||
array(
|
|
||||||
'account_id' => $this->_getAccountId(),
|
|
||||||
'hero_uid' => $heroId,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
if ($row){
|
|
||||||
$data = array(
|
|
||||||
'skill_id' => $row['skill_id'],
|
|
||||||
'weapon_uid1' => $row['weapon_uid1'],
|
|
||||||
'weapon_uid2' => $row['weapon_uid2'],
|
|
||||||
'chip_page' => $row['chip_page'],
|
|
||||||
);
|
|
||||||
}else{
|
|
||||||
$data = array(
|
|
||||||
'skill_id' => \mt\Skill::DEFAULT_SKILL,
|
|
||||||
'weapon_uid1' => 0,
|
|
||||||
'weapon_uid2' => 0,
|
|
||||||
'chip_page' => 1,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$this->_rspData(array(
|
|
||||||
'data' => $data,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function applyHero(){
|
|
||||||
$heroId = getReqVal('hero_uid',0);
|
|
||||||
$chipPageId = getReqVal('chip_page',0);
|
|
||||||
$weaponUid1 = getReqVal('weapon_uid1',0);
|
|
||||||
$weaponUid2 = getReqVal('weapon_uid2',0);
|
|
||||||
$skillId = getReqVal('skill_id',0);
|
|
||||||
$heroDb = Hero::find($heroId);
|
|
||||||
if (! $heroDb){
|
|
||||||
$this->_rspErr(1, "You don't have the hero yet");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$chipPageDb = ChipPage::find($chipPageId);
|
|
||||||
if (! $chipPageDb){
|
|
||||||
$this->_rspErr(1, "You don't have the chip page");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ($weaponUid1){
|
|
||||||
$gunDb1 = Gun::find($weaponUid1);
|
|
||||||
if (!$gunDb1){
|
|
||||||
$this->_rspErr(1, "You don't have the gun1 yet");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($weaponUid2){
|
|
||||||
$gunDb2 = Gun::find($weaponUid2);
|
|
||||||
if (!$gunDb2){
|
|
||||||
$this->_rspErr(1, "You don't have the gun2 yet");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$skillMeta = \mt\Skill::get($skillId);
|
|
||||||
if (! $skillMeta){
|
|
||||||
$this->_rspErr(1,'skill_id parameter error');
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
SqlHelper::upsert
|
|
||||||
($this->_getSelfMysql(),
|
|
||||||
't_hero_preset',
|
|
||||||
array(
|
|
||||||
'account_id' => $this->_getAccountId(),
|
|
||||||
'hero_uid' => $heroId,
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'skill_id' => $skillId,
|
|
||||||
'weapon_uid1' => $weaponUid1,
|
|
||||||
'weapon_uid2' => $weaponUid2,
|
|
||||||
'chip_page' => $chipPageId,
|
|
||||||
'modifytime' => $this->_getNowTime(),
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'account_id' => $this->_getAccountId(),
|
|
||||||
'hero_uid' => $heroId,
|
|
||||||
'skill_id' => $skillId,
|
|
||||||
'weapon_uid1' => $weaponUid1,
|
|
||||||
'weapon_uid2' => $weaponUid2,
|
|
||||||
'chip_page' => $chipPageId,
|
|
||||||
'createtime' => $this->_getNowTime(),
|
|
||||||
'modifytime' => $this->_getNowTime(),
|
|
||||||
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$this->_rspOk();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ namespace models;
|
|||||||
require_once('mt/Hero.php');
|
require_once('mt/Hero.php');
|
||||||
require_once('mt/HeroLevelAttr.php');
|
require_once('mt/HeroLevelAttr.php');
|
||||||
require_once('mt/HeroQuality.php');
|
require_once('mt/HeroQuality.php');
|
||||||
|
require_once('mt/HeroLevel.php');
|
||||||
require_once('mt/AttrHelper.php');
|
require_once('mt/AttrHelper.php');
|
||||||
require_once('mt/Item.php');
|
require_once('mt/Item.php');
|
||||||
require_once('mt/SkillCommon.php');
|
require_once('mt/SkillCommon.php');
|
||||||
@ -231,24 +232,24 @@ class Hero extends BaseModel {
|
|||||||
$unlockTime = $row['unlock_time'];
|
$unlockTime = $row['unlock_time'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$qualityMeta = mt\HeroQuality::getByQuality($row['quality']);
|
$levelMeta = mt\HeroLevel::getByLevel($row['hero_lv']);
|
||||||
$todayGetGold = $row['today_get_gold'];
|
$todayGetGold = $row['today_get_gold'];
|
||||||
$lastGetGoldTime = $row['last_get_gold_time'];
|
$lastGetGoldTime = $row['last_get_gold_time'];
|
||||||
if (myself()->_getDaySeconds($lastGetGoldTime) <
|
if (myself()->_getDaySeconds($lastGetGoldTime) <
|
||||||
myself()->_getNowDaySeconds()) {
|
myself()->_getNowDaySeconds()) {
|
||||||
$todayGetGold = 0;
|
$todayGetGold = 0;
|
||||||
}
|
}
|
||||||
$todayPveGetCeg = $row['today_pve_get_ceg'];
|
// $todayPveGetCeg = $row['today_pve_get_ceg'];
|
||||||
$lastPveGetCegTime = $row['last_pve_get_ceg_time'];
|
// $lastPveGetCegTime = $row['last_pve_get_ceg_time'];
|
||||||
if (myself()->_getDaySeconds($lastPveGetCegTime) <
|
// if (myself()->_getDaySeconds($lastPveGetCegTime) <
|
||||||
myself()->_getNowDaySeconds()) {
|
// myself()->_getNowDaySeconds()) {
|
||||||
$todayPveGetCeg = 0;
|
// $todayPveGetCeg = 0;
|
||||||
}
|
// }
|
||||||
$todayMissionGetCeg = $row['today_mission_get_ceg'];
|
// $todayMissionGetCeg = $row['today_mission_get_ceg'];
|
||||||
$lastMissionGetCegTime = $row['last_mission_get_ceg_time'];
|
// $lastMissionGetCegTime = $row['last_mission_get_ceg_time'];
|
||||||
if (myself()->_getDaySeconds($lastMissionGetCegTime) < myself()->_getNowDaySeconds()) {
|
// if (myself()->_getDaySeconds($lastMissionGetCegTime) < myself()->_getNowDaySeconds()) {
|
||||||
$todayMissionGetCeg = 0;
|
// $todayMissionGetCeg = 0;
|
||||||
}
|
// }
|
||||||
$baseAttr=[];
|
$baseAttr=[];
|
||||||
$attrPro=[];
|
$attrPro=[];
|
||||||
$heroMeta = mt\Hero::get($row['hero_id']);
|
$heroMeta = mt\Hero::get($row['hero_id']);
|
||||||
@ -285,12 +286,13 @@ class Hero extends BaseModel {
|
|||||||
'unlock_time' => $unlockTime,
|
'unlock_time' => $unlockTime,
|
||||||
'unlock_lefttime' => max(0,
|
'unlock_lefttime' => max(0,
|
||||||
$unlockTime - myself()->_getNowTime()),
|
$unlockTime - myself()->_getNowTime()),
|
||||||
'current_pvp_get_ceg' => $todayGetGold / 100,
|
'current_get_gold' => $todayGetGold / 100,
|
||||||
'last_pvp_get_ceg_time' => $lastGetGoldTime,
|
'last_get_gold_time' => $lastGetGoldTime,
|
||||||
'current_pve_get_ceg' => $todayPveGetCeg / 100,
|
'gold_uplimit' => $levelMeta['gold_limit'],
|
||||||
'last_pve_get_ceg_time' => $lastPveGetCegTime,
|
// 'current_pve_get_ceg' => $todayPveGetCeg / 100,
|
||||||
'current_mission_get_ceg' => $todayMissionGetCeg / 100,
|
// 'last_pve_get_ceg_time' => $lastPveGetCegTime,
|
||||||
'last_mission_get_ceg_time' => $lastMissionGetCegTime,
|
// 'current_mission_get_ceg' => $todayMissionGetCeg / 100,
|
||||||
|
// 'last_mission_get_ceg_time' => $lastMissionGetCegTime,
|
||||||
'unlock_trade_time' => $row['unlock_trade_time'],
|
'unlock_trade_time' => $row['unlock_trade_time'],
|
||||||
'advanced_count' => $row['advanced_count'],
|
'advanced_count' => $row['advanced_count'],
|
||||||
// 'lucky' => $heroLucky,
|
// 'lucky' => $heroLucky,
|
||||||
@ -342,6 +344,14 @@ class Hero extends BaseModel {
|
|||||||
|
|
||||||
public static function internalAddHero($conn, $heroMeta, $accountId, $tokenId,$state)
|
public static function internalAddHero($conn, $heroMeta, $accountId, $tokenId,$state)
|
||||||
{
|
{
|
||||||
|
$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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
$realHeroMeta = mt\Hero::get($heroMeta['id']);
|
$realHeroMeta = mt\Hero::get($heroMeta['id']);
|
||||||
$randAttr = array();
|
$randAttr = array();
|
||||||
$fieldsKv = array(
|
$fieldsKv = array(
|
||||||
|
@ -25,13 +25,69 @@ class HeroSkin extends BaseModel {
|
|||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function toDto($row)
|
public static function findBx($heroId)
|
||||||
{
|
{
|
||||||
return array(
|
$row = SqlHelper::ormSelectOne(
|
||||||
'skin_id' => $row['skin_id'],
|
myself()->_getSelfMysql(),
|
||||||
'skin_state' => $row['skin_state'],
|
't_hero_skin',
|
||||||
'try_expire_at' => $row['try_expire_at'],
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
'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::update(
|
||||||
|
myself()->_getSelfMysql(),
|
||||||
|
't_hero_skin',
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
'skin_id' => $skinId
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'hero_id'=>$heroId
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function getSkinList($cb){
|
||||||
|
SqlHelper::ormSelect(
|
||||||
|
myself()->_getSelfMysql(),
|
||||||
|
't_hero_skin',
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId()
|
||||||
|
),
|
||||||
|
function ($row) use($cb) {
|
||||||
|
$cb($row);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function toDto($meta)
|
||||||
|
{
|
||||||
|
$row = self::find($meta['id']);
|
||||||
|
$array = array(
|
||||||
|
'skin_id'=>$meta['id'],
|
||||||
|
'is_have' => $row?1:0,
|
||||||
|
'use_state' => $row['hero_id']?1:0,
|
||||||
|
);
|
||||||
|
return $array;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function addSkin($itemMeta)
|
public static function addSkin($itemMeta)
|
||||||
@ -43,10 +99,7 @@ class HeroSkin extends BaseModel {
|
|||||||
'account_id' => myself()->_getAccountId(),
|
'account_id' => myself()->_getAccountId(),
|
||||||
'skin_id' => $itemMeta['id']
|
'skin_id' => $itemMeta['id']
|
||||||
),
|
),
|
||||||
array(
|
array(),
|
||||||
'skin_state' => 3,
|
|
||||||
'modifytime' => myself()->_getNowTime()
|
|
||||||
),
|
|
||||||
array(
|
array(
|
||||||
'account_id' => myself()->_getAccountId(),
|
'account_id' => myself()->_getAccountId(),
|
||||||
'skin_id' => $itemMeta['id'],
|
'skin_id' => $itemMeta['id'],
|
||||||
@ -54,6 +107,7 @@ class HeroSkin extends BaseModel {
|
|||||||
'get_from' => 0,
|
'get_from' => 0,
|
||||||
'consume_num' => 0,
|
'consume_num' => 0,
|
||||||
'try_expire_at' => 0,
|
'try_expire_at' => 0,
|
||||||
|
'hero_id' => $itemMeta['isdefaultskin']?$itemMeta['playerid']:0,
|
||||||
'createtime' => myself()->_getNowTime(),
|
'createtime' => myself()->_getNowTime(),
|
||||||
'modifytime' => myself()->_getNowTime()
|
'modifytime' => myself()->_getNowTime()
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user