This commit is contained in:
aozhiwei 2022-05-08 13:35:35 +08:00
parent 39dbbaa7e2
commit 421acd9abe
2 changed files with 41 additions and 3 deletions

View File

@ -66,4 +66,32 @@ class AttrHelper {
}
}
public static function getAbsVal($randAttr, $attrId)
{
if (!$randAttr) {
return null;
}
foreach ($randAttr as $attr){
if ($attr['attr_id'] == $attrId &&
$attr['type'] == kHAT_ABS_VAL) {
return $attr;
}
}
return null;
}
public static function getRateVal($randAttr, $attrId)
{
if (!$randAttr) {
return null;
}
foreach ($randAttr as $attr){
if ($attr['attr_id'] == $attrId &&
$attr['type'] == kHAT_RATE_VAL) {
return $attr;
}
}
return null;
}
}

View File

@ -10,6 +10,7 @@ require_once('mt/RankReward.php');
require_once('mt/KillReward.php');
require_once('mt/Parameter.php');
require_once('mt/HeroQuality.php');
require_once('mt/AttrHelper.php');
require_once('models/Season.php');
require_once('models/Battle.php');
@ -340,8 +341,13 @@ class BattleDataService extends BaseService {
private function rewardGold($heroDb)
{
$heroMeta = mt\Item::get($heroDb['hero_id']);
if (!$heroMeta) {
return;
}
$killMeta = mt\KillReward::get(getReqVal('kills', 0));
$rankMeta = mt\RankReward::get(getReqVal('ranked', 0));
$gold = 0;
$gold += $killMeta ? $killMeta['parameter'] : 0;
$gold += $rankMeta ? $rankMeta['parameter'] : 0;
$addGold = 0;
@ -352,9 +358,13 @@ class BattleDataService extends BaseService {
$heroQualityMeta = mt\HeroQuality::getByQuality($heroDb['quality']);
if ($heroQualityMeta) {
$goldLimit = $heroMeta['gold_limit'];
$attr = getXVal($heroDb['attr'], kHAT_LUCKY, null);
if ($attr && $attr['type'] == 1) {
$goldLimit += $attr['val'];
$randAttr = emptyReplace(json_decode($row['rand_attr'], true),
array());
if ($randAttr) {
$attr = mt\AttrHelper::getAbsVal($randAttr, kHAT_LUCKY);
if ($attr) {
$goldLimit += $attr['val'];
}
}
$newGold = min($goldLimit, $heroDb['today_get_gold'] + $addGold);
Hero::update($heroDb['hero_uniid'],