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