From 0ed0793757b716c5988f20d31e043c683f7c666e Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 4 Jan 2022 19:39:07 +0800 Subject: [PATCH] 1 --- webapp/controller/UserController.class.php | 23 ++++++++++++++-- webapp/models/Hero.php | 32 +++++++++++++++++++++- 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/webapp/controller/UserController.class.php b/webapp/controller/UserController.class.php index c626b846..36c68a64 100644 --- a/webapp/controller/UserController.class.php +++ b/webapp/controller/UserController.class.php @@ -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( diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index ef73ea4d..70312f0c 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -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' => '[]',