From 421acd9abe9f3a1d854b957634462e67413096e5 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sun, 8 May 2022 13:35:35 +0800 Subject: [PATCH] 1 --- webapp/mt/AttrHelper.php | 28 +++++++++++++++++++++++++++ webapp/services/BattleDataService.php | 16 ++++++++++++--- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/webapp/mt/AttrHelper.php b/webapp/mt/AttrHelper.php index 0476bf11..8651add9 100644 --- a/webapp/mt/AttrHelper.php +++ b/webapp/mt/AttrHelper.php @@ -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; + } + } diff --git a/webapp/services/BattleDataService.php b/webapp/services/BattleDataService.php index a3cf0d17..f6acbfc6 100644 --- a/webapp/services/BattleDataService.php +++ b/webapp/services/BattleDataService.php @@ -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'],