96 lines
2.8 KiB
PHP
96 lines
2.8 KiB
PHP
<?php
|
|
|
|
require_once('mt/GunTalentGrow.php');
|
|
require_once('mt/GunTalent.php');
|
|
|
|
require_once('models/GunSkin.php');
|
|
require_once('models/GunTalent.php');
|
|
require_once('models/User.php');
|
|
|
|
require_once('services/PropertyChgService.php');
|
|
|
|
use phpcommon\SqlHelper;
|
|
use models\GunSkin;
|
|
use models\GunTalent;
|
|
use models\User;
|
|
|
|
class GunController extends BaseAuthedController {
|
|
|
|
public function skinList()
|
|
{
|
|
$skinList = array();
|
|
SqlHelper::ormSelect(
|
|
$this->_getSelfMysql(),
|
|
't_gun_skin',
|
|
array(
|
|
'account_id' => $this->_getAccountId()
|
|
),
|
|
function ($row) use(&$skinList) {
|
|
array_push($skinList, GunSkin::toDto($row));
|
|
}
|
|
);
|
|
$this->_rspData(array(
|
|
'skin_list' => $skinList
|
|
));
|
|
}
|
|
|
|
public function talentList()
|
|
{
|
|
$talentList = array();
|
|
SqlHelper::ormSelect(
|
|
$this->_getSelfMysql(),
|
|
't_gun_talent',
|
|
array(
|
|
'account_id' => $this->_getAccountId()
|
|
),
|
|
function ($row) use(&$talentList) {
|
|
array_push($talentList, GunTalent::toDto($row));
|
|
}
|
|
);
|
|
$this->_rspData(array(
|
|
'talent_list' => $talentList
|
|
));
|
|
}
|
|
|
|
public function upgradeTalentLv()
|
|
{
|
|
$talentId = getReqVal('talent_id', 0);
|
|
|
|
/*$talentMeta = mt\GunTalent::get($talentId);
|
|
if (!$talentMeta) {
|
|
$this->_rspErr(1, 'type_id参数错误');
|
|
return;
|
|
}
|
|
if (!mt\GunTalent::isValidTalent($talentMeta, $talentId)) {
|
|
$this->_rspErr(1, 'talent_id参数错误');
|
|
return;
|
|
}*/
|
|
$talentDb = GunTalent::find($talentId);
|
|
$currLv = isset($talentDb) ? $talentDb['talent_lv'] : 0;
|
|
$growMeta = mt\GunTalentGrow::getByIdLv($talentId, $currLv + 1);
|
|
if (!$growMeta) {
|
|
$this->_rspErr(2, '已满级');
|
|
return;
|
|
}
|
|
$ormUserInfo = $this->_getOrmUserInfo();
|
|
if ($ormUserInfo['level'] < $growMeta['need_user_level']) {
|
|
$this->_rspErr(3, '用户等级未到达');
|
|
return;
|
|
}
|
|
$costList = mt\GunTalentGrow::getCostList($growMeta);
|
|
$lackItem = array();
|
|
if (!$this->_hasEnoughItems($costList, $lackItem)) {
|
|
$this->_rspErr(3, '缺少材料');
|
|
return;
|
|
}
|
|
$this->_decItems($costList);
|
|
GunTalent::upgradeLv($talentId, $currLv + 1);
|
|
$propertyChgService = new services\PropertyChgService();
|
|
$propertyChgService->addUserChg();
|
|
$this->_rspData(array(
|
|
'property_chg' => $propertyChgService->toDto()
|
|
));
|
|
}
|
|
|
|
}
|