This commit is contained in:
hujiabin 2024-06-07 14:27:49 +08:00
parent 9443d07aa8
commit 3073b52274
4 changed files with 31 additions and 11 deletions

View File

@ -8,6 +8,7 @@ require_once('mt/LootConfig.php');
require_once('models/Bag.php'); require_once('models/Bag.php');
require_once('models/Hero.php'); require_once('models/Hero.php');
require_once('models/User.php');
require_once('services/AwardService.php'); require_once('services/AwardService.php');
@ -19,6 +20,7 @@ require_once('services/LootService.php');
use phpcommon\SqlHelper; use phpcommon\SqlHelper;
use models\Bag; use models\Bag;
use models\Hero; use models\Hero;
use models\User;
use services\LogService; use services\LogService;
class BagController extends BaseAuthedController { class BagController extends BaseAuthedController {
@ -524,10 +526,7 @@ class BagController extends BaseAuthedController {
$this->_rspErr(1, "You don't have the hero yet"); $this->_rspErr(1, "You don't have the hero yet");
return; return;
} }
if ($userInfo['hero_id'] == $heroUniId){
$this->_rspErr(1, "Unable to operate the battle hero");
return;
}
// if (!$heroDb['token_id']){ // if (!$heroDb['token_id']){
// $this->_rspErr(1, "this hero is not NFT"); // $this->_rspErr(1, "this hero is not NFT");
// return; // return;
@ -539,8 +538,17 @@ class BagController extends BaseAuthedController {
) )
)); ));
Hero::update($heroUniId,array( 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->addBagChg();
$this->propertyChgService->addHeroChg(); $this->propertyChgService->addHeroChg();
$event = array( $event = array(

View File

@ -328,7 +328,7 @@ class HeroController extends BaseAuthedController {
// return; // return;
// } // }
Hero::update($heroUniId,array( Hero::update($heroUniId,array(
'seal_type' => 0, 'seal_type' => Hero::UNSEAL_STATE,
"unseal_time" => myself()->_getNowTime() "unseal_time" => myself()->_getNowTime()
)); ));
$propertyChgService = new services\PropertyChgService(); $propertyChgService = new services\PropertyChgService();

View File

@ -318,13 +318,15 @@ class UserController extends BaseAuthedController {
return $val; return $val;
}, },
'valid_func' => function ($val, &$errCode, &$errMsg) use ($userInfo) { '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; return true;
} else { }else{
$errCode = 1; $errCode = 1;
$errMsg = 'hero_id parameter error'; $errMsg = 'hero_id parameter error';
return false; return false;
} }
} }
), ),
'first_fight' => array( 'first_fight' => array(

View File

@ -35,6 +35,9 @@ class Hero extends BaseModel {
const GETED_STATE = 0; const GETED_STATE = 0;
const FREE_STATE = 1; const FREE_STATE = 1;
const SEAL_STATE = 1;
const UNSEAL_STATE = 0;
const NO_LOCK = 0; const NO_LOCK = 0;
const LEVEL_LOCK = 1; const LEVEL_LOCK = 1;
const QUALITY_LOCK = 2; const QUALITY_LOCK = 2;
@ -277,7 +280,7 @@ class Hero extends BaseModel {
$userDb = myself()->_getOrmUserInfo(); $userDb = myself()->_getOrmUserInfo();
$isSelect = 0; $isSelect = 0;
if ($row['idx'] == $userDb['hero_id']){ if ($row['idx'] == $userDb['hero_id'] && self::findByAccountId(myself()->_getAccountId(),$userDb['hero_id'])){
$isSelect = 1; $isSelect = 1;
} }
$skinDb = HeroSkin::findBx($row['hero_id']); $skinDb = HeroSkin::findBx($row['hero_id']);
@ -648,6 +651,13 @@ class Hero extends BaseModel {
't_hero', 't_hero',
$fieldsKv $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; return true;
} }
@ -701,9 +711,9 @@ class Hero extends BaseModel {
$heroList = array(); $heroList = array();
Hero::getHeroList(function ($row) use($heroId, &$heroList) { 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)); array_push($heroList, Hero::toDto($row));
// } }
}); });
$key = null; $key = null;
if (count($heroList)>0){ if (count($heroList)>0){