1
This commit is contained in:
parent
946f0f0fe9
commit
dc3c40a98d
@ -124,6 +124,7 @@ class Hero(object):
|
||||
'url': 'webapp/index.php?c=Hero&a=receive',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['type', 0, '1:领取升级 2:领取升阶'],
|
||||
['hero_uniid', 0, '英雄唯一id'],
|
||||
],
|
||||
'response': [
|
||||
|
@ -68,3 +68,6 @@ const kHAT_ABS_VAL = 1;
|
||||
const kHAT_RATE_VAL = 2;
|
||||
|
||||
const kWantedLockType = 3;
|
||||
|
||||
const kMaxHeroUpLevelNum = 2;
|
||||
const kMaxHeroUpQualityNum = 4;
|
||||
|
@ -90,7 +90,7 @@ class HeroController extends BaseAuthedController {
|
||||
public function getUpgradeLevelList()
|
||||
{
|
||||
$infos = array();
|
||||
for ($i = 0; $i <= 1; ++$i) {
|
||||
for ($i = 0; $i < kMaxHeroUpLevelNum; ++$i) {
|
||||
$heroUniId = $this->_getV(TN_HERO_LEVEL_UP, $i);
|
||||
$info = null;
|
||||
if ($heroUniId) {
|
||||
@ -99,7 +99,7 @@ class HeroController extends BaseAuthedController {
|
||||
$heroDto = Hero::toDto($heroDb);
|
||||
$info = array(
|
||||
'info' => $heroDto,
|
||||
'countdown' => 0
|
||||
'countdown' => $heroDto['unlock_lefttime']
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -123,6 +123,80 @@ class HeroController extends BaseAuthedController {
|
||||
|
||||
public function receive()
|
||||
{
|
||||
$type = getReqVal('type', 0);
|
||||
$heroUniId = getReqVal('hero_uniid', 0);
|
||||
$heroDb = Hero::find($heroUniId);
|
||||
if (!$heroDb) {
|
||||
$this->_rspErr(1, 'hero does not exist');
|
||||
return;
|
||||
}
|
||||
$heroDto = Hero::toDto($heroDb);
|
||||
if ($heroDto['unlock_lefttime'] > 0) {
|
||||
$this->_rspErr(1, 'Countdown is not over');
|
||||
return;
|
||||
}
|
||||
switch ($type) {
|
||||
case 1:
|
||||
{
|
||||
$idx = 0;
|
||||
$found = false;
|
||||
for ($i = 0; $i < kMaxHeroUpLevelNum; ++$i) {
|
||||
$upHeroUniId = $this->_getV(TN_HERO_LEVEL_UP, $i);
|
||||
if ($upHeroUniId == $heroUniId) {
|
||||
$idx = $i;
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$found) {
|
||||
$this->_rspErr(1, 'hero does not exist');
|
||||
return;
|
||||
}
|
||||
$this->_setV(TN_HERO_LEVEL_UP, $idx, 0);
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
$propertyChgService->addHeroChg();
|
||||
$propertyChgService->addBagChg();
|
||||
$propertyChgService->addUserChg();
|
||||
$rankActivityService = new service\RankActivityService();
|
||||
$rankActivityService->heroUpgradeLevel($heroDb['hero_lv'] + 1);
|
||||
$this->_rspData(array(
|
||||
'property_chg' => $propertyChgService->toDto(),
|
||||
));
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
$idx = 0;
|
||||
$found = false;
|
||||
for ($i = 0; $i < kMaxHeroUpQualityNum; ++$i) {
|
||||
$upHeroUniId = $this->_getV(TN_HERO_QUALITY_UP, $i);
|
||||
if ($upHeroUniId == $heroUniId) {
|
||||
$idx = $i;
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$found) {
|
||||
$this->_rspErr(1, 'hero does not exist');
|
||||
return;
|
||||
}
|
||||
$this->_setV(TN_HERO_QUALITY_UP, $idx, 0);
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
$propertyChgService->addHeroChg();
|
||||
$propertyChgService->addBagChg();
|
||||
$propertyChgService->addUserChg();
|
||||
$this->_rspData(array(
|
||||
'property_chg' => $propertyChgService->toDto(),
|
||||
));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
$this->_rspErr(1, 'type parameter error');
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
/*
|
||||
$baseAttrs = mt\Hero::getHeroAttr($heroMeta);
|
||||
mt\AttrHelper::mergeAttr($baseAttrs, Bag::getAttrs());
|
||||
@ -347,17 +421,14 @@ class HeroController extends BaseAuthedController {
|
||||
Hero::update($heroUniId,
|
||||
array(
|
||||
'hero_lv' => $heroDb['hero_lv'],
|
||||
'quality' => $heroDb['quality'] + 1,
|
||||
'rand_attr' => json_encode($attrs),
|
||||
'lock_type' => Gun::QUALITY_LOCK,
|
||||
'unlock_time' => $this->_getNowTime() + $currQualityMeta['time'],
|
||||
'unlock_trade_time' => $this->_getNowTime() + $currQualityMeta['time'] + mt\Parameter::getVal('hero_lock_transaction_time', 0)
|
||||
)
|
||||
);
|
||||
$rankActivityService = new services\RankActivityService();
|
||||
$rankActivityService->heroUpgradeQuality($heroDb['quality'] + 1);
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
$propertyChgService->addHeroChg();
|
||||
$propertyChgService->addBagChg();
|
||||
$propertyChgService->addUserChg();
|
||||
$this->_rspData(array(
|
||||
'property_chg' => $propertyChgService->toDto(),
|
||||
));
|
||||
|
Loading…
x
Reference in New Issue
Block a user