This commit is contained in:
aozhiwei 2021-11-29 16:30:35 +08:00
parent a89b04db72
commit 42d1f3dff1
5 changed files with 57 additions and 19 deletions

View File

@ -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(), '属性变更'],
]
},
]

View File

@ -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())
)
));
}
}

View File

@ -1,16 +0,0 @@
<?php
class ServerSwitchController extends BaseAuthedController {
public function getSwitch()
{
$payable = 0;
echo json_encode(array(
'errcode' => 0,
'errmsg' => '',
'payable' => $payable,
'show_team_ui' => 1
));
}
}

View File

@ -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()
)
);
}
}

View File

@ -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);
}