diff --git a/webapp/controller/BagController.class.php b/webapp/controller/BagController.class.php index d7051dfa..010f6f66 100644 --- a/webapp/controller/BagController.class.php +++ b/webapp/controller/BagController.class.php @@ -188,7 +188,7 @@ class BagController extends BaseAuthedController { } if (mb_strlen($name, 'utf8') > 12) { $errCode = 5; - $errMsg = 'Parameter error name length must not be greater than 16'; + $errMsg = 'Parameter error name length must not be greater than 12'; return; } if(!preg_match("/^[a-z\d]*$/i",$name)) diff --git a/webapp/controller/CallbackController.class.php b/webapp/controller/CallbackController.class.php index 2dd1a76d..d84b846f 100644 --- a/webapp/controller/CallbackController.class.php +++ b/webapp/controller/CallbackController.class.php @@ -9,6 +9,10 @@ require_once('models/Nft.php'); require_once('models/Withdrawal.php'); require_once('models/Transfer.php'); require_once('models/UserWalletRecord.php'); +require_once('models/NftUpEvent.php'); +require_once('models/Hero.php'); +require_once('models/Gun.php'); +require_once('models/DynData.php'); require_once('phpcommon/bchelper.php'); @@ -17,6 +21,10 @@ use models\Nft; use models\Withdrawal; use models\Transfer; use models\UserWalletRecord; +use models\NftUpEvent; +use models\Hero; +use models\Gun; +use models\DynData; class CallbackController extends BaseController { @@ -130,4 +138,124 @@ class CallbackController extends BaseController { myself()->_rspOk(); } + public function heroUpgradeQuality(){ + $transId = getReqVal('trans_id', '0'); + $tokenId = getReqVal('token_id', '0'); + $quality = getReqVal('quality', '0'); + if (!$transId || !$tokenId || !$quality){ + myself()->_rspErr(1, 'param error'); + return; + } + if (NftUpEvent::find($transId)){ + myself()->_rspOk(); + return; + } + $heroDb = Hero::findByTokenId($tokenId); + if ( !$heroDb ){ + myself()->_rspErr(1, 'token_id param error'); + return; + } + $nextQualityMeta = mt\HeroQuality::getByQuality($quality); + if (! $nextQualityMeta){ + $this->_rspErr(1, 'quality is full'); + return; + } +// $idx = 0; +// $found = false; +// for ($i = 0; $i < kMaxHeroUpQualityNum; ++$i) { +// $upHeroUniId = DynData::getV(TN_HERO_QUALITY_UP, $i); +// if ($upHeroUniId == $heroDb['idx']) { +// $idx = $i; +// $found = true; +// break; +// } +// } +// if (!$found) { +// $this->_rspErr(1, 'hero does not exist'); +// return; +// } +// DynData::setV(TN_HERO_QUALITY_UP, $idx, 0); +// DynData::setV(TN_HERO_QUALITY_UP, (int)$idx + 1000, 0); + $heroLucky = \services\FormulaService::Hero_Advanced_Lucky_Value($heroDb['quality']); + $nextHeroLucky = \services\FormulaService::Hero_Advanced_Lucky_Value($quality); + $heroTili = \services\FormulaService::Hero_NFT_Maximum_Physical_Strength($heroDb['quality'],$heroLucky); + $nextHeroTili = \services\FormulaService::Hero_NFT_Maximum_Physical_Strength($quality,$nextHeroLucky); + Hero::updateByTokenId($tokenId, + array( + 'hero_tili' => $heroDb['hero_tili']+($nextHeroTili-$heroTili), + 'skill_points' => $heroDb['skill_points'] + $nextQualityMeta['skill_point'], + 'quality' => $quality, + 'advanced_count' => $heroDb['advanced_count'] + 1, + 'lock_type' => 0, + 'unlock_time' => 0, + 'labour' => 0, + ) + ); + if ($quality > myself()->_getV(TN_HERO_MAX_QUALITY, 0)) { + myself()->_setV(TN_HERO_MAX_QUALITY, 0, $quality); + } + $rankActivityService = new services\RankActivityService(); + $rankActivityService->heroUpgradeQuality($quality); + myself()->_rspOk(); + } + public function gunUpgradeQuality(){ + $transId = getReqVal('trans_id', '0'); + $tokenId = getReqVal('token_id', '0'); + $quality = getReqVal('quality', '0'); + if (!$transId || !$tokenId || !$quality){ + myself()->_rspErr(1, 'param error'); + return; + } + if (NftUpEvent::find($transId)){ + myself()->_rspOk(); + return; + } + $gunDb = Gun::findByTokenId($tokenId); + if ( !$gunDb ){ + myself()->_rspErr(1, 'token_id param error'); + return; + } + $nextQualityMeta = mt\GunQuality::getByQuality($quality); + if (!$nextQualityMeta) { + $this->_rspErr(1, 'quality is full'); + return; + } +// $idx = 0; +// $found = false; +// for ($i = 0; $i < kMaxHeroUpQualityNum; ++$i) { +// $upGunUniId = DynData::getV(TN_GUN_QUALITY_UP, $i); +// if ($upGunUniId == $gunDb['idx']) { +// $idx = $i; +// $found = true; +// break; +// } +// } +// if (!$found) { +// $this->_rspErr(1, 'gun does not exist'); +// return; +// } +// +// DynData::setV(TN_GUN_QUALITY_UP, $idx, 0); +// DynData::setV(TN_GUN_QUALITY_UP, (int)$idx + 1000, 0); + $gunLucky = \services\FormulaService::Weapon_Advanced_Lucky_Value($gunDb['quality']); + $nextGunLucky = \services\FormulaService::Weapon_Advanced_Lucky_Value($quality); + $durability = \services\FormulaService::Weapon_NFT_Maximum_Durability($gunDb['quality'],$gunLucky); + $nextDurability = \services\FormulaService::Weapon_NFT_Maximum_Durability($quality,$nextGunLucky); + Gun::updateByTokenId($tokenId, + array( + 'durability' => $gunDb['durability']+($nextDurability-$durability), + 'quality' => $quality, + 'lock_type' => 0, + 'unlock_time' => 0, + 'labour' => 0, + ) + ); + if ($quality > myself()->_getV(TN_GUN_MAX_QUALITY, 0)) { + myself()->_setV(TN_GUN_MAX_QUALITY, 0, $quality); + } + $rankActivityService = new services\RankActivityService(); + $rankActivityService->heroUpgradeQuality($quality); + myself()->_rspOk(); + } + } diff --git a/webapp/controller/GunController.class.php b/webapp/controller/GunController.class.php index b2aa1c39..1ae80a76 100644 --- a/webapp/controller/GunController.class.php +++ b/webapp/controller/GunController.class.php @@ -161,6 +161,10 @@ class GunController extends BaseAuthedController { $this->_rspErr(5, "It's already the highest level"); return; } + if ($gunDb['gun_lv'] + 1 == 15 && !$gunDb['token_id']){ + $this->_rspErr(1, "Free guns cannot continue to level up"); + return; + } $is_cec = false; if ($gunDb['gun_lv']+1 <15){ $costItems = array( @@ -273,10 +277,10 @@ class GunController extends BaseAuthedController { $this->_rspErr(1, 'slot_id parameter error'); return; } -// if (!$gunDb['token_id']){ -// $this->_rspErr(100, 'Free heroes cannot quality up'); -// return; -// } + if (!$gunDb['token_id']){ + $this->_rspErr(100, 'Free heroes cannot quality up'); + return; + } $costGunDb = Gun::find($costGunUniId); if (!$costGunDb) { $this->_rspErr(1, 'cost hero parameter error'); @@ -422,10 +426,10 @@ class GunController extends BaseAuthedController { $this->_rspErr(100, 'server internal error'); return; } -// if (!$gunDb['token_id']){ -// $this->_rspErr(100, 'Free gun cannot quality up'); -// return; -// } + if (!$gunDb['token_id']){ + $this->_rspErr(100, 'Free gun cannot quality up'); + return; + } if ($gunDb['gun_id'] != $costGunDb['gun_id']){ $this->_rspErr(100, 'You need the same kind of hero'); return; diff --git a/webapp/controller/HeroController.class.php b/webapp/controller/HeroController.class.php index 82275e25..61cf192f 100644 --- a/webapp/controller/HeroController.class.php +++ b/webapp/controller/HeroController.class.php @@ -508,6 +508,12 @@ class HeroController extends BaseAuthedController { $this->_rspErr(5, "It's already the highest level"); return; } + + if ($heroDb['hero_lv'] + 1 == 15 && !$heroDb['token_id']){ + $this->_rspErr(1, "Free heroes cannot continue to level up"); + return; + } + $is_cec = false; if ($heroDb['hero_lv']+1 <15){ $costItems = array( @@ -621,10 +627,10 @@ class HeroController extends BaseAuthedController { $this->_rspErr(1, 'slot_id parameter error'); return; } -// if (!$heroDb['token_id']){ -// $this->_rspErr(100, 'Free heroes cannot quality up'); -// return; -// } + if (!$heroDb['token_id']){ + $this->_rspErr(100, 'Free heroes cannot quality up'); + return; + } $costHeroDb = Hero::find($costHeroUniId); @@ -775,10 +781,10 @@ class HeroController extends BaseAuthedController { $this->_rspErr(100, 'server internal error'); return; } -// if (!$heroDb['token_id']){ -// $this->_rspErr(100, 'Free heroes cannot quality up'); -// return; -// } + if (!$heroDb['token_id']){ + $this->_rspErr(100, 'Free heroes cannot quality up'); + return; + } if ($heroDb['hero_id'] != $costHeroDb['hero_id']){ $this->_rspErr(100, 'You need the same kind of hero'); diff --git a/webapp/models/Gun.php b/webapp/models/Gun.php index aa09dbac..aafdf263 100644 --- a/webapp/models/Gun.php +++ b/webapp/models/Gun.php @@ -342,6 +342,20 @@ class Gun extends BaseModel { } } + public static function updateByTokenId($tokenId, $fieldsKv) + { + if (self::findByTokenId($tokenId)) { + SqlHelper::update + (myself()->_getSelfMysql(), + 't_gun', + array( + 'token_id' => $tokenId, + ), + $fieldsKv + ); + } + } + public static function addDurability($gunUniId, $val) { self::update($gunUniId, diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index 1d3f5a27..e7315ec6 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -379,6 +379,20 @@ class Hero extends BaseModel { } } + public static function updateByTokenId($tokenId, $fieldsKv) + { + if (self::findByTokenId($tokenId)) { + SqlHelper::update + (myself()->_getSelfMysql(), + 't_hero', + array( + 'token_id' => $tokenId, + ), + $fieldsKv + ); + } + } + public static function randHero(&$heroUniId, &$heroId) { $heroUniId = 0; diff --git a/webapp/models/NftUpEvent.php b/webapp/models/NftUpEvent.php new file mode 100644 index 00000000..2366050d --- /dev/null +++ b/webapp/models/NftUpEvent.php @@ -0,0 +1,22 @@ +_getSelfMysql(), + 't_nft_up_event', + array( + 'trans_id' => $transId, + ) + ); + return $row; + } + +} \ No newline at end of file