hero gun upgradeQuality callback
This commit is contained in:
parent
6cc11aa665
commit
69aa33dc50
@ -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))
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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');
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
22
webapp/models/NftUpEvent.php
Normal file
22
webapp/models/NftUpEvent.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace models;
|
||||
|
||||
use mt;
|
||||
use phpcommon\SqlHelper;
|
||||
class NftUpEvent extends BaseModel
|
||||
{
|
||||
public static function find($transId)
|
||||
{
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
myself()->_getSelfMysql(),
|
||||
't_nft_up_event',
|
||||
array(
|
||||
'trans_id' => $transId,
|
||||
)
|
||||
);
|
||||
return $row;
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user