1
This commit is contained in:
parent
765a6117e8
commit
34af585100
@ -9,6 +9,9 @@ require_once('mt/HeroQuality.php');
|
||||
require_once('models/Hero.php');
|
||||
require_once('models/HeroSkin.php');
|
||||
|
||||
require_once('services/AwardService.php');
|
||||
require_once('services/PropertyChgService.php');
|
||||
|
||||
use phpcommon\SqlHelper;
|
||||
use models\Hero;
|
||||
use models\HeroSkin;
|
||||
@ -95,7 +98,7 @@ class HeroController extends BaseAuthedController {
|
||||
$this->_rspErr(1, '英雄不存在');
|
||||
return;
|
||||
}
|
||||
if ($heroDb['state'] == Hero::GETED_STATE) {
|
||||
if ($heroDb['state'] != Hero::GETED_STATE) {
|
||||
$this->_rspErr(3, '试用英雄不能操作');
|
||||
return;
|
||||
}
|
||||
@ -107,11 +110,6 @@ class HeroController extends BaseAuthedController {
|
||||
$this->_rspErr(2, '锁定期间不能操作');
|
||||
return;
|
||||
}
|
||||
$initLevelMeta = mt\HeroLevel::getByQualityLevel(1, 1);
|
||||
if (!$initLevelMeta) {
|
||||
$this->_rspErr(100, '服务器内部错误');
|
||||
return;
|
||||
}
|
||||
$currLevelMeta = mt\HeroLevel::getByQualityLevel($heroDb['quality'], $heroDb['hero_lv']);
|
||||
if (!$currLevelMeta) {
|
||||
$this->_rspErr(100, '服务器内部错误');
|
||||
@ -156,9 +154,8 @@ class HeroController extends BaseAuthedController {
|
||||
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
|
||||
return;
|
||||
}
|
||||
$oldAttr = json_decode($heroDb['rand_attr'], true);
|
||||
$randAttr = $oldAttr;
|
||||
$ret = mt\HeroLevel::getRandAttr($initLevelMeta, $nextLevelMeta, $oldAttr, $randAttr);
|
||||
$attrs = emptyReplace(json_decode($heroDb['rand_attr'], true), array());
|
||||
$ret = mt\HeroLevel::addRandAttr($nextLevelMeta, $attrs);
|
||||
if (!$ret) {
|
||||
$this->_rspErr(2, '服务器内部错误');
|
||||
return;
|
||||
@ -166,10 +163,15 @@ class HeroController extends BaseAuthedController {
|
||||
$this->_decItems($costItems);
|
||||
Hero::update($heroUniId,
|
||||
array(
|
||||
'level' => $heroDb['level'] + 1,
|
||||
'rand_attr' => json_encode($randAttr)
|
||||
'hero_lv' => $heroDb['hero_lv'] + 1,
|
||||
'rand_attr' => json_encode($attrs)
|
||||
)
|
||||
);
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
$propertyChgService->addHeroChg();
|
||||
$this->_rspData(array(
|
||||
'property_chg' => $propertyChgService->toDto(),
|
||||
));
|
||||
}
|
||||
|
||||
public function upgradeQuality()
|
||||
@ -181,7 +183,7 @@ class HeroController extends BaseAuthedController {
|
||||
$this->_rspErr(1, '英雄不存在');
|
||||
return;
|
||||
}
|
||||
if ($heroDb['state'] == Hero::GETED_STATE) {
|
||||
if ($heroDb['state'] != Hero::GETED_STATE) {
|
||||
$this->_rspErr(3, '试用英雄不能操作');
|
||||
return;
|
||||
}
|
||||
|
@ -98,6 +98,7 @@ class Hero extends BaseModel {
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'hero_id' => $heroMeta['id'],
|
||||
'hero_lv' => 1,
|
||||
'quality' => 1,
|
||||
'hero_tili' => $realHeroMeta ? $realHeroMeta['tili'] : 0,
|
||||
'state' => self::GETED_STATE,
|
||||
'skill_lv1' => 1,
|
||||
@ -135,6 +136,7 @@ class Hero extends BaseModel {
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'hero_id' => $heroMeta['id'],
|
||||
'hero_lv' => 1,
|
||||
'quality' => 1,
|
||||
'hero_tili' => $realHeroMeta ? $realHeroMeta['tili'] : 0,
|
||||
'state' => self::TRY_STATE,
|
||||
'try_count' => $tryCount,
|
||||
|
@ -19,15 +19,21 @@ class HeroLevel {
|
||||
return getXVal(self::$qualityLevelHash, $quality . '_' . $level, null);
|
||||
}
|
||||
|
||||
public static function getRandAttr($initMeta, $nextMeta, $oldAttr, &$newAttr)
|
||||
public static function addRandAttr($levelMeta, &$attrs)
|
||||
{
|
||||
$initAttr = mt\AttrHelper::parseAttrCfg($initMeta['rand_attrs']);
|
||||
$nextAttr = mt\AttrHelper::parseAttrCfg($next['rand_attrs']);
|
||||
if (!mt\AttrHelper::canMergeCfg($initAttr, $nextAttr)) {
|
||||
return false;
|
||||
$attrArr = StrHelper::parseList($levelMeta['rand_attrs'], array('|', ':'));
|
||||
foreach ($attrArr as $tuple) {
|
||||
$attrId = $tuple[0];
|
||||
$type = $tuple[1];
|
||||
$val = rand($tuple[2], $tuple[3]);
|
||||
foreach ($attrs as &$attr) {
|
||||
if ($attr['attr_id'] == $attrId &&
|
||||
$attr['type'] == $type) {
|
||||
$attr['val'] += $val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
mt\AttrHelper::randAttr($newMeta, $newAttr);
|
||||
mt\AttrHelper::mergeAttr($oldAttr, $newAttr);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user