英雄预设

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(),
['old_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(), '英雄-老'],
['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(),
['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已解锁'],
['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 */;
--
-- 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 character_set_client = utf8 */;
CREATE TABLE `t_hero_skill` (
CREATE TABLE `t_hero_preset` (
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
`hero_uid` int(11) NOT NULL DEFAULT '0' COMMENT 'hero uniid',
`skill_id` int(11) NOT NULL DEFAULT '0' COMMENT '技能 item_id',
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
PRIMARY KEY (`idx`),
UNIQUE KEY `account_hero_skill` (`account_id`, `hero_uid`, `skill_id`)
`hero_uid` int(11) NOT NULL DEFAULT 0 COMMENT 'hero uniid',
`skill_id` int(11) NOT NULL DEFAULT 0 COMMENT '技能 item_id',
`weapon_uid1` int(11) NOT NULL DEFAULT 0 COMMENT 'gun uniid1',
`weapon_uid2` int(11) NOT NULL DEFAULT 0 COMMENT 'gun uniid2',
`chip_page` int(11) NOT NULL DEFAULT 0 COMMENT '芯片页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;
/*!40101 SET character_set_client = @saved_cs_client */;

View File

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

View File

@ -14,10 +14,11 @@ require_once('mt/Skill.php');
require_once('models/Hero.php');
require_once('models/Bag.php');
require_once('models/HeroSkin.php');
require_once('models/Chip.php');
require_once('models/Nft.php');
require_once('models/NftUpReceive.php');
require_once('models/Transaction.php');
require_once('models/ChipPage.php');
require_once('models/Gun.php');
require_once('services/AwardService.php');
require_once('services/PropertyChgService.php');
@ -30,7 +31,8 @@ use phpcommon\SqlHelper;
use models\Hero;
use models\Bag;
use models\HeroSkin;
use models\Chip;
use models\ChipPage;
use models\Gun;
use models\Nft;
use models\NftUpReceive;
use models\Transaction;
@ -640,19 +642,31 @@ class HeroController extends BaseAuthedController {
$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);
$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);
$newHeroDto = Hero::toDto($newHeroDb);
$this->_rspData(array(
'old_hero' => $heroDto,
'new_hero' => $newHeroDto,
'cost' => $cost
'cost' => $costItems
));
}
@ -1003,20 +1017,29 @@ class HeroController extends BaseAuthedController {
}
//升级所需消耗
// $costItems = array();
// $lackItem = null;
// if (!$this->_hasEnoughItems($costItems, $lackItem)) {
// $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
// return;
// }
// $this->_decItems($costItems);
$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,
'skill_points' => $heroDb['skill_points']+$nextLevelMeta['skill_point']
));
if ($costHeroDb){
Hero::update($costHeroUniId, array(
@ -1036,4 +1059,103 @@ class HeroController extends BaseAuthedController {
'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 {
const DEFAULT_SKILL = 10101;
public static function get($id)
{
return getXVal(self::getMetaList(), $id);