From c19b4a1fb61e8a0e16c9351b2ac7e19684176ead Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 19 Sep 2022 19:36:49 +0800 Subject: [PATCH] 1 --- webapp/services/BattleDataService.php | 88 ++++++++++++++------------- 1 file changed, 47 insertions(+), 41 deletions(-) diff --git a/webapp/services/BattleDataService.php b/webapp/services/BattleDataService.php index e2ed29c6..2ff45541 100644 --- a/webapp/services/BattleDataService.php +++ b/webapp/services/BattleDataService.php @@ -39,6 +39,8 @@ use services\FormulaService; class BattleDataService extends BaseService { + const MAX_DROP_NUM = 2; + private $seasonDb = array(); private $heroDto = null; private $heroMeta = null; @@ -488,54 +490,33 @@ class BattleDataService extends BaseService { private function rewardFragmentPvp() { - $todayPvpBattleTimes = $this->_getDailyV(TN_DAILY_PVP_BATTLE_TIMES, 0); $todayPveGetFragmentNum = $this->_getDailyV(TN_DAILY_PVE_GET_FRAGMENT_NUM, 0); $todayPvpGetFragmentNum = $this->_getDailyV(TN_DAILY_PVP_GET_FRAGMENT_NUM, 0); - if ($todayPveGetFragmentNum + $todayPvpGetFragmentNum > 2) { - return; - } + if ($todayPveGetFragmentNum + $todayPvpGetFragmentNum < self::MAX_DROP_NUM) { + $todayPvpBattleTimes = $this->_getDailyV(TN_DAILY_PVP_BATTLE_TIMES, 0); - $onlineNum = RealtimeData::getOnline(); - $heroFragmentNum = FragmentPool::getHeroNum(); - $gunFragmentNum = FragmentPool::getGunNum(); + $onlineNum = RealtimeData::getOnline(); + $heroFragmentNum = FragmentPool::getHeroNum(); + $gunFragmentNum = FragmentPool::getGunNum(); - $heroProbability = FormulaService::calcHeroFragmentProbabilityPvp - ($_REQUEST, - $onlineNum, - $heroFragmentNum, - $todayPvpBattleTimes); - $gunProbability = FormulaService::calcGunFragmentProbabilityPvp - ($_REQUEST, - $onlineNum, - $gunFragmentNum, - $todayPvpBattleTimes); + $heroProbability = FormulaService::calcHeroFragmentProbabilityPvp + ($_REQUEST, + $onlineNum, + $heroFragmentNum, + $todayPvpBattleTimes); + $gunProbability = FormulaService::calcGunFragmentProbabilityPvp + ($_REQUEST, + $onlineNum, + $gunFragmentNum, + $todayPvpBattleTimes); - $heroProbability = max($heroProbability, 0); - $gunProbability = max($gunProbability, 0); - $emptyProbability = max(1 - $heroProbability - $gunProbability, 0); + $heroProbability = max($heroProbability, 0); + $gunProbability = max($gunProbability, 0); + $emptyProbability = max(1 - $heroProbability - $gunProbability, 0); - $dropIdx = $this->randWeight(array($heroProbability, $gunProbability, $emptyProbability)); - if ($dropIdx == 0) { - $itemId = FragmentPool::dropHero(); - if ($itemId) { - array_push($this->reward['items'], - array( - 'item_id' => $itemId, - 'item_num' => 1 - )); - $this->_incDailyV(TN_DAILY_PVP_GET_FRAGMENT_NUM, 1); - } - } else if ($dropIdx == 1) { - $itemId = FragmentPool::dropGun(); - if ($itemId) { - array_push($this->reward['items'], - array( - 'item_id' => $itemId, - 'item_num' => 1 - )); - $this->_incDailyV(TN_DAILY_PVP_GET_FRAGMENT_NUM, 1); - } + $dropIdx = $this->randWeight(array($heroProbability, $gunProbability, $emptyProbability)); + $this->procDrop($dropIdx); } } @@ -743,4 +724,29 @@ class BattleDataService extends BaseService { } } + private function procDrop($dropIdx) + { + if ($dropIdx == 0) { + $itemId = FragmentPool::dropHero(); + if ($itemId) { + array_push($this->reward['items'], + array( + 'item_id' => $itemId, + 'item_num' => 1 + )); + $this->_incDailyV(TN_DAILY_PVP_GET_FRAGMENT_NUM, 1); + } + } else if ($dropIdx == 1) { + $itemId = FragmentPool::dropGun(); + if ($itemId) { + array_push($this->reward['items'], + array( + 'item_id' => $itemId, + 'item_num' => 1 + )); + $this->_incDailyV(TN_DAILY_PVP_GET_FRAGMENT_NUM, 1); + } + } + } + }