1
This commit is contained in:
parent
7c35018135
commit
2725daba43
@ -106,30 +106,30 @@ class GunController extends BaseAuthedController {
|
||||
public function upgradeLevel()
|
||||
{
|
||||
$costItemId = getReqVal('cost_item_id', 0);
|
||||
$heroUniId = getReqVal('hero_uniid', 0);
|
||||
$heroDb = Hero::find($heroUniId);
|
||||
if (!$heroDb) {
|
||||
$this->_rspErr(1, '英雄不存在');
|
||||
$gunUniId = getReqVal('gun_uniid', 0);
|
||||
$gunDb = Gun::find($gunUniId);
|
||||
if (!$gunDb) {
|
||||
$this->_rspErr(1, '枪不存在');
|
||||
return;
|
||||
}
|
||||
if ($heroDb['state'] != Hero::GETED_STATE) {
|
||||
$this->_rspErr(3, '试用英雄不能操作');
|
||||
if ($gunDb['state'] != Gun::GETED_STATE) {
|
||||
$this->_rspErr(3, '试用枪不能操作');
|
||||
return;
|
||||
}
|
||||
if ($heroDb['unlock_time'] > $this->_getNowTime()) {
|
||||
if ($gunDb['unlock_time'] > $this->_getNowTime()) {
|
||||
$this->_rspErr(2, '锁定期间不能操作');
|
||||
return;
|
||||
}
|
||||
if ($heroDb['unlock_trade_time'] > $this->_getNowTime()) {
|
||||
if ($gunDb['unlock_trade_time'] > $this->_getNowTime()) {
|
||||
$this->_rspErr(2, '锁定期间不能操作');
|
||||
return;
|
||||
}
|
||||
$currLevelMeta = mt\HeroLevel::getByQualityLevel($heroDb['quality'], $heroDb['hero_lv']);
|
||||
$currLevelMeta = mt\GunLevel::getByQualityLevel($gunDb['quality'], $gunDb['gun_lv']);
|
||||
if (!$currLevelMeta) {
|
||||
$this->_rspErr(100, '服务器内部错误');
|
||||
return;
|
||||
}
|
||||
$nextLevelMeta = mt\HeroLevel::getByQualityLevel($heroDb['quality'], $heroDb['hero_lv'] + 1);
|
||||
$nextLevelMeta = mt\GunLevel::getByQualityLevel($gunDb['quality'], $gunDb['gun_lv'] + 1);
|
||||
if (!$nextLevelMeta) {
|
||||
$this->_rspErr(5, '已满级');
|
||||
return;
|
||||
@ -168,16 +168,16 @@ class GunController extends BaseAuthedController {
|
||||
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
|
||||
return;
|
||||
}
|
||||
$attrs = emptyReplace(json_decode($heroDb['rand_attr'], true), array());
|
||||
$ret = mt\HeroLevel::addRandAttr($nextLevelMeta, $attrs);
|
||||
$attrs = emptyReplace(json_decode($gunDb['rand_attr'], true), array());
|
||||
$ret = mt\GunLevel::addRandAttr($nextLevelMeta, $attrs);
|
||||
if (!$ret) {
|
||||
$this->_rspErr(2, '服务器内部错误');
|
||||
return;
|
||||
}
|
||||
$this->_decItems($costItems);
|
||||
Hero::update($heroUniId,
|
||||
Gun::update($gunUniId,
|
||||
array(
|
||||
'hero_lv' => $heroDb['hero_lv'] + 1,
|
||||
'gun_lv' => $gunDb['gun_lv'] + 1,
|
||||
'rand_attr' => json_encode($attrs)
|
||||
)
|
||||
);
|
||||
@ -191,35 +191,35 @@ class GunController extends BaseAuthedController {
|
||||
public function upgradeQuality()
|
||||
{
|
||||
$costItemId = getReqVal('cost_item_id', 0);
|
||||
$heroUniId = getReqVal('hero_uniid', 0);
|
||||
$heroDb = Hero::find($heroUniId);
|
||||
if (!$heroDb) {
|
||||
$this->_rspErr(1, '英雄不存在');
|
||||
$gunUniId = getReqVal('gun_uniid', 0);
|
||||
$gunDb = Gun::find($gunUniId);
|
||||
if (!$gunDb) {
|
||||
$this->_rspErr(1, '枪不存在');
|
||||
return;
|
||||
}
|
||||
if ($heroDb['state'] != Hero::GETED_STATE) {
|
||||
$this->_rspErr(3, '试用英雄不能操作');
|
||||
if ($gunDb['state'] != Gun::GETED_STATE) {
|
||||
$this->_rspErr(3, '试用枪不能操作');
|
||||
return;
|
||||
}
|
||||
if ($heroDb['unlock_time'] > $this->_getNowTime()) {
|
||||
if ($gunDb['unlock_time'] > $this->_getNowTime()) {
|
||||
$this->_rspErr(2, '锁定期间不能操作');
|
||||
return;
|
||||
}
|
||||
if ($heroDb['unlock_trade_time'] > $this->_getNowTime()) {
|
||||
if ($gunDb['unlock_trade_time'] > $this->_getNowTime()) {
|
||||
$this->_rspErr(2, '锁定期间不能操作');
|
||||
return;
|
||||
}
|
||||
$currQualityMeta = mt\HeroQuality::getByQuality($heroDb['quality']);
|
||||
$currQualityMeta = mt\GunQuality::getByQuality($gunDb['quality']);
|
||||
if (!$currQualityMeta) {
|
||||
$this->_rspErr(100, '服务器内部错误');
|
||||
return;
|
||||
}
|
||||
$nextQualityMeta = mt\HeroQuality::getByQuality($heroDb['quality'] + 1);
|
||||
$nextQualityMeta = mt\GunQuality::getByQuality($gunDb['quality'] + 1);
|
||||
if (!$nextQualityMeta) {
|
||||
$this->_rspErr(5, '已满级1');
|
||||
return;
|
||||
}
|
||||
$nextLevelMeta = mt\HeroLevel::getByQualityLevel($heroDb['quality'] + 1, $heroDb['hero_lv']);
|
||||
$nextLevelMeta = mt\GunLevel::getByQualityLevel($gunDb['quality'] + 1, $gunDb['gun_lv']);
|
||||
if (!$nextLevelMeta) {
|
||||
$this->_rspErr(5, '已满级2');
|
||||
return;
|
||||
@ -258,23 +258,23 @@ class GunController extends BaseAuthedController {
|
||||
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
|
||||
return;
|
||||
}
|
||||
$attrs = emptyReplace(json_decode($heroDb['rand_attr'], true), array());
|
||||
$attrs = emptyReplace(json_decode($gunDb['rand_attr'], true), array());
|
||||
{
|
||||
$obtainAttrs = mt\HeroQuality::getRandAttr($nextQualityMeta);
|
||||
$obtainAttrs = mt\GunQuality::getRandAttr($nextQualityMeta);
|
||||
mt\AttrHelper::mergeAttr($attrs, $obtainAttrs);
|
||||
}
|
||||
{
|
||||
$ret = mt\HeroLevel::addRandAttr($nextLevelMeta, $attrs);
|
||||
$ret = mt\GunLevel::addRandAttr($nextLevelMeta, $attrs);
|
||||
if (!$ret) {
|
||||
$this->_rspErr(2, '服务器内部错误');
|
||||
return;
|
||||
}
|
||||
}
|
||||
$this->_decItems($costItems);
|
||||
Hero::update($heroUniId,
|
||||
Gun::update($gunUniId,
|
||||
array(
|
||||
'hero_lv' => $heroDb['hero_lv'],
|
||||
'quality' => $heroDb['quality'] + 1,
|
||||
'gun_lv' => $gunDb['gun_lv'],
|
||||
'quality' => $gunDb['quality'] + 1,
|
||||
'rand_attr' => json_encode($attrs)
|
||||
)
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user