From 42d1f3dff1e5f5a872d0bb37fc8917ac4d848b5a Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 29 Nov 2021 16:30:35 +0800 Subject: [PATCH] 1 --- doc/Gun.py | 3 +- webapp/controller/GunController.class.php | 28 +++++++++++++++++++ .../ServerSwitchController.class.php | 16 ----------- webapp/models/GunTalent.php | 27 +++++++++++++++++- webapp/mt/GunTalent.php | 2 +- 5 files changed, 57 insertions(+), 19 deletions(-) delete mode 100644 webapp/controller/ServerSwitchController.class.php diff --git a/doc/Gun.py b/doc/Gun.py index 8ff8db9..2bdad0d 100644 --- a/doc/Gun.py +++ b/doc/Gun.py @@ -40,10 +40,11 @@ class Gun(object): 'params': [ _common.ReqHead(), ['type_id', 0, '枪支类型'], - ['talent_id', 0, '天赋点'], + ['talent_id', 0, '天赋id'], ], 'response': [ _common.RspHead(), + ['property_chg', _common.PropertyChg(), '属性变更'], ] }, ] diff --git a/webapp/controller/GunController.class.php b/webapp/controller/GunController.class.php index 86472e2..797d040 100644 --- a/webapp/controller/GunController.class.php +++ b/webapp/controller/GunController.class.php @@ -52,8 +52,36 @@ class GunController extends BaseAuthedController { { $typeId = getReqVal('type_id', 0); $talentId = getReqVal('talent_id', 0); + + $talentMeta = mt\GunTalent::get($typeId); + if (!$talentMeta) { + $this->_rspErr(1, 'type_id参数错误'); + return; + } + if (!mt\GunTalent::isValidTalent($talentMeta, $talentId)) { + $this->_rspErr(1, 'talent_id参数错误'); + return; + } $talentDb = GunTalent::find($typeId, $talentId); $currLv = isset($talentDb) ? $talentDb['talent_lv'] : 0; + $growMeta = mt\GunTalentGrow::getByIdLv($talentId, $currLv + 1); + if (!$growMeta) { + $this->_rspErr(2, '已满级'); + return; + } + $ormUserInfo = $this->_getOrmUserInfo(); + $costList = mt\GunTalentGrow::getCostList($growMeta); + $lackItem = array(); + if (!$this->_hasEnoughItems($costList, $lackItem)) { + $this->_rspErr(3, '缺少材料'); + return; + } + GunTalent::upgradeLv($typeId, $talentId, $currLv + 1); + $this->_rspData(array( + 'property_chg' => array( + 'user_info' => User::info($this->_getOrmUserInfo()) + ) + )); } } diff --git a/webapp/controller/ServerSwitchController.class.php b/webapp/controller/ServerSwitchController.class.php deleted file mode 100644 index 7ccad54..0000000 --- a/webapp/controller/ServerSwitchController.class.php +++ /dev/null @@ -1,16 +0,0 @@ - 0, - 'errmsg' => '', - 'payable' => $payable, - 'show_team_ui' => 1 - )); - } - -} diff --git a/webapp/models/GunTalent.php b/webapp/models/GunTalent.php index ea3dda6..46e5aba 100644 --- a/webapp/models/GunTalent.php +++ b/webapp/models/GunTalent.php @@ -15,7 +15,7 @@ class GunTalent extends BaseModel { array( 'account_id' => myself()->_getAccountId(), 'type_id' => $typeId, - 'type_id' => $row['type_id'], + 'talent_id' => $talentId ) ); return $row; @@ -30,4 +30,29 @@ class GunTalent extends BaseModel { ); } + public static function upgradeLv($typeId, $talentId, $talentLv) + { + SqlHelper::upsert( + myself()->_getSelfMysql(), + 't_gun_talent', + array( + 'account_id' => myself()->_getAccountId(), + 'type_id' => $typeId, + 'talent_id' => $talentId + ), + array( + 'talent_lv' => $talentLv, + 'modifytime' => myself()->_getNowTime() + ), + array( + 'account_id' => myself()->_getAccountId(), + 'type_id' => $typeId, + 'talent_id' => $talentId, + 'talent_lv' => $talentLv, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime() + ) + ); + } + } diff --git a/webapp/mt/GunTalent.php b/webapp/mt/GunTalent.php index ffbae4b..1fe1d07 100644 --- a/webapp/mt/GunTalent.php +++ b/webapp/mt/GunTalent.php @@ -13,7 +13,7 @@ class GunTalent { public static function isValidTalent($meta, $talentId) { - $strArr = explode("|", $meta["list"]); + $strArr = explode("|", $meta["talent_list"]); return in_array($talentId, $strArr); }