From 7928ea7c0cb8aff4793a85a9ce41d8f9b95ca70e Mon Sep 17 00:00:00 2001 From: hujiabin Date: Mon, 29 Aug 2022 17:29:11 +0800 Subject: [PATCH] skill_common --- doc/Hero.py | 18 ++++ doc/_common.py | 7 +- webapp/controller/ChipController.class.php | 22 ++-- webapp/controller/HeroController.class.php | 115 +++++++++++++++++---- webapp/models/Chip.php | 1 - webapp/models/Hero.php | 8 +- webapp/mt/SkillCommon.php | 24 +++++ 7 files changed, 160 insertions(+), 35 deletions(-) create mode 100644 webapp/mt/SkillCommon.php diff --git a/doc/Hero.py b/doc/Hero.py index 624e7806..1fa7828e 100644 --- a/doc/Hero.py +++ b/doc/Hero.py @@ -54,9 +54,11 @@ class Hero(object): 'params': [ _common.ReqHead(), ['hero_uniid', 0, '英雄唯一id'], + ['skill_idx', 0, '技能idx 0:主动技能;1:被动技能'], ], 'response': [ _common.RspHead(), + ['property_chg', _common.PropertyChg(), '属性变更'], ] }, { @@ -164,4 +166,20 @@ class Hero(object): ['!data', [_common.Hero()], '英雄信息'] ] }, + { + 'name': 'upgradeSkillCommon', + 'desc': '通用技能升级', + 'group': 'Hero', + 'url': 'webapp/index.php?c=Hero&a=upgradeSkillCommon', + 'params': [ + _common.ReqHead(), + ['hero_uniid', 0, '英雄唯一id'], + ['skill_index', 0, '通用技能下标'], + ], + 'response': [ + _common.RspHead(), + ['property_chg', _common.PropertyChg(), '属性变更'], + ] + }, + ] diff --git a/doc/_common.py b/doc/_common.py index a3c9e5a7..a4a2eed7 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -214,11 +214,12 @@ class Hero(object): ['state', 0, '0:已购买 1:体验中'], ['skin_id', 0, '英雄皮肤id'], ['quality', 0, '品阶'], - ['skill_lv1', 0, '必杀技等级'], - ['skill_lv2', 0, '躲避技能等级'], + ['skill_lv1', 0, '主动技能unique_id'], + ['skill_lv2', 0, '被动技能unique_id'], ['ceg_uplimit', 0, 'ceg今天获取上限'], ['pve_ceg_uplimit', 0, 'pve ceg今天获取上限'], - ['!attr', [Attr()], '属性'], + ['!attr', [Attr()], '英雄总属性'], + ['!rand_attr', [Attr()], '芯片属性'], ['try_count', 0, '剩余体验次数 当state=1时才有意义'], ['lock_type', 0, '0:无锁 1:升级 2:升阶 3:派遣中'], ['unlock_lefttime', 0, '解锁剩余时间(单位秒)'], diff --git a/webapp/controller/ChipController.class.php b/webapp/controller/ChipController.class.php index 96a25b69..bd4038c8 100644 --- a/webapp/controller/ChipController.class.php +++ b/webapp/controller/ChipController.class.php @@ -472,9 +472,7 @@ class ChipController extends BaseAuthedController } public function test(){ -// $a = \services\FormulaService::Do_Demount_Hero_Mint(620.2-612.738994); - -// $nft = SqlHelper::ormSelect( +// $nft_active = SqlHelper::ormSelect( // myself()->_getSelfMysql(), // 't_nft_active', // array( @@ -482,14 +480,18 @@ class ChipController extends BaseAuthedController // 'token_type' =>3, // ) // ); -// foreach ($nft as $item){ +// foreach ($nft_active as $item){ // $chip = Chip::getChipByTokenId($item['token_id']); -// $Hero_Chip_PSA_Value= \services\FormulaService::Hero_Chip_PSA_Value($chip['chip_grade']); -// $tili = $chip['strength']-$chip['strength_max']*$Hero_Chip_PSA_Value; +// if ($chip['chip_type'] == 1){ +// $Chip_PSA_Value= \services\FormulaService::Hero_Chip_PSA_Value($chip['chip_grade']); +// }else{ +// $Chip_PSA_Value= \services\FormulaService::Weapon_Chip_DA_Value($chip['chip_grade']); +// } +// $tili = $chip['strength']-$chip['strength_max']*$Chip_PSA_Value; // Chip::update($chip['token_id'],['strength'=>$tili]); // } -// print_r($a); - $this->chipDetails(); +// $this->_rspOk(); + echo $this->_getV(TN_HERO_LEVEL_UP, 0); } @@ -741,9 +743,9 @@ class ChipController extends BaseAuthedController $lucky = ltrim(\services\FormulaService::getChipLuckyValue($new_grade),'-') ; if ($new_grade>=5){ - $where = ['lucky_temporary'=>$lucky, 'chip_grade'=>$new_grade,'supper_state'=>1]; + $where = ['lucky_temporary'=>$lucky, 'chip_grade'=>$new_grade,'supper_state'=>1,'modifytime' => $this->_getNowTime()]; }else{ - $where = ['lucky_temporary'=>$lucky, 'chip_grade'=>$new_grade]; + $where = ['lucky_temporary'=>$lucky, 'chip_grade'=>$new_grade,'modifytime' => $this->_getNowTime()]; } Chip::update($chip['token_id'],$where); } diff --git a/webapp/controller/HeroController.class.php b/webapp/controller/HeroController.class.php index 08b2466c..c4f8465c 100644 --- a/webapp/controller/HeroController.class.php +++ b/webapp/controller/HeroController.class.php @@ -8,6 +8,8 @@ require_once('mt/HeroLevelAttr.php'); require_once('mt/HeroQuality.php'); require_once('mt/AttrHelper.php'); require_once('mt/Parameter.php'); +require_once('mt/SkillCommon.php'); +require_once('mt/Skill.php'); require_once('models/Hero.php'); require_once('models/Bag.php'); @@ -64,7 +66,11 @@ class HeroController extends BaseAuthedController { } } $hero['rand_attr'] = $item; - $hero_attr = emptyReplace(json_decode($hero['attr'], true), array()); + if ($hero['attr']){ + $hero_attr = emptyReplace(json_decode($hero['attr'], true), array()); + }else{ + $hero_attr = []; + } \mt\AttrHelper::mergeAttr($hero_attr,$chipAttr); $hero['attr'] = $hero_attr; $chipCore = []; @@ -92,6 +98,96 @@ class HeroController extends BaseAuthedController { )); } + public function upgradeSkillCommon(){ + $heroUniId = getReqVal('hero_uniid', 0); + $skillIndex = getReqVal('skill_index', 0); + $heroDb = Hero::find($heroUniId); + if (!$heroDb) { + $this->_rspErr(1, "You don't have the hero yet"); + return; + } + $item = explode('|',$heroDb['skill_common']); + $skill_common = \mt\SkillCommon::get($item[$skillIndex]); + if ($skill_common['skill_level'] == 10){ + $this->_rspErr(1, "Max level"); + return; + } + if($heroDb['quality'] < $skill_common['skill_limit_star']){ + $this->_rspErr(1, "Hero level is not enough"); + return; + } + if($heroDb['skill_points'] < $skill_common['skill_point_cost']){ + $this->_rspErr(1, "Not enough hero skill points"); + return; + } + + $item[$skillIndex] = $skill_common['nextlv_skill']; + $where = [ + 'skill_common'=>implode('|',$item), + 'skill_points'=>$heroDb['skill_points']-$skill_common['skill_point_cost'], + 'modifytime' => $this->_getNowTime() + ]; + Hero::update($heroUniId, $where); + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addHeroChg(); + $this->_rspData(array( + 'propery_chg' => $propertyChgService->toDto(), + )); + } + + public function upgradeSkill() + { + $heroUniId = getReqVal('hero_uniid', 0); + $skillIdx = getReqVal('skill_idx', 0); + $heroDb = Hero::find($heroUniId); + if (!$heroDb) { + $this->_rspErr(1, "You don't have the hero yet"); + return; + } + if (!in_array($skillIdx, array(0, 1))) { + $this->_rspErr(1, 'skill_idx must be 0-1'); + return; + } + if ($skillIdx){ + $skill = \mt\Skill::get($heroDb['skill_lv2']); + }else{ + $skill = \mt\Skill::get($heroDb['skill_lv1']); + } + if (!$skill){ + $this->_rspErr(1, "You don't have the skill yet"); + return; + } + if ($skill['level_skill'] == 15){ + $this->_rspErr(1, "Max level"); + return; + } + if($heroDb['quality'] < $skill['skill_limit_star']){ + $this->_rspErr(1, "Hero level is not enough"); + return; + } + if(! $heroDb['skill_points'] || $heroDb['skill_points'] < $skill['skill_point']){ + $this->_rspErr(1, "Not enough hero skill points"); + return; + } + if ($skillIdx){ + $where = [ + 'skill_lv2'=>$skill['nextlv_skill'], + 'modifytime' => $this->_getNowTime() + ]; + }else{ + $where = [ + 'skill_lv1'=>$skill['nextlv_skill'], + 'modifytime' => $this->_getNowTime() + ]; + } + Hero::update($heroUniId,$where); + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addHeroChg(); + $this->_rspData(array( + 'propery_chg' => $propertyChgService->toDto(), + )); + } + public function skinList() { $skinList = array(); @@ -128,23 +224,6 @@ class HeroController extends BaseAuthedController { $this->_rspOk(); } - public function upgradeSkill() - { - $heroUniId = getReqVal('hero_uniid', 0); - $skillIdx = getReqVal('skill_idx', 0); - $heroDb = Hero::find($heroUniId); - if (!$heroDb) { - $this->_rspErr(1, "You don't have the hero yet"); - return; - } - if (!in_array($skillIdx, array(0, 1))) { - $this->_rspErr(1, 'skill_idx must be 0-1'); - return; - } - Hero::upgradeSkill($heroUniId, $skillIdx); - $this->_rspOk(); - } - public function getUpgradeLevelList() { $infos = array(); diff --git a/webapp/models/Chip.php b/webapp/models/Chip.php index ce02e3f2..d1e91ec0 100644 --- a/webapp/models/Chip.php +++ b/webapp/models/Chip.php @@ -213,7 +213,6 @@ class Chip extends BaseModel $rand_attr = emptyReplace(json_decode($chip['rand_attr'], true), array()); array_push($rand_attr,$attr_pool); $fieldsKv = [ - 'chip_grade'=>$chip['chip_grade']+1, 'rand_attr'=>json_encode($rand_attr) ]; self::update($chip['token_id'],$fieldsKv); diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index fb5b3cd2..706cee88 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -212,7 +212,9 @@ class Hero extends BaseModel { 'def' => $def, 'advanced_count' => $row['advanced_count'], 'lucky' => $heroLucky, - 'chip_ids' => $row['chip_ids'] + 'chip_ids' => $row['chip_ids'], + 'skill_common' => explode("|",$row['skill_common']), + 'skill_points' => $row['skill_points'], ); $dto['ceg_uplimit'] = FormulaService::getHeroPvpDailyCegUpLimit($dto); $dto['raw_pve_ceg_uplimit'] = @@ -249,8 +251,8 @@ class Hero extends BaseModel { 'quality' => 1, 'hero_tili' => $realHeroMeta ? $realHeroMeta['tili'] : 0, 'state' => self::GETED_STATE, - 'skill_lv1' => 1, - 'skill_lv2' => 1, + 'skill_lv1' => $realHeroMeta['skill1list'], + 'skill_lv2' => $realHeroMeta['skill3list'], 'rand_attr' => json_encode($randAttr), 'lock_type' => self::NO_LOCK, 'unlock_time' => 0, diff --git a/webapp/mt/SkillCommon.php b/webapp/mt/SkillCommon.php new file mode 100644 index 00000000..1192dc9f --- /dev/null +++ b/webapp/mt/SkillCommon.php @@ -0,0 +1,24 @@ +