英雄预设

This commit is contained in:
hujiabin 2023-03-01 15:34:47 +08:00
parent 8fb2aa81a4
commit 7f55d4e552
8 changed files with 417 additions and 260 deletions

View File

@ -87,7 +87,7 @@ class Gun(object):
_common.RspHead(), _common.RspHead(),
['old_gun', _common.Gun(), '枪械-老'], ['old_gun', _common.Gun(), '枪械-老'],
['new_gun', _common.Gun(), '枪械-新'], ['new_gun', _common.Gun(), '枪械-新'],
['cost', _common.Cost(), '所需费用'], ['!cost', [_common.AwardItem()], '所需费用'],
] ]
}, },
{ {

View File

@ -243,6 +243,35 @@ class Hero(object):
['old_hero', _common.Hero(), '英雄-老'], ['old_hero', _common.Hero(), '英雄-老'],
['new_hero', _common.Hero(), '英雄-新'], ['new_hero', _common.Hero(), '英雄-新'],
] ]
},{
'name': 'presetHero',
'desc': '英雄预设',
'group': 'Hero',
'url': 'webapp/index.php?c=Hero&a=presetHero',
'params': [
_common.ReqHead(),
['hero_uid', 0, '英雄唯一id'],
],
'response': [
_common.RspHead(),
['data', _common.HeroPreset(), '预设信息']
]
},{
'name': 'applyHero',
'desc': '应用',
'group': 'Hero',
'url': 'webapp/index.php?c=Hero&a=applyHero',
'params': [
_common.ReqHead(),
['hero_uid', 0, '英雄唯一id'],
['skill_id', 0, '技能itemId'],
['weapon_uid1', 0, '武器1唯一id'],
['weapon_uid2', 0, '武器2唯一id'],
['chip_page', 0, '芯片页id'],
],
'response': [
_common.RspHead(),
]
}, },
] ]

View File

@ -18,31 +18,5 @@ class HeroSkill(object):
_common.RspHead(), _common.RspHead(),
['data', [], '技能itemId'] ['data', [], '技能itemId']
] ]
},{ }
'name': 'presetHero',
'desc': '技能预设',
'group': 'HeroSkill',
'url': 'webapp/index.php?c=HeroSkill&a=presetHero',
'params': [
_common.ReqHead(),
['skill_id', '0', '技能id'],
],
'response': [
_common.RspHead(),
['!data', [['item_id',0,'英雄itemId'],['state',0,'1:设置 0:未设置']], '预设英雄信息']
]
},{
'name': 'applyHero',
'desc': '技能应用',
'group': 'HeroSkill',
'url': 'webapp/index.php?c=HeroSkill&a=applyHero',
'params': [
_common.ReqHead(),
['skill_id', '0', '技能itemId'],
['hero_ids', '0', '英雄itemId 用|分割 例如 xxx|xxx'],
],
'response': [
_common.RspHead(),
]
},
] ]

View File

@ -1017,3 +1017,13 @@ class ChipPageSlot(object):
['state', 0, '0未解锁 1已解锁'], ['state', 0, '0未解锁 1已解锁'],
['chip_id', '', '芯片idx'], ['chip_id', '', '芯片idx'],
] ]
class HeroPreset(object):
def __init__(self):
self.fields = [
['skill_id', 0, '技能item id'],
['weapon_uid1', 0, '武器1唯一id'],
['weapon_uid2', 0, '武器2唯一id'],
['chip_page', 0, '芯片页id'],
]

View File

@ -964,20 +964,22 @@ CREATE TABLE `t_chip_page` (
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
-- --
-- Table structure for table `t_hero_skill` -- Table structure for table `t_hero_preset`
-- --
DROP TABLE IF EXISTS `t_hero_skill`; DROP TABLE IF EXISTS `t_hero_preset`;
/*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */; /*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t_hero_skill` ( CREATE TABLE `t_hero_preset` (
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id', `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
`hero_uid` int(11) NOT NULL DEFAULT '0' COMMENT 'hero uniid', `hero_uid` int(11) NOT NULL DEFAULT 0 COMMENT 'hero uniid',
`skill_id` int(11) NOT NULL DEFAULT '0' COMMENT '技能 item_id', `skill_id` int(11) NOT NULL DEFAULT 0 COMMENT '技能 item_id',
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `weapon_uid1` int(11) NOT NULL DEFAULT 0 COMMENT 'gun uniid1',
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', `weapon_uid2` int(11) NOT NULL DEFAULT 0 COMMENT 'gun uniid2',
PRIMARY KEY (`idx`), `chip_page` int(11) NOT NULL DEFAULT 0 COMMENT '芯片页id',
UNIQUE KEY `account_hero_skill` (`account_id`, `hero_uid`, `skill_id`) `createtime` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
`modifytime` int(11) NOT NULL DEFAULT 0 COMMENT '修改时间',
PRIMARY KEY (`idx`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;

View File

@ -262,19 +262,29 @@ class GunController extends BaseAuthedController {
return; return;
} }
$costItems = array(
array(
'item_id' => V_ITEM_GOLD,
'item_num' => $nextLevelMeta['gold']
),
array(
'item_id' => V_ITEM_DIAMOND,
'item_num' => $nextLevelMeta['diamond']
),
);
$newGunDb = $gunDb; $newGunDb = $gunDb;
$newGunDb['gun_lv'] += 1; $newGunDb['gun_lv'] += 1;
$attrs = mt\GunLevel::addRandAttrNew($gunDb,0); $attrs = mt\GunLevel::addRandAttrNew($gunDb,0);
$newGunDb['rand_attr'] = json_encode($attrs); $newGunDb['rand_attr'] = json_encode($attrs);
$cost['CEG'] = \services\FormulaService::Weapon_Upgrade_CEG_Expend( $newGunDb['gun_lv']);
$cost['CEC'] = \services\FormulaService::Weapon_Upgrade_CEC_Expend( $newGunDb['gun_lv']);
$gunDto = Gun::toDto($gunDb); $gunDto = Gun::toDto($gunDb);
$newGunDto = Gun::toDto($newGunDb); $newGunDto = Gun::toDto($newGunDb);
$this->_rspData(array( $this->_rspData(array(
'old_gun' => $gunDto, 'old_gun' => $gunDto,
'new_gun' => $newGunDto, 'new_gun' => $newGunDto,
'cost' => $cost 'cost' => $costItems
)); ));
} }
@ -858,19 +868,28 @@ class GunController extends BaseAuthedController {
} }
//升级所需消耗 //升级所需消耗
// $costItems = array(); $costItems = array(
// $lackItem = null; array(
// if (!$this->_hasEnoughItems($costItems, $lackItem)) { 'item_id' => V_ITEM_GOLD,
// $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); 'item_num' => $nextLevelMeta['gold']
// return; ),
// } array(
// $this->_decItems($costItems); 'item_id' => V_ITEM_DIAMOND,
'item_num' => $nextLevelMeta['diamond']
),
);
$lackItem = null;
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
return;
}
$this->_decItems($costItems);
$attrs = mt\GunLevel::addRandAttrNew($gunDb,1); $attrs = mt\GunLevel::addRandAttrNew($gunDb,1);
Gun::update($gunUniId, Gun::update($gunUniId,
array( array(
'gun_lv' => $gunDb['gun_lv'] + 1, 'gun_lv' => $gunDb['gun_lv'] + 1,
'state' => 1, 'state' => Gun::GETED_STATE,
'rand_attr' => json_encode($attrs), 'rand_attr' => json_encode($attrs),
)); ));
Gun::update($costGunUniId, Gun::update($costGunUniId,

View File

@ -14,10 +14,11 @@ require_once('mt/Skill.php');
require_once('models/Hero.php'); require_once('models/Hero.php');
require_once('models/Bag.php'); require_once('models/Bag.php');
require_once('models/HeroSkin.php'); require_once('models/HeroSkin.php');
require_once('models/Chip.php');
require_once('models/Nft.php'); require_once('models/Nft.php');
require_once('models/NftUpReceive.php'); require_once('models/NftUpReceive.php');
require_once('models/Transaction.php'); require_once('models/Transaction.php');
require_once('models/ChipPage.php');
require_once('models/Gun.php');
require_once('services/AwardService.php'); require_once('services/AwardService.php');
require_once('services/PropertyChgService.php'); require_once('services/PropertyChgService.php');
@ -30,7 +31,8 @@ use phpcommon\SqlHelper;
use models\Hero; use models\Hero;
use models\Bag; use models\Bag;
use models\HeroSkin; use models\HeroSkin;
use models\Chip; use models\ChipPage;
use models\Gun;
use models\Nft; use models\Nft;
use models\NftUpReceive; use models\NftUpReceive;
use models\Transaction; use models\Transaction;
@ -640,19 +642,31 @@ class HeroController extends BaseAuthedController {
$this->_rspErr(5, "It's already the highest level"); $this->_rspErr(5, "It's already the highest level");
return; 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 = $heroDb;
$newHeroDb['hero_lv'] += 1; $newHeroDb['hero_lv'] += 1;
$attrs = mt\HeroLevelAttr::addRandAttrNew($heroDb,0); $attrs = mt\HeroLevelAttr::addRandAttrNew($heroDb,0);
$newHeroDb['rand_attr'] = json_encode($attrs); $newHeroDb['rand_attr'] = json_encode($attrs);
$cost['CEG'] = \services\FormulaService::Hero_Upgrade_CEG_Expend($newHeroDb['hero_lv']);
$cost['CEC'] = \services\FormulaService::Hero_Upgrade_CEC_Expend($newHeroDb['hero_lv']);
$heroDto = Hero::toDto($heroDb); $heroDto = Hero::toDto($heroDb);
$newHeroDto = Hero::toDto($newHeroDb); $newHeroDto = Hero::toDto($newHeroDb);
$this->_rspData(array( $this->_rspData(array(
'old_hero' => $heroDto, 'old_hero' => $heroDto,
'new_hero' => $newHeroDto, 'new_hero' => $newHeroDto,
'cost' => $cost 'cost' => $costItems
)); ));
} }
@ -1003,20 +1017,29 @@ class HeroController extends BaseAuthedController {
} }
//升级所需消耗 //升级所需消耗
// $costItems = array(); $meta = mt\HeroLevel::get($heroDb['hero_lv'] + 1);
// $lackItem = null; $costItems = array(
// if (!$this->_hasEnoughItems($costItems, $lackItem)) { array(
// $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); 'item_id' => V_ITEM_GOLD,
// return; 'item_num' => $meta['gold']
// } ),
// $this->_decItems($costItems); 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); $attrs = mt\HeroLevelAttr::addRandAttrNew($heroDb,1);
Hero::update($heroUniId, array( Hero::update($heroUniId, array(
'hero_lv' => $heroDb['hero_lv'] + 1, 'hero_lv' => $heroDb['hero_lv'] + 1,
'rand_attr' => json_encode($attrs), 'rand_attr' => json_encode($attrs),
'state' => Hero::GETED_STATE, 'state' => Hero::GETED_STATE,
'skill_points' => $heroDb['skill_points']+$nextLevelMeta['skill_point']
)); ));
if ($costHeroDb){ if ($costHeroDb){
Hero::update($costHeroUniId, array( Hero::update($costHeroUniId, array(
@ -1036,4 +1059,103 @@ class HeroController extends BaseAuthedController {
'new_hero' => $newHero, '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();
}
} }

View File

@ -6,6 +6,7 @@ use phpcommon;
class Skill { class Skill {
const DEFAULT_SKILL = 10101;
public static function get($id) public static function get($id)
{ {
return getXVal(self::getMetaList(), $id); return getXVal(self::getMetaList(), $id);