This commit is contained in:
aozhiwei 2022-01-04 19:39:07 +08:00
parent 29b999dd71
commit 0ed0793757
2 changed files with 51 additions and 4 deletions

View File

@ -188,19 +188,35 @@ class UserController extends BaseAuthedController {
return;
}
if (!isValidSex($sex)) {
$this->_rspErr(1, '参数错误,sex不合法');
$this->_rspErr(1, '参数错误,sex不合法');
return;
}
if (!User::isValidHeadId($userInfo, $headId)) {
$this->_rspErr(1, '参数错误,head_id不合法');
$this->_rspErr(1, '参数错误,head_id不合法');
return;
}
if (!User::isValidHeadFrame($userInfo, $headFrame)) {
$this->_rspErr(1, '参数错误,head_frame不合法');
$this->_rspErr(1, '参数错误,head_frame不合法');
return;
}
$heroMeta = mt\Hero::get($heroId);
if (!$heroMeta) {
$this->_rspErr(1, '参数错误,hero_id不合法');
return;
}
$heroCfg = null;
{
$list = mt\Parameter::parseList('creator_present_player', array('|', ':'));
foreach ($list as $item) {
if ($item[0] == $heroId) {
$heroCfg = $item;
break;
}
}
if (!$heroCfg || $heroCfg[1] <= 0) {
$this->_rspErr(1, '参数错误,hero_id不合法');
return;
}
}
if (!$nameService->useName($name)) {
$this->_rspErr(2, '名字已被占用');
@ -213,6 +229,7 @@ class UserController extends BaseAuthedController {
'head_frame' => $headFrame,
'activated' => 1
));
Hero::addTryHero($heroMeta, $heroCfg[1]);
$propertyChgService = new services\PropertyChgService();
$propertyChgService->addUserChg();
$this->_rspData(array(

View File

@ -97,7 +97,37 @@ class Hero extends BaseModel {
'hero_lv' => 1,
'hero_tili' => $realHeroMeta ? $realHeroMeta['tili'] : 0,
'state' => self::GETED_STATE,
#'skin_id' => $defSkin,
'skill_lv1' => 1,
'skill_lv2' => 1,
'rand_attr' => '[]',
'lock_type' => self::NO_LOCK,
'unlock_time' => 0,
'unlock_trade_time' => 0,
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime()
)
);
}
public static function addTryHero($heroMeta, $tryCount)
{
$realHeroMeta = mt\Hero::get($heroMeta['id']);
SqlHelper::upsert(
myself()->_getSelfMysql(),
't_hero',
array(
'account_id' => myself()->_getAccountId(),
'hero_id' => $heroMeta['id']
),
array(
),
array(
'account_id' => myself()->_getAccountId(),
'hero_id' => $heroMeta['id'],
'hero_lv' => 1,
'hero_tili' => $realHeroMeta ? $realHeroMeta['tili'] : 0,
'state' => self::TRY_STATE,
'try_count' => $tryCount,
'skill_lv1' => 1,
'skill_lv2' => 1,
'rand_attr' => '[]',