1
This commit is contained in:
parent
a7e8ed5917
commit
c264b23a56
@ -125,6 +125,11 @@ class GunController extends BaseAuthedController {
|
|||||||
$this->_rspErr(2, '锁定期间不能操作');
|
$this->_rspErr(2, '锁定期间不能操作');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$itemMeta = mt\Item::get($gunDb['gun_id']);
|
||||||
|
if (!$itemMeta) {
|
||||||
|
$this->_rspErr(100, '服务器内部错误');
|
||||||
|
return;
|
||||||
|
}
|
||||||
$currLevelMeta = mt\GunLevel::getByQualityLevel($gunDb['quality'], $gunDb['gun_lv']);
|
$currLevelMeta = mt\GunLevel::getByQualityLevel($gunDb['quality'], $gunDb['gun_lv']);
|
||||||
if (!$currLevelMeta) {
|
if (!$currLevelMeta) {
|
||||||
$this->_rspErr(100, '服务器内部错误');
|
$this->_rspErr(100, '服务器内部错误');
|
||||||
@ -169,8 +174,9 @@ class GunController extends BaseAuthedController {
|
|||||||
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
|
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$baseAttrs = mt\Item::getBaseAttrs($itemMeta);
|
||||||
$attrs = emptyReplace(json_decode($gunDb['rand_attr'], true), array());
|
$attrs = emptyReplace(json_decode($gunDb['rand_attr'], true), array());
|
||||||
$ret = mt\GunLevel::addRandAttr($nextLevelMeta, $attrs);
|
$ret = mt\GunLevel::addRandAttr($nextLevelMeta, $baseAttrs, $attrs);
|
||||||
if (!$ret) {
|
if (!$ret) {
|
||||||
$this->_rspErr(2, '服务器内部错误');
|
$this->_rspErr(2, '服务器内部错误');
|
||||||
return;
|
return;
|
||||||
@ -213,6 +219,11 @@ class GunController extends BaseAuthedController {
|
|||||||
$this->_rspErr(2, '锁定期间不能操作');
|
$this->_rspErr(2, '锁定期间不能操作');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$itemMeta = mt\Item::get($gunDb['gun_id']);
|
||||||
|
if (!$itemMeta) {
|
||||||
|
$this->_rspErr(100, '服务器内部错误');
|
||||||
|
return;
|
||||||
|
}
|
||||||
$currQualityMeta = mt\GunQuality::getByQuality($gunDb['quality']);
|
$currQualityMeta = mt\GunQuality::getByQuality($gunDb['quality']);
|
||||||
if (!$currQualityMeta) {
|
if (!$currQualityMeta) {
|
||||||
$this->_rspErr(100, '服务器内部错误');
|
$this->_rspErr(100, '服务器内部错误');
|
||||||
@ -262,13 +273,14 @@ class GunController extends BaseAuthedController {
|
|||||||
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
|
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$baseAttrs = mt\Item::getBaseAttrs($itemMeta);
|
||||||
$attrs = emptyReplace(json_decode($gunDb['rand_attr'], true), array());
|
$attrs = emptyReplace(json_decode($gunDb['rand_attr'], true), array());
|
||||||
{
|
{
|
||||||
$obtainAttrs = mt\GunQuality::getRandAttr($nextQualityMeta);
|
$obtainAttrs = mt\GunQuality::getRandAttr($nextQualityMeta);
|
||||||
mt\AttrHelper::mergeAttr($attrs, $obtainAttrs);
|
mt\AttrHelper::mergeAttr($attrs, $obtainAttrs);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
$ret = mt\GunLevel::addRandAttr($nextLevelMeta, $attrs);
|
$ret = mt\GunLevel::addRandAttr($nextLevelMeta, $baseAttrs, $attrs);
|
||||||
if (!$ret) {
|
if (!$ret) {
|
||||||
$this->_rspErr(2, '服务器内部错误');
|
$this->_rspErr(2, '服务器内部错误');
|
||||||
return;
|
return;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace mt;
|
namespace mt;
|
||||||
|
|
||||||
|
require_once('mt/StrHelper.php');
|
||||||
require_once('mt/AttrHelper.php');
|
require_once('mt/AttrHelper.php');
|
||||||
|
|
||||||
use phpcommon;
|
use phpcommon;
|
||||||
@ -19,21 +20,12 @@ class GunLevel {
|
|||||||
return getXVal(self::$qualityLevelHash, $quality . '_' . $level, null);
|
return getXVal(self::$qualityLevelHash, $quality . '_' . $level, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function addRandAttr($levelMeta, &$attrs)
|
public static function addRandAttr($levelMeta, $baseAttrs, &$attrs)
|
||||||
{
|
{
|
||||||
$attrArr = StrHelper::parseList($levelMeta['rand_attrs'], array('|', ':'));
|
$nums = explode(':', $levelMeta['rand_attrs_num']);
|
||||||
foreach ($attrArr as $tuple) {
|
$num = rand($nums[0], $nums[1]);
|
||||||
$attrId = $tuple[0];
|
$cfgAttrs = StrHelper::parseList($levelMeta['rand_attrs'], array('|', ':'));
|
||||||
$type = $tuple[1];
|
AttrHelper::addRandAttrs($cfgAttrs, $num, $baseAttrs, $dbAttrs);
|
||||||
$val = rand($tuple[2], $tuple[3]);
|
|
||||||
foreach ($attrs as &$attr) {
|
|
||||||
if ($attr['attr_id'] == $attrId &&
|
|
||||||
$attr['type'] == $type) {
|
|
||||||
$attr['val'] += $val;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user