diff --git a/webapp/controller/BagController.class.php b/webapp/controller/BagController.class.php index eb66c160..96eec645 100644 --- a/webapp/controller/BagController.class.php +++ b/webapp/controller/BagController.class.php @@ -8,6 +8,7 @@ require_once('mt/LootConfig.php'); require_once('models/Bag.php'); require_once('models/Hero.php'); +require_once('models/User.php'); require_once('services/AwardService.php'); @@ -19,6 +20,7 @@ require_once('services/LootService.php'); use phpcommon\SqlHelper; use models\Bag; use models\Hero; +use models\User; use services\LogService; class BagController extends BaseAuthedController { @@ -524,10 +526,7 @@ class BagController extends BaseAuthedController { $this->_rspErr(1, "You don't have the hero yet"); return; } - if ($userInfo['hero_id'] == $heroUniId){ - $this->_rspErr(1, "Unable to operate the battle hero"); - return; - } + // if (!$heroDb['token_id']){ // $this->_rspErr(1, "this hero is not NFT"); // return; @@ -539,8 +538,17 @@ class BagController extends BaseAuthedController { ) )); Hero::update($heroUniId,array( - 'seal_type' => 1 + 'seal_type' => Hero::SEAL_STATE )); + if ($userInfo['hero_id'] == $heroUniId){ + $heroUniIdNew = 0; + $heroId = 0; + Hero::randHero($heroUniIdNew,$heroId); + User::Update(array( + 'hero_id' => $heroUniIdNew + )); + $this->propertyChgService->addUserChg(); + } $this->propertyChgService->addBagChg(); $this->propertyChgService->addHeroChg(); $event = array( diff --git a/webapp/controller/HeroController.class.php b/webapp/controller/HeroController.class.php index 1df23e8f..c6a3edc7 100644 --- a/webapp/controller/HeroController.class.php +++ b/webapp/controller/HeroController.class.php @@ -328,7 +328,7 @@ class HeroController extends BaseAuthedController { // return; // } Hero::update($heroUniId,array( - 'seal_type' => 0, + 'seal_type' => Hero::UNSEAL_STATE, "unseal_time" => myself()->_getNowTime() )); $propertyChgService = new services\PropertyChgService(); diff --git a/webapp/controller/UserController.class.php b/webapp/controller/UserController.class.php index 173d50a2..e9145760 100644 --- a/webapp/controller/UserController.class.php +++ b/webapp/controller/UserController.class.php @@ -318,13 +318,15 @@ class UserController extends BaseAuthedController { return $val; }, 'valid_func' => function ($val, &$errCode, &$errMsg) use ($userInfo) { - if (User::isValidHeroId($userInfo, $val)) { + $heroDb = Hero::find($val); + if (User::isValidHeroId($userInfo, $val) && $heroDb['seal_type'] == Hero::UNSEAL_STATE) { return true; - } else { + }else{ $errCode = 1; $errMsg = 'hero_id parameter error'; return false; } + } ), 'first_fight' => array( diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index 1a66a037..71767ba7 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -35,6 +35,9 @@ class Hero extends BaseModel { const GETED_STATE = 0; const FREE_STATE = 1; + const SEAL_STATE = 1; + const UNSEAL_STATE = 0; + const NO_LOCK = 0; const LEVEL_LOCK = 1; const QUALITY_LOCK = 2; @@ -277,7 +280,7 @@ class Hero extends BaseModel { $userDb = myself()->_getOrmUserInfo(); $isSelect = 0; - if ($row['idx'] == $userDb['hero_id']){ + if ($row['idx'] == $userDb['hero_id'] && self::findByAccountId(myself()->_getAccountId(),$userDb['hero_id'])){ $isSelect = 1; } $skinDb = HeroSkin::findBx($row['hero_id']); @@ -648,6 +651,13 @@ class Hero extends BaseModel { 't_hero', $fieldsKv ); + $userInfo = myself()->_getOrmUserInfo(); + if (!$userInfo['hero_id'] && $seal_type == self::UNSEAL_STATE){ + $heroUnid = SqlHelper::getLastInsertId(myself()->_getSelfMysql()); + User::Update(array( + 'hero_id' => $heroUnid + )); + } return true; } @@ -701,9 +711,9 @@ class Hero extends BaseModel { $heroList = array(); Hero::getHeroList(function ($row) use($heroId, &$heroList) { -// if ($row['state'] == self::GETED_STATE) { + if ($row['seal_type'] == self::UNSEAL_STATE) { array_push($heroList, Hero::toDto($row)); -// } + } }); $key = null; if (count($heroList)>0){