From dc3c40a98d8f297770282fc3af656c4d5421a1a3 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 13 Jun 2022 15:16:23 +0800 Subject: [PATCH] 1 --- doc/Hero.py | 1 + webapp/bootstrap/constant.php | 3 + webapp/controller/HeroController.class.php | 85 ++++++++++++++++++++-- 3 files changed, 82 insertions(+), 7 deletions(-) diff --git a/doc/Hero.py b/doc/Hero.py index ee5ab762..e2d14876 100644 --- a/doc/Hero.py +++ b/doc/Hero.py @@ -124,6 +124,7 @@ class Hero(object): 'url': 'webapp/index.php?c=Hero&a=receive', 'params': [ _common.ReqHead(), + ['type', 0, '1:领取升级 2:领取升阶'], ['hero_uniid', 0, '英雄唯一id'], ], 'response': [ diff --git a/webapp/bootstrap/constant.php b/webapp/bootstrap/constant.php index e53c29fa..bf007a06 100644 --- a/webapp/bootstrap/constant.php +++ b/webapp/bootstrap/constant.php @@ -68,3 +68,6 @@ const kHAT_ABS_VAL = 1; const kHAT_RATE_VAL = 2; const kWantedLockType = 3; + +const kMaxHeroUpLevelNum = 2; +const kMaxHeroUpQualityNum = 4; diff --git a/webapp/controller/HeroController.class.php b/webapp/controller/HeroController.class.php index 522aac6e..f455bf2c 100644 --- a/webapp/controller/HeroController.class.php +++ b/webapp/controller/HeroController.class.php @@ -90,7 +90,7 @@ class HeroController extends BaseAuthedController { public function getUpgradeLevelList() { $infos = array(); - for ($i = 0; $i <= 1; ++$i) { + for ($i = 0; $i < kMaxHeroUpLevelNum; ++$i) { $heroUniId = $this->_getV(TN_HERO_LEVEL_UP, $i); $info = null; if ($heroUniId) { @@ -99,7 +99,7 @@ class HeroController extends BaseAuthedController { $heroDto = Hero::toDto($heroDb); $info = array( 'info' => $heroDto, - 'countdown' => 0 + 'countdown' => $heroDto['unlock_lefttime'] ); } } @@ -123,6 +123,80 @@ class HeroController extends BaseAuthedController { public function receive() { + $type = getReqVal('type', 0); + $heroUniId = getReqVal('hero_uniid', 0); + $heroDb = Hero::find($heroUniId); + if (!$heroDb) { + $this->_rspErr(1, 'hero does not exist'); + return; + } + $heroDto = Hero::toDto($heroDb); + if ($heroDto['unlock_lefttime'] > 0) { + $this->_rspErr(1, 'Countdown is not over'); + return; + } + 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; + } + } + if (!$found) { + $this->_rspErr(1, 'hero does not exist'); + return; + } + $this->_setV(TN_HERO_LEVEL_UP, $idx, 0); + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addHeroChg(); + $propertyChgService->addBagChg(); + $propertyChgService->addUserChg(); + $rankActivityService = new service\RankActivityService(); + $rankActivityService->heroUpgradeLevel($heroDb['hero_lv'] + 1); + $this->_rspData(array( + 'property_chg' => $propertyChgService->toDto(), + )); + } + break; + case 2: + { + $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; + } + $this->_setV(TN_HERO_QUALITY_UP, $idx, 0); + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addHeroChg(); + $propertyChgService->addBagChg(); + $propertyChgService->addUserChg(); + $this->_rspData(array( + 'property_chg' => $propertyChgService->toDto(), + )); + } + break; + default: + { + $this->_rspErr(1, 'type parameter error'); + return; + } + break; + } /* $baseAttrs = mt\Hero::getHeroAttr($heroMeta); mt\AttrHelper::mergeAttr($baseAttrs, Bag::getAttrs()); @@ -347,17 +421,14 @@ class HeroController extends BaseAuthedController { Hero::update($heroUniId, array( 'hero_lv' => $heroDb['hero_lv'], - 'quality' => $heroDb['quality'] + 1, - 'rand_attr' => json_encode($attrs), 'lock_type' => Gun::QUALITY_LOCK, 'unlock_time' => $this->_getNowTime() + $currQualityMeta['time'], - 'unlock_trade_time' => $this->_getNowTime() + $currQualityMeta['time'] + mt\Parameter::getVal('hero_lock_transaction_time', 0) ) ); - $rankActivityService = new services\RankActivityService(); - $rankActivityService->heroUpgradeQuality($heroDb['quality'] + 1); $propertyChgService = new services\PropertyChgService(); $propertyChgService->addHeroChg(); + $propertyChgService->addBagChg(); + $propertyChgService->addUserChg(); $this->_rspData(array( 'property_chg' => $propertyChgService->toDto(), ));