diff --git a/doc/Gun.py b/doc/Gun.py index ddaf6573..c87184b3 100644 --- a/doc/Gun.py +++ b/doc/Gun.py @@ -87,7 +87,7 @@ class Gun(object): _common.RspHead(), ['old_gun', _common.Gun(), '枪械-老'], ['new_gun', _common.Gun(), '枪械-新'], - ['cost', _common.Cost(), '所需费用'], + ['!cost', [_common.AwardItem()], '所需费用'], ] }, { diff --git a/doc/Hero.py b/doc/Hero.py index 94613077..780f3811 100644 --- a/doc/Hero.py +++ b/doc/Hero.py @@ -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(), + ] }, ] diff --git a/doc/HeroSkill.py b/doc/HeroSkill.py index 767c6d7b..add8505b 100644 --- a/doc/HeroSkill.py +++ b/doc/HeroSkill.py @@ -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(), - ] - }, + } ] diff --git a/doc/_common.py b/doc/_common.py index a7c5bfe4..d66c5a3f 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -1016,4 +1016,14 @@ class ChipPageSlot(object): ['slot_id', 0, '卡槽id'], ['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'], ] \ No newline at end of file diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 639a0421..1a4fe4dd 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -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 */; \ No newline at end of file diff --git a/webapp/controller/GunController.class.php b/webapp/controller/GunController.class.php index dba9c355..03544e25 100644 --- a/webapp/controller/GunController.class.php +++ b/webapp/controller/GunController.class.php @@ -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, diff --git a/webapp/controller/HeroController.class.php b/webapp/controller/HeroController.class.php index 95947538..e681506e 100644 --- a/webapp/controller/HeroController.class.php +++ b/webapp/controller/HeroController.class.php @@ -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; @@ -235,9 +237,9 @@ class HeroController extends BaseAuthedController { // $this->_rspData(array( // 'infos' => $infos // )); - $list = NftUpReceive::all(myself()->_getAccountId(),1); - $infos = array(); - foreach ($list as $value){ + $list = NftUpReceive::all(myself()->_getAccountId(),1); + $infos = array(); + foreach ($list as $value){ if ($this->_getNowTime() - $value['createtime'] < 24*3600 && !$value['from_data'] || $value['from_data'] ){ $hero = Hero::findByTokenId2($value['token_id1']); $costHero = Hero::findByTokenId2($value['token_id2']); @@ -261,7 +263,7 @@ class HeroController extends BaseAuthedController { ); array_push($infos,$info); } - } + } $this->_rspData(array( 'infos' => $infos )); @@ -286,40 +288,40 @@ class HeroController extends BaseAuthedController { $oldHero = $heroDto; $newHero = $heroDto; switch ($type) { - case 1: - { - $idx = 0; - $found = false; - for ($i = 0; $i < kMaxHeroUpLevelNum; ++$i) { - $upHeroUniId = $this->_getV(TN_HERO_LEVEL_UP, $i); - if ($upHeroUniId == $heroUniId) { - $idx = $i; - $found = true; - break; - } - } + case 1: + { + $idx = 0; + $found = false; + for ($i = 0; $i < kMaxHeroUpLevelNum; ++$i) { + $upHeroUniId = $this->_getV(TN_HERO_LEVEL_UP, $i); + if ($upHeroUniId == $heroUniId) { + $idx = $i; + $found = true; + break; + } + } - if (!$found) { - $this->_rspErr(1, 'hero does not exist2'); - return; - } - $this->_setV(TN_HERO_LEVEL_UP, $idx, 0); - $propertyChgService = new services\PropertyChgService(); - $propertyChgService->addHeroChg(); - $propertyChgService->addBagChg(); - $propertyChgService->addUserChg(); - $nextLevelMeta = null; - $nextLevelMeta = mt\HeroLevelAttr::getByLevel($heroDb['hero_lv'] + 1); - if ($nextLevelMeta) { - $attrs = mt\HeroLevelAttr::addRandAttrNew($heroDb,1); - $where = array( - 'hero_lv' => $heroDb['hero_lv'] + 1, - 'rand_attr' => json_encode($attrs), - 'lock_type' => 0, - 'unlock_time' => 0, - 'skill_points' => $heroDb['skill_points']+$nextLevelMeta['skill_point'] - ); - //免费英雄到底15级后生成NFT + if (!$found) { + $this->_rspErr(1, 'hero does not exist2'); + return; + } + $this->_setV(TN_HERO_LEVEL_UP, $idx, 0); + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addHeroChg(); + $propertyChgService->addBagChg(); + $propertyChgService->addUserChg(); + $nextLevelMeta = null; + $nextLevelMeta = mt\HeroLevelAttr::getByLevel($heroDb['hero_lv'] + 1); + if ($nextLevelMeta) { + $attrs = mt\HeroLevelAttr::addRandAttrNew($heroDb,1); + $where = array( + 'hero_lv' => $heroDb['hero_lv'] + 1, + 'rand_attr' => json_encode($attrs), + 'lock_type' => 0, + 'unlock_time' => 0, + 'skill_points' => $heroDb['skill_points']+$nextLevelMeta['skill_point'] + ); + //免费英雄到底15级后生成NFT // if ($heroDb['hero_lv'] + 1 == 15 && !$heroDb['token_id']){ // $token_id = myself()->_getNowTime(); // if(!\services\NftService::addNft($heroDb['hero_id'],$token_id)){ @@ -334,181 +336,181 @@ class HeroController extends BaseAuthedController { // 'skill_points' => $heroDb['skill_points']+$nextLevelMeta['skill_point'] // ); // } - Hero::update($heroUniId, $where); - if ($heroDb['hero_lv'] + 1 > myself()->_getV(TN_HERO_MAX_LEVEL, 0)) { - myself()->_setV(TN_HERO_MAX_LEVEL, 0, $heroDb['hero_lv'] + 1); + Hero::update($heroUniId, $where); + if ($heroDb['hero_lv'] + 1 > myself()->_getV(TN_HERO_MAX_LEVEL, 0)) { + myself()->_setV(TN_HERO_MAX_LEVEL, 0, $heroDb['hero_lv'] + 1); + } + $newHeroDb = Hero::find($heroUniId); + $newHero = Hero::toDto($newHeroDb); } - $newHeroDb = Hero::find($heroUniId); - $newHero = Hero::toDto($newHeroDb); + { + //埋点 + $event = [ + 'name' => LogService::HERO_LEVEL_UP, + ]; + $oldHero['level'] = $oldHero['hero_lv']; + $oldHero['item_id'] = $oldHero['hero_id']; + $newHero['level'] = $newHero['hero_lv']; + $newHero['item_id'] = $newHero['hero_id']; + LogService::LevelUpOrQualityUp($event,$oldHero,$newHero); + } + $this->_rspData(array( + 'property_chg' => $propertyChgService->toDto(), + 'old_hero' => $oldHero, + 'new_hero' => $newHero, + )); } - { - //埋点 - $event = [ - 'name' => LogService::HERO_LEVEL_UP, - ]; - $oldHero['level'] = $oldHero['hero_lv']; - $oldHero['item_id'] = $oldHero['hero_id']; - $newHero['level'] = $newHero['hero_lv']; - $newHero['item_id'] = $newHero['hero_id']; - LogService::LevelUpOrQualityUp($event,$oldHero,$newHero); - } - $this->_rspData(array( - 'property_chg' => $propertyChgService->toDto(), - 'old_hero' => $oldHero, - 'new_hero' => $newHero, - )); - } - break; - case 2: - { - $this->_rspOk();return; - $idx = 0; - $found = false; - for ($i = 0; $i < kMaxHeroUpQualityNum; ++$i) { - $upHeroUniId = $this->_getV(TN_HERO_QUALITY_UP, $i); - if ($upHeroUniId == $heroUniId) { - $idx = $i; - $found = true; - break; - } - } - if (!$found) { - $this->_rspErr(1, 'hero does not exist'); - return; - } - $costHeroUniId = $this->_getV(TN_HERO_QUALITY_UP, (int)$idx + 1000); - $this->_setV(TN_HERO_QUALITY_UP, $idx, 0); - $this->_setV(TN_HERO_QUALITY_UP, (int)$idx + 1000, 0); - $propertyChgService = new services\PropertyChgService(); - $propertyChgService->addHeroChg(); - $propertyChgService->addBagChg(); - $propertyChgService->addUserChg(); - $nextQualityMeta = mt\HeroQuality::getByQuality($heroDb['quality'] + 1); - if ($nextQualityMeta) { - $costHeroDb = Hero::find($costHeroUniId); - if ($costHeroDb['token_id']){ + break; + case 2: + { + $this->_rspOk();return; + $idx = 0; + $found = false; + for ($i = 0; $i < kMaxHeroUpQualityNum; ++$i) { + $upHeroUniId = $this->_getV(TN_HERO_QUALITY_UP, $i); + if ($upHeroUniId == $heroUniId) { + $idx = $i; + $found = true; + break; + } + } + if (!$found) { + $this->_rspErr(1, 'hero does not exist'); + return; + } + $costHeroUniId = $this->_getV(TN_HERO_QUALITY_UP, (int)$idx + 1000); + $this->_setV(TN_HERO_QUALITY_UP, $idx, 0); + $this->_setV(TN_HERO_QUALITY_UP, (int)$idx + 1000, 0); + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addHeroChg(); + $propertyChgService->addBagChg(); + $propertyChgService->addUserChg(); + $nextQualityMeta = mt\HeroQuality::getByQuality($heroDb['quality'] + 1); + if ($nextQualityMeta) { + $costHeroDb = Hero::find($costHeroUniId); + if ($costHeroDb['token_id']){ // SqlHelper::update( // myself()->_getMarketMysql(), // 't_nft', // ['token_id'=>$costHeroDb['token_id']], // ['deleted'=>1] // ); - }else{ + }else{ + Hero::update($costHeroUniId, + array( + 'account_id' => myself()->_getAccountId() . '!!!', + ) + ); + } Hero::update($costHeroUniId, array( - 'account_id' => myself()->_getAccountId() . '!!!', + 'lock_type' => 0, + 'unlock_time' => 0, ) ); - } - Hero::update($costHeroUniId, - array( - 'lock_type' => 0, - 'unlock_time' => 0, - ) - ); - { - //埋点 - $event = [ - 'name' => LogService::HERO_QUALITY_UP_MATERIAL, - ]; - $params = array( - array( - 'unique_id'=>$costHeroDb['idx'], - 'token_id'=>$costHeroDb['token_id'], - ) - ); - LogService::ConsumableMaterial($event,$params); - } - $rnd = rand(1, 100); - $probability = \services\FormulaService::Hero_Advanced_Probability($heroDb['quality'] + 1)*100; - if ($rnd > $probability) { - Hero::update($heroUniId, - array( - 'advanced_count' => $heroDb['advanced_count'] + 1, - 'lock_type' => 0, - 'unlock_time' => 0, - ) - ); - $oldHero['advanced_count'] += 1; - $newHero['advanced_count'] += 1; { //埋点 $event = [ - 'name' => LogService::HERO_QUALITY_UP, + 'name' => LogService::HERO_QUALITY_UP_MATERIAL, ]; - $oldHero['level'] = $oldHero['hero_lv']; - $oldHero['item_id'] = $oldHero['hero_id']; - $newHero['level'] = $newHero['hero_lv']; - $newHero['item_id'] = $newHero['hero_id']; - LogService::LevelUpOrQualityUp($event,$oldHero,$newHero); + $params = array( + array( + 'unique_id'=>$costHeroDb['idx'], + 'token_id'=>$costHeroDb['token_id'], + ) + ); + LogService::ConsumableMaterial($event,$params); } - $this->_rspRawData(array( - 'errcode' => 0, - 'errmsg' => '', - 'state' => 0, - 'old_hero' => $oldHero, - 'new_hero' => $newHero, - //'errmsg' => 'advance failed', - 'property_chg' => $propertyChgService->toDto(), - )); + $rnd = rand(1, 100); + $probability = \services\FormulaService::Hero_Advanced_Probability($heroDb['quality'] + 1)*100; + if ($rnd > $probability) { + Hero::update($heroUniId, + array( + 'advanced_count' => $heroDb['advanced_count'] + 1, + 'lock_type' => 0, + 'unlock_time' => 0, + ) + ); + $oldHero['advanced_count'] += 1; + $newHero['advanced_count'] += 1; + { + //埋点 + $event = [ + 'name' => LogService::HERO_QUALITY_UP, + ]; + $oldHero['level'] = $oldHero['hero_lv']; + $oldHero['item_id'] = $oldHero['hero_id']; + $newHero['level'] = $newHero['hero_lv']; + $newHero['item_id'] = $newHero['hero_id']; + LogService::LevelUpOrQualityUp($event,$oldHero,$newHero); + } + $this->_rspRawData(array( + 'errcode' => 0, + 'errmsg' => '', + 'state' => 0, + 'old_hero' => $oldHero, + 'new_hero' => $newHero, + //'errmsg' => 'advance failed', + 'property_chg' => $propertyChgService->toDto(), + )); + return; + } + $heroLucky = \services\FormulaService::Hero_Advanced_Lucky_Value($heroDb['quality']); + $nextHeroLucky = \services\FormulaService::Hero_Advanced_Lucky_Value($heroDb['quality'] + 1); + $heroTili = \services\FormulaService::Hero_NFT_Maximum_Physical_Strength($heroDb['quality'],$heroLucky); + $nextHeroTili = \services\FormulaService::Hero_NFT_Maximum_Physical_Strength($heroDb['quality'] + 1,$nextHeroLucky); + Hero::update($heroUniId, + array( + 'hero_tili' => $heroDb['hero_tili']+($nextHeroTili-$heroTili), + 'skill_points' => $heroDb['skill_points'] + $nextQualityMeta['skill_point'], + 'quality' => $heroDb['quality'] + 1, + 'advanced_count' => $heroDb['advanced_count'] + 1, + 'lock_type' => 0, + 'unlock_time' => 0, + 'labour' => 0, + ) + ); + if ($heroDb['quality'] + 1 > myself()->_getV(TN_HERO_MAX_QUALITY, 0)) { + myself()->_setV(TN_HERO_MAX_QUALITY, 0, $heroDb['quality'] + 1); + } + $newHeroDb = Hero::find($heroUniId); + $newHero = Hero::toDto($newHeroDb); + error_log(json_encode(array( + 'costHeroUniId' => $costHeroUniId, + 'heroUniId' => $heroUniId + ))); + $rankActivityService = new services\RankActivityService(); + $rankActivityService->heroUpgradeQuality($heroDb['quality'] + 1); + } + if (!$nextQualityMeta) { + $this->_rspErr(1, 'quality is full'); return; } - $heroLucky = \services\FormulaService::Hero_Advanced_Lucky_Value($heroDb['quality']); - $nextHeroLucky = \services\FormulaService::Hero_Advanced_Lucky_Value($heroDb['quality'] + 1); - $heroTili = \services\FormulaService::Hero_NFT_Maximum_Physical_Strength($heroDb['quality'],$heroLucky); - $nextHeroTili = \services\FormulaService::Hero_NFT_Maximum_Physical_Strength($heroDb['quality'] + 1,$nextHeroLucky); - Hero::update($heroUniId, - array( - 'hero_tili' => $heroDb['hero_tili']+($nextHeroTili-$heroTili), - 'skill_points' => $heroDb['skill_points'] + $nextQualityMeta['skill_point'], - 'quality' => $heroDb['quality'] + 1, - 'advanced_count' => $heroDb['advanced_count'] + 1, - 'lock_type' => 0, - 'unlock_time' => 0, - 'labour' => 0, - ) - ); - if ($heroDb['quality'] + 1 > myself()->_getV(TN_HERO_MAX_QUALITY, 0)) { - myself()->_setV(TN_HERO_MAX_QUALITY, 0, $heroDb['quality'] + 1); + { + //埋点 + $event = [ + 'name' => LogService::HERO_QUALITY_UP, + ]; + $oldHero['level'] = $oldHero['hero_lv']; + $oldHero['item_id'] = $oldHero['hero_id']; + $newHero['level'] = $newHero['hero_lv']; + $newHero['item_id'] = $newHero['hero_id']; + LogService::LevelUpOrQualityUp($event,$oldHero,$newHero); } - $newHeroDb = Hero::find($heroUniId); - $newHero = Hero::toDto($newHeroDb); - error_log(json_encode(array( - 'costHeroUniId' => $costHeroUniId, - 'heroUniId' => $heroUniId - ))); - $rankActivityService = new services\RankActivityService(); - $rankActivityService->heroUpgradeQuality($heroDb['quality'] + 1); + $this->_rspData(array( + 'state' => 1, + 'property_chg' => $propertyChgService->toDto(), + 'old_hero' => $oldHero, + 'new_hero' => $newHero, + )); } - if (!$nextQualityMeta) { - $this->_rspErr(1, 'quality is full'); - return; - } - { - //埋点 - $event = [ - 'name' => LogService::HERO_QUALITY_UP, - ]; - $oldHero['level'] = $oldHero['hero_lv']; - $oldHero['item_id'] = $oldHero['hero_id']; - $newHero['level'] = $newHero['hero_lv']; - $newHero['item_id'] = $newHero['hero_id']; - LogService::LevelUpOrQualityUp($event,$oldHero,$newHero); - } - $this->_rspData(array( - 'state' => 1, - 'property_chg' => $propertyChgService->toDto(), - 'old_hero' => $oldHero, - 'new_hero' => $newHero, - )); - } - break; - default: - { - $this->_rspErr(1, 'type parameter error'); - return; - } - break; + break; + default: + { + $this->_rspErr(1, 'type parameter error'); + return; + } + break; } } @@ -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 )); } @@ -765,16 +779,16 @@ class HeroController extends BaseAuthedController { $this->_decItems($costItems); Hero::update($heroUniId, - array( - 'lock_type' => Hero::QUALITY_LOCK, - 'unlock_time' => $this->_getNowTime() + $nextQualityMeta['time'], - ) + array( + 'lock_type' => Hero::QUALITY_LOCK, + 'unlock_time' => $this->_getNowTime() + $nextQualityMeta['time'], + ) ); Hero::update($costHeroUniId, - array( - 'lock_type' => Hero::COST_LOCK, - 'unlock_time' => $this->_getNowTime() + $nextQualityMeta['time'], - ) + array( + 'lock_type' => Hero::COST_LOCK, + 'unlock_time' => $this->_getNowTime() + $nextQualityMeta['time'], + ) ); $this->_setV(TN_HERO_QUALITY_UP, (int)$slotId, (int)$heroDb['idx']); $this->_setV(TN_HERO_QUALITY_UP, (int)$slotId + 1000, (int)$costHeroDb['idx']); @@ -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(); + } } diff --git a/webapp/mt/Skill.php b/webapp/mt/Skill.php index 3a77df1f..e047f198 100644 --- a/webapp/mt/Skill.php +++ b/webapp/mt/Skill.php @@ -6,6 +6,7 @@ use phpcommon; class Skill { + const DEFAULT_SKILL = 10101; public static function get($id) { return getXVal(self::getMetaList(), $id);