From 68481fc610767e44c0e72a833dac8a735097df7c Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 19 Sep 2022 17:35:58 +0800 Subject: [PATCH 01/16] 1 --- webapp/models/FragmentPool.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/webapp/models/FragmentPool.php b/webapp/models/FragmentPool.php index 7e4599cd..7afbb456 100644 --- a/webapp/models/FragmentPool.php +++ b/webapp/models/FragmentPool.php @@ -9,12 +9,14 @@ class FragmentPool extends BaseModel { public static function dropHero() { + $allocTime = myself()->_getNowDaySeconds() + + intval((myself()->_getNowTime() - myself()->_getNowDaySeconds()) / 3600) * 3600; $rows = SqlHelper::ormSelect (myself()->_getMysql($targetId), 't_fragment_pool', array( 'fragment_type' => 0, - 'alloc_time' => 0, + 'alloc_time' => $allocTime, ) ); if ($rows) { From 5aeb8b691bc73695c3405533a42bdb251a826b6a Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 19 Sep 2022 17:38:51 +0800 Subject: [PATCH 02/16] 1 --- webapp/models/FragmentPool.php | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/webapp/models/FragmentPool.php b/webapp/models/FragmentPool.php index 7afbb456..edf62d89 100644 --- a/webapp/models/FragmentPool.php +++ b/webapp/models/FragmentPool.php @@ -9,20 +9,6 @@ class FragmentPool extends BaseModel { public static function dropHero() { - $allocTime = myself()->_getNowDaySeconds() + - intval((myself()->_getNowTime() - myself()->_getNowDaySeconds()) / 3600) * 3600; - $rows = SqlHelper::ormSelect - (myself()->_getMysql($targetId), - 't_fragment_pool', - array( - 'fragment_type' => 0, - 'alloc_time' => $allocTime, - ) - ); - if ($rows) { - - } - return null; } public static function dropGun() @@ -30,4 +16,19 @@ class FragmentPool extends BaseModel { } + private static function internalGet($type) + { + $allocTime = myself()->_getNowDaySeconds() + + intval((myself()->_getNowTime() - myself()->_getNowDaySeconds()) / 3600) * 3600; + $rows = SqlHelper::ormSelect + (myself()->_getMysql($targetId), + 't_fragment_pool', + array( + 'fragment_type' => $type, + 'alloc_time' => $allocTime, + ) + ); + return $rows ? $rows : array(); + } + } From ed3db8ad4fea2dab9f7f4c44e50cdc8b9ba5f7a8 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 19 Sep 2022 17:40:48 +0800 Subject: [PATCH 03/16] 1 --- webapp/models/FragmentPool.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webapp/models/FragmentPool.php b/webapp/models/FragmentPool.php index edf62d89..4dcb9464 100644 --- a/webapp/models/FragmentPool.php +++ b/webapp/models/FragmentPool.php @@ -9,11 +9,12 @@ class FragmentPool extends BaseModel { public static function dropHero() { + $items = self::internalGet(0); } public static function dropGun() { - + $items = self::internalGet(1); } private static function internalGet($type) From 9bbce806332448f939b3a5eb4d9156cbfe303a08 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 19 Sep 2022 18:22:16 +0800 Subject: [PATCH 04/16] 1 --- webapp/models/FragmentPool.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/webapp/models/FragmentPool.php b/webapp/models/FragmentPool.php index 4dcb9464..e499c24a 100644 --- a/webapp/models/FragmentPool.php +++ b/webapp/models/FragmentPool.php @@ -29,7 +29,15 @@ class FragmentPool extends BaseModel { 'alloc_time' => $allocTime, ) ); - return $rows ? $rows : array(); + $items = array(); + if ($rows) { + foreach ($rows as $row) { + if ($row['fragment_num'] > 0) { + array_push($items, $row); + } + } + } + return $items; } } From 74da8ff34de181a68aa092abe5546304c571834d Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 19 Sep 2022 18:55:00 +0800 Subject: [PATCH 05/16] 1 --- webapp/models/FragmentPool.php | 42 +++++++++++++++++++++++++-- webapp/services/BattleDataService.php | 1 + 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/webapp/models/FragmentPool.php b/webapp/models/FragmentPool.php index e499c24a..68292c93 100644 --- a/webapp/models/FragmentPool.php +++ b/webapp/models/FragmentPool.php @@ -10,17 +10,30 @@ class FragmentPool extends BaseModel { public static function dropHero() { $items = self::internalGet(0); + if (count($items)) { + $idx = array_rand($items, 1); + $fragmentId = $items[$idx]['fragment_id']; + self::decNum($fragmentId); + return $fragmentId; + } + return 0; } public static function dropGun() { $items = self::internalGet(1); + if (count($items)) { + $idx = array_rand($items, 1); + $fragmentId = $items[$idx]['fragment_id']; + self::decNum($fragmentId); + return $fragmentId; + } + return 0; } private static function internalGet($type) { - $allocTime = myself()->_getNowDaySeconds() + - intval((myself()->_getNowTime() - myself()->_getNowDaySeconds()) / 3600) * 3600; + $allocTime = self::getAllocTime(); $rows = SqlHelper::ormSelect (myself()->_getMysql($targetId), 't_fragment_pool', @@ -40,4 +53,29 @@ class FragmentPool extends BaseModel { return $items; } + private static function decNum($itemId) + { + $allocTime = self::getAllocTime(); + SqlHelper::update + (myself()->_getMysql($targetId), + 't_fragment_pool', + array( + 'fragment_id' => $itemId, + 'alloc_time' => $allocTime, + ), + array( + 'fragment_num' => function () { + return 'GREATEST(0, fragment_num - 1)'; + }, + ) + ); + } + + private static function getAllocTime() + { + $allocTime = myself()->_getNowDaySeconds() + + intval((myself()->_getNowTime() - myself()->_getNowDaySeconds()) / 3600) * 3600; + return $allocTime; + } + } diff --git a/webapp/services/BattleDataService.php b/webapp/services/BattleDataService.php index 7baa4843..fc2a73a3 100644 --- a/webapp/services/BattleDataService.php +++ b/webapp/services/BattleDataService.php @@ -34,6 +34,7 @@ use models\Bag; use models\Hero; use models\Gun; use models\RealtimeData; +use models\FragmentPool; use services\FormulaService; class BattleDataService extends BaseService { From 3a8b989fb4467134b5aeac074931ed45fb604bbf Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 19 Sep 2022 18:57:51 +0800 Subject: [PATCH 06/16] 1 --- webapp/models/FragmentPool.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/webapp/models/FragmentPool.php b/webapp/models/FragmentPool.php index 68292c93..be0368a4 100644 --- a/webapp/models/FragmentPool.php +++ b/webapp/models/FragmentPool.php @@ -31,6 +31,26 @@ class FragmentPool extends BaseModel { return 0; } + public static function getHeroNum() + { + $items = self::internalGet(0); + $num = 0; + foreach ($items as $item) { + $num += $item['fragment_num']; + } + return $num; + } + + public static function getGunNum() + { + $items = self::internalGet(1); + $num = 0; + foreach ($items as $item) { + $num += $item['fragment_num']; + } + return $num; + } + private static function internalGet($type) { $allocTime = self::getAllocTime(); From 37c759ac4ac58a29cc225c50c4a7c54ea98b26a8 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 19 Sep 2022 19:03:59 +0800 Subject: [PATCH 07/16] 1 --- webapp/services/BattleDataService.php | 44 ++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/webapp/services/BattleDataService.php b/webapp/services/BattleDataService.php index fc2a73a3..8e359ea0 100644 --- a/webapp/services/BattleDataService.php +++ b/webapp/services/BattleDataService.php @@ -532,7 +532,27 @@ class BattleDataService extends BaseService { return; } - + 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); + } + } } private function rewardFragmentPve() @@ -569,6 +589,28 @@ class BattleDataService extends BaseService { return; } + if ($dropIdx == 0) { + $itemId = FragmentPool::dropHero(); + if ($itemId) { + array_push($this->reward['items'], + array( + 'item_id' => $itemId, + 'item_num' => 1 + )); + $this->_incDailyV(TN_DAILY_PVE_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_PVE_GET_FRAGMENT_NUM, 1); + } + } + } private function rewardCegPvp() From 4d7637e575d403197068bb86119ccb1ce67723a0 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 19 Sep 2022 19:11:33 +0800 Subject: [PATCH 08/16] 1 --- webapp/services/BattleDataService.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/webapp/services/BattleDataService.php b/webapp/services/BattleDataService.php index 8e359ea0..2a521e31 100644 --- a/webapp/services/BattleDataService.php +++ b/webapp/services/BattleDataService.php @@ -497,6 +497,8 @@ class BattleDataService extends BaseService { } $onlineNum = RealtimeData::getOnline(); + $heroFragmentNum = FragmentPool::getHeroNum(); + $gunFragmentNum = FragmentPool::getGunNum(); $rankedTopX= getXVal($params, 'ranked_topx'); $meta = mt\FormulaPvp::getByRanked($rankedTopX); @@ -504,7 +506,7 @@ class BattleDataService extends BaseService { return; } - $heroProbability = min($heroFragment[$now].total / $onlineNum * + $heroProbability = min($heroFragmentNum / $onlineNum * 5 * ( 0.5*$meta['ranked_topx'] + @@ -513,7 +515,7 @@ class BattleDataService extends BaseService { 0.05*$meta['weapon_topx'] ) * pow(2, ($todayPvpBattleTimes % 10) - 1), 1); - $gunProbability = min($gunFragment[$now].total / $onlineNum * + $gunProbability = min($gunFragmentNum / $onlineNum * 5 * ( 0.5*$meta['ranked_topx'] + @@ -568,6 +570,9 @@ class BattleDataService extends BaseService { } $onlineNum = RealtimeData::getOnline(); + $heroFragmentNum = FragmentPool::getHeroNum(); + $gunFragmentNum = FragmentPool::getGunNum(); + $instanceLevel = $this->pveGeminiMeta['gemini_lv']; $instanceRank = $this->instanceRank; $instanceRankRate = $this->getInstanceRankRate(); @@ -577,8 +582,12 @@ class BattleDataService extends BaseService { $dropRate = max(1.15 - ($heroQuality - $instanceLevel) * 0.25, 0); $dropMul = 0.8 - ($instanceRank - 1) * 0.25 + $bossReward * 0.2; - $heroProbability = min($heroFragment[$now].total / $onlineNum * $dropRate * ($instanceRankRate + $bossReward*0.2) * pow(2, $todayPveBattleTimes - $todayPveGetFragmentNum -1), 1); - $gunProbability = min($gunFragment[$now].total / $onlineNum * $dropRate * ($instanceRankRate + $bossReward*0.2) * pow(2, $todayPveBattleTimes - $todayPveGetFragmentNum -1), 1); + $heroProbability = min($heroFragmentNum / $onlineNum * + $dropRate * ($instanceRankRate + $bossReward*0.2) * + pow(2, $todayPveBattleTimes - $todayPveGetFragmentNum -1), 1); + $gunProbability = min($gunFragmentNum / $onlineNum * + $dropRate * ($instanceRankRate + $bossReward*0.2) * + pow(2, $todayPveBattleTimes - $todayPveGetFragmentNum -1), 1); $heroProbability = max($heroProbability, 0); $gunProbability = max($gunProbability, 0); From 43a916c235aa6da0e75eb60baa19120bdf6918c6 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 19 Sep 2022 19:33:12 +0800 Subject: [PATCH 09/16] 1 --- webapp/services/BattleDataService.php | 38 ++++++-------------- webapp/services/FormulaService.php | 52 ++++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 29 deletions(-) diff --git a/webapp/services/BattleDataService.php b/webapp/services/BattleDataService.php index 2a521e31..e2ed29c6 100644 --- a/webapp/services/BattleDataService.php +++ b/webapp/services/BattleDataService.php @@ -500,40 +500,22 @@ class BattleDataService extends BaseService { $heroFragmentNum = FragmentPool::getHeroNum(); $gunFragmentNum = FragmentPool::getGunNum(); - $rankedTopX= getXVal($params, 'ranked_topx'); - $meta = mt\FormulaPvp::getByRanked($rankedTopX); - if (!$meta) { - return; - } - - $heroProbability = min($heroFragmentNum / $onlineNum * - 5 * - ( - 0.5*$meta['ranked_topx'] + - 0.25*$meta['kills_topx'] + - 0.15*$meta['hero_topx'] + - 0.05*$meta['weapon_topx'] - ) * - pow(2, ($todayPvpBattleTimes % 10) - 1), 1); - $gunProbability = min($gunFragmentNum / $onlineNum * - 5 * - ( - 0.5*$meta['ranked_topx'] + - 0.25*$meta['kills_topx'] + - 0.15*$meta['hero_topx'] + - 0.05*$meta['weapon_topx'] - ) * - pow(2, ($todayPvpBattleTimes % 10) - 1), 1); + $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); $dropIdx = $this->randWeight(array($heroProbability, $gunProbability, $emptyProbability)); - if ($dropIdx < 0 || $dropIdx == 2) { - return; - } - if ($dropIdx == 0) { $itemId = FragmentPool::dropHero(); if ($itemId) { diff --git a/webapp/services/FormulaService.php b/webapp/services/FormulaService.php index e02b889c..8fc161f5 100644 --- a/webapp/services/FormulaService.php +++ b/webapp/services/FormulaService.php @@ -20,7 +20,7 @@ class FormulaService extends BaseService { $kills = getXVal($params, 'kills'); $aliveTime = getXVal($params, 'alive_time'); - $rankedTopX= getXVal($params, 'ranked_topx'); + $rankedTopX = getXVal($params, 'ranked_topx'); $killsTopX = getXVal($params, 'kills_topx'); $heroTopX = getXVal($params, 'hero_topx'); $weaponTopX = getXVal($params, 'weapon_topx'); @@ -96,6 +96,56 @@ class FormulaService extends BaseService { return round(ceg); } + public static function calcHeroFragmentProbabilityPvp($params, + $onlineNum, + $heroFragmentNum, + $todayPvpBattleTimes) + { + $rankedTopX = getXVal($params, 'ranked_topx'); + $killsTopX = getXVal($params, 'kills_topx'); + $heroTopX = getXVal($params, 'hero_topx'); + $weaponTopX = getXVal($params, 'weapon_topx'); + $meta = mt\FormulaPvp::getByRanked($rankedTopX); + if (!$meta) { + return 0; + } + $heroProbability = min($heroFragmentNum / $onlineNum * + 5 * + ( + 0.5 * $rankedTopX * $meta['ranked_topx'] + + 0.25 * $killsTopX * $meta['kills_topx'] + + 0.15 * $heroTopX * $meta['hero_topx'] + + 0.05 * $weaponTopX * $meta['weapon_topx'] + ) * + pow(2, ($todayPvpBattleTimes % 10) - 1), 1); + return $heroProbability; + } + + public static function calcWeaponFragmentProbabilityPvp($params, + $onlineNum, + $weaponFragmentNum, + $todayPvpBattleTimes) + { + $rankedTopX = getXVal($params, 'ranked_topx'); + $killsTopX = getXVal($params, 'kills_topx'); + $heroTopX = getXVal($params, 'hero_topx'); + $weaponTopX = getXVal($params, 'weapon_topx'); + $meta = mt\FormulaPvp::getByRanked($rankedTopX); + if (!$meta) { + return 0; + } + $weaponProbability = min($FragmentNum / $onlineNum * + 5 * + ( + 0.5 * $rankedTopX * $meta['ranked_topx'] + + 0.25 * $killsTopX * $meta['kills_topx'] + + 0.15 * $heroTopX * $meta['hero_topx'] + + 0.05 * $weaponTopX * $meta['weapon_topx'] + ) * + pow(2, ($todayPvpBattleTimes % 10) - 1), 1); + return $weaponProbability; + } + public static function getHeroPvpTiliTotalValue($heroDb) { //ROUND((0.0241*角色NFT阶数^3-0.5675*角色NFT阶数^2+7.1798*角色NFT阶数+2.4114)+(0.0161*角色幸运值^3-1.2943*角色幸运值^2+36.5664*角色幸运值-336.144),0)+系统参数 From c19b4a1fb61e8a0e16c9351b2ac7e19684176ead Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 19 Sep 2022 19:36:49 +0800 Subject: [PATCH 10/16] 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); + } + } + } + } From 55846eabd3232c882f03982c972159ff3998b458 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 19 Sep 2022 19:38:16 +0800 Subject: [PATCH 11/16] 1 --- webapp/services/BattleDataService.php | 83 +++++++++------------------ 1 file changed, 27 insertions(+), 56 deletions(-) diff --git a/webapp/services/BattleDataService.php b/webapp/services/BattleDataService.php index 2ff45541..690053f3 100644 --- a/webapp/services/BattleDataService.php +++ b/webapp/services/BattleDataService.php @@ -522,67 +522,38 @@ class BattleDataService extends BaseService { private function rewardFragmentPve() { - $pveRankScore = getReqVal('pve_rank_score', 0); - $todayPveBattleTimes = $this->_getDailyV(TN_DAILY_PVE_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) { + $onlineNum = RealtimeData::getOnline(); + $heroFragmentNum = FragmentPool::getHeroNum(); + $gunFragmentNum = FragmentPool::getGunNum(); + + $instanceLevel = $this->pveGeminiMeta['gemini_lv']; + $instanceRank = $this->instanceRank; + $instanceRankRate = $this->getInstanceRankRate(); + $bossReward = getReqVal('pve_kill_boss', 0) ? 1 : 0; + $heroQuality = $this->heroDto['quality']; + + $dropRate = max(1.15 - ($heroQuality - $instanceLevel) * 0.25, 0); + $dropMul = 0.8 - ($instanceRank - 1) * 0.25 + $bossReward * 0.2; + + $heroProbability = min($heroFragmentNum / $onlineNum * + $dropRate * ($instanceRankRate + $bossReward*0.2) * + pow(2, $todayPveBattleTimes - $todayPveGetFragmentNum -1), 1); + $gunProbability = min($gunFragmentNum / $onlineNum * + $dropRate * ($instanceRankRate + $bossReward*0.2) * + pow(2, $todayPveBattleTimes - $todayPveGetFragmentNum -1), 1); + + $heroProbability = max($heroProbability, 0); + $gunProbability = max($gunProbability, 0); + $emptyProbability = max(1 - $heroProbability - $gunProbability, 0); + + $dropIdx = $this->randWeight(array($heroProbability, $gunProbability, $emptyProbability)); + $this->procDrop($dropIdx); } - - $onlineNum = RealtimeData::getOnline(); - $heroFragmentNum = FragmentPool::getHeroNum(); - $gunFragmentNum = FragmentPool::getGunNum(); - - $instanceLevel = $this->pveGeminiMeta['gemini_lv']; - $instanceRank = $this->instanceRank; - $instanceRankRate = $this->getInstanceRankRate(); - $bossReward = getReqVal('pve_kill_boss', 0) ? 1 : 0; - $heroQuality = $this->heroDto['quality']; - - $dropRate = max(1.15 - ($heroQuality - $instanceLevel) * 0.25, 0); - $dropMul = 0.8 - ($instanceRank - 1) * 0.25 + $bossReward * 0.2; - - $heroProbability = min($heroFragmentNum / $onlineNum * - $dropRate * ($instanceRankRate + $bossReward*0.2) * - pow(2, $todayPveBattleTimes - $todayPveGetFragmentNum -1), 1); - $gunProbability = min($gunFragmentNum / $onlineNum * - $dropRate * ($instanceRankRate + $bossReward*0.2) * - pow(2, $todayPveBattleTimes - $todayPveGetFragmentNum -1), 1); - - $heroProbability = max($heroProbability, 0); - $gunProbability = max($gunProbability, 0); - $emptyProbability = max(1 - $heroProbability - $gunProbability, 0); - - $dropIdx = $this->randWeight(array($heroProbability, $gunProbability, $emptyProbability)); - if ($dropIdx < 0 || $dropIdx == 2) { - return; - } - - if ($dropIdx == 0) { - $itemId = FragmentPool::dropHero(); - if ($itemId) { - array_push($this->reward['items'], - array( - 'item_id' => $itemId, - 'item_num' => 1 - )); - $this->_incDailyV(TN_DAILY_PVE_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_PVE_GET_FRAGMENT_NUM, 1); - } - } - } private function rewardCegPvp() From 0ded0384afa1da6de1e7e0e74d63b4eaa3dc8409 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 19 Sep 2022 19:42:32 +0800 Subject: [PATCH 12/16] 1 --- webapp/services/BattleDataService.php | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/webapp/services/BattleDataService.php b/webapp/services/BattleDataService.php index 690053f3..5926e539 100644 --- a/webapp/services/BattleDataService.php +++ b/webapp/services/BattleDataService.php @@ -41,6 +41,10 @@ class BattleDataService extends BaseService { const MAX_DROP_NUM = 2; + const MATCH_MODE_PVP = 0; + const MATCH_MODE_MATCH = 1; + const MATCH_MODE_PVE = 2; + private $seasonDb = array(); private $heroDto = null; private $heroMeta = null; @@ -82,7 +86,8 @@ class BattleDataService extends BaseService { return false; } $this->reward['hero']['hero_uniid'] = $this->heroDto['hero_uniid']; - $this->reward['hero']['ceg_uplimit'] = $matchMode == 2 ? $this->heroDto['pve_ceg_uplimit'] : $this->heroDto['pvp_ceg_uplimit']; + $this->reward['hero']['ceg_uplimit'] = $matchMode == self::MATCH_MODE_PVE ? + $this->heroDto['pve_ceg_uplimit'] : $this->heroDto['pvp_ceg_uplimit']; } { $weaponUuid1 = getReqVal('weapon_uuid1', ''); @@ -93,7 +98,8 @@ class BattleDataService extends BaseService { } $this->weapon1Dto = Gun::toDto($weaponDb); $this->reward['weapon1']['gun_uniid'] = $this->weapon1Dto['gun_uniid']; - $this->reward['weapon1']['ceg_uplimit'] = $matchMode == 2 ? $this->weapon1Dto['pve_ceg_uplimit'] : $this->weapon1Dto['pvp_ceg_uplimit']; + $this->reward['weapon1']['ceg_uplimit'] = $matchMode == self::MATCH_MODE_PVE ? + $this->weapon1Dto['pve_ceg_uplimit'] : $this->weapon1Dto['pvp_ceg_uplimit']; } } { @@ -105,7 +111,8 @@ class BattleDataService extends BaseService { } $this->weapon2Dto = Gun::toDto($weaponDb); $this->reward['weapon2']['gun_uniid'] = $this->weapon2Dto['gun_uniid']; - $this->reward['weapon2']['ceg_uplimit'] = $matchMode == 2 ? $this->weapon2Dto['pve_ceg_uplimit'] : $this->weapon2Dto['pvp_ceg_uplimit']; + $this->reward['weapon2']['ceg_uplimit'] = $matchMode == self::MATCH_MODE_PVE ? + $this->weapon2Dto['pve_ceg_uplimit'] : $this->weapon2Dto['pvp_ceg_uplimit']; } } switch ($matchMode) { @@ -697,6 +704,7 @@ class BattleDataService extends BaseService { private function procDrop($dropIdx) { + $matchMode = getReqVal('match_mode'); if ($dropIdx == 0) { $itemId = FragmentPool::dropHero(); if ($itemId) { @@ -705,7 +713,11 @@ class BattleDataService extends BaseService { 'item_id' => $itemId, 'item_num' => 1 )); - $this->_incDailyV(TN_DAILY_PVP_GET_FRAGMENT_NUM, 1); + if ($matchMode == self::MATCH_MODE_PVE) { + $this->_incDailyV(TN_DAILY_PVE_GET_FRAGMENT_NUM, 1); + } else { + $this->_incDailyV(TN_DAILY_PVP_GET_FRAGMENT_NUM, 1); + } } } else if ($dropIdx == 1) { $itemId = FragmentPool::dropGun(); @@ -715,7 +727,11 @@ class BattleDataService extends BaseService { 'item_id' => $itemId, 'item_num' => 1 )); - $this->_incDailyV(TN_DAILY_PVP_GET_FRAGMENT_NUM, 1); + if ($matchMode == self::MATCH_MODE_PVE) { + $this->_incDailyV(TN_DAILY_PVE_GET_FRAGMENT_NUM, 1); + } else { + $this->_incDailyV(TN_DAILY_PVP_GET_FRAGMENT_NUM, 1); + } } } } From a3fe93b04c59d24253caa5559f8dba4cf6210c9a Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 19 Sep 2022 19:45:57 +0800 Subject: [PATCH 13/16] 1 --- webapp/services/BattleDataService.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/webapp/services/BattleDataService.php b/webapp/services/BattleDataService.php index 5926e539..526b5714 100644 --- a/webapp/services/BattleDataService.php +++ b/webapp/services/BattleDataService.php @@ -116,7 +116,7 @@ class BattleDataService extends BaseService { } } switch ($matchMode) { - case 0: + case self::MATCH_MODE_PVP: { //匹配赛模式 $this->updatePvpData(); @@ -125,12 +125,12 @@ class BattleDataService extends BaseService { $this->_incDailyV(TN_DAILY_PVP_BATTLE_TIMES, 1); } break; - case 1: + case self::MATCH_MODE_MATCH: { //排位赛 } break; - case 2: + case self::MATCH_MODE_PVE: { //pve $this>updatePveData(); From 3d7a98c617d7c1347ac64701651bede821580922 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 19 Sep 2022 19:51:46 +0800 Subject: [PATCH 14/16] 1 --- webapp/services/BattleDataService.php | 3 --- webapp/services/FormulaService.php | 20 ++++++++++---------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/webapp/services/BattleDataService.php b/webapp/services/BattleDataService.php index 526b5714..76174ddc 100644 --- a/webapp/services/BattleDataService.php +++ b/webapp/services/BattleDataService.php @@ -517,9 +517,6 @@ class BattleDataService extends BaseService { $onlineNum, $gunFragmentNum, $todayPvpBattleTimes); - - $heroProbability = max($heroProbability, 0); - $gunProbability = max($gunProbability, 0); $emptyProbability = max(1 - $heroProbability - $gunProbability, 0); $dropIdx = $this->randWeight(array($heroProbability, $gunProbability, $emptyProbability)); diff --git a/webapp/services/FormulaService.php b/webapp/services/FormulaService.php index 8fc161f5..7d01a6cd 100644 --- a/webapp/services/FormulaService.php +++ b/webapp/services/FormulaService.php @@ -118,7 +118,7 @@ class FormulaService extends BaseService { 0.05 * $weaponTopX * $meta['weapon_topx'] ) * pow(2, ($todayPvpBattleTimes % 10) - 1), 1); - return $heroProbability; + return max(0, $heroProbability); } public static function calcWeaponFragmentProbabilityPvp($params, @@ -135,15 +135,15 @@ class FormulaService extends BaseService { return 0; } $weaponProbability = min($FragmentNum / $onlineNum * - 5 * - ( - 0.5 * $rankedTopX * $meta['ranked_topx'] + - 0.25 * $killsTopX * $meta['kills_topx'] + - 0.15 * $heroTopX * $meta['hero_topx'] + - 0.05 * $weaponTopX * $meta['weapon_topx'] - ) * - pow(2, ($todayPvpBattleTimes % 10) - 1), 1); - return $weaponProbability; + 5 * + ( + 0.5 * $rankedTopX * $meta['ranked_topx'] + + 0.25 * $killsTopX * $meta['kills_topx'] + + 0.15 * $heroTopX * $meta['hero_topx'] + + 0.05 * $weaponTopX * $meta['weapon_topx'] + ) * + pow(2, ($todayPvpBattleTimes % 10) - 1), 1); + return max(0, $weaponProbability); } public static function getHeroPvpTiliTotalValue($heroDb) From 7a94f56644c8f32ac9534e7925cb10404128ae78 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 19 Sep 2022 19:56:30 +0800 Subject: [PATCH 15/16] 1 --- webapp/services/FormulaService.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/webapp/services/FormulaService.php b/webapp/services/FormulaService.php index 7d01a6cd..b54e070f 100644 --- a/webapp/services/FormulaService.php +++ b/webapp/services/FormulaService.php @@ -105,6 +105,7 @@ class FormulaService extends BaseService { $killsTopX = getXVal($params, 'kills_topx'); $heroTopX = getXVal($params, 'hero_topx'); $weaponTopX = getXVal($params, 'weapon_topx'); + $survivalTopX = getXVal($params, 'survival_topx'); $meta = mt\FormulaPvp::getByRanked($rankedTopX); if (!$meta) { return 0; @@ -115,7 +116,8 @@ class FormulaService extends BaseService { 0.5 * $rankedTopX * $meta['ranked_topx'] + 0.25 * $killsTopX * $meta['kills_topx'] + 0.15 * $heroTopX * $meta['hero_topx'] + - 0.05 * $weaponTopX * $meta['weapon_topx'] + 0.05 * $weaponTopX * $meta['weapon_topx'] + + 0.05 * $survivalTopX * $meta['survival_topx'] ) * pow(2, ($todayPvpBattleTimes % 10) - 1), 1); return max(0, $heroProbability); @@ -130,6 +132,7 @@ class FormulaService extends BaseService { $killsTopX = getXVal($params, 'kills_topx'); $heroTopX = getXVal($params, 'hero_topx'); $weaponTopX = getXVal($params, 'weapon_topx'); + $survivalTopX = getXVal($params, 'survival_topx'); $meta = mt\FormulaPvp::getByRanked($rankedTopX); if (!$meta) { return 0; @@ -140,7 +143,8 @@ class FormulaService extends BaseService { 0.5 * $rankedTopX * $meta['ranked_topx'] + 0.25 * $killsTopX * $meta['kills_topx'] + 0.15 * $heroTopX * $meta['hero_topx'] + - 0.05 * $weaponTopX * $meta['weapon_topx'] + 0.05 * $weaponTopX * $meta['weapon_topx'] + + 0.05 * $survivalTopX * $meta['survival_topx'] ) * pow(2, ($todayPvpBattleTimes % 10) - 1), 1); return max(0, $weaponProbability); From 7635c820e7815678f9d1da25d801f9165161bcab Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 19 Sep 2022 20:08:11 +0800 Subject: [PATCH 16/16] 1 --- webapp/services/BattleDataService.php | 36 ++++++++++++++++--------- webapp/services/FormulaService.php | 38 +++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 12 deletions(-) diff --git a/webapp/services/BattleDataService.php b/webapp/services/BattleDataService.php index 76174ddc..b4efcfcf 100644 --- a/webapp/services/BattleDataService.php +++ b/webapp/services/BattleDataService.php @@ -541,18 +541,30 @@ class BattleDataService extends BaseService { $bossReward = getReqVal('pve_kill_boss', 0) ? 1 : 0; $heroQuality = $this->heroDto['quality']; - $dropRate = max(1.15 - ($heroQuality - $instanceLevel) * 0.25, 0); - $dropMul = 0.8 - ($instanceRank - 1) * 0.25 + $bossReward * 0.2; - - $heroProbability = min($heroFragmentNum / $onlineNum * - $dropRate * ($instanceRankRate + $bossReward*0.2) * - pow(2, $todayPveBattleTimes - $todayPveGetFragmentNum -1), 1); - $gunProbability = min($gunFragmentNum / $onlineNum * - $dropRate * ($instanceRankRate + $bossReward*0.2) * - pow(2, $todayPveBattleTimes - $todayPveGetFragmentNum -1), 1); - - $heroProbability = max($heroProbability, 0); - $gunProbability = max($gunProbability, 0); + $heroProbability = FormulaService::calcHeroFragmentProbabilityPve + ( + $heroQuality, + $onlineNum, + $heroFragmentNum, + $todayPveBattleTimes, + $instanceLevel, + $instanceRank, + $instanceRankRate, + $bossReward, + $todayPveGetFragmentNum + ); + $gunProbability = FormulaService::calcWeaponFragmentProbabilityPve + ( + $heroQuality, + $onlineNum, + $gunFragmentNum, + $todayPveBattleTimes, + $instanceLevel, + $instanceRank, + $instanceRankRate, + $bossReward, + $todayPveGetFragmentNum + ); $emptyProbability = max(1 - $heroProbability - $gunProbability, 0); $dropIdx = $this->randWeight(array($heroProbability, $gunProbability, $emptyProbability)); diff --git a/webapp/services/FormulaService.php b/webapp/services/FormulaService.php index b54e070f..bf67b5c7 100644 --- a/webapp/services/FormulaService.php +++ b/webapp/services/FormulaService.php @@ -150,6 +150,44 @@ class FormulaService extends BaseService { return max(0, $weaponProbability); } + public static function calcHeroFragmentProbabilityPve($heroQuality, + $onlineNum, + $heroFragmentNum, + $todayPvpBattleTimes, + $instanceLevel, + $instanceRank, + $instanceRankRate, + $bossReward, + $todayPveGetFragmentNum) + { + $dropRate = max(1.15 - ($heroQuality - $instanceLevel) * 0.25, 0); + $dropMul = 0.8 - ($instanceRank - 1) * 0.25 + $bossReward * 0.2; + + $heroProbability = min($heroFragmentNum / $onlineNum * + $dropRate * ($instanceRankRate + $bossReward*0.2) * + pow(2, $todayPveBattleTimes - $todayPveGetFragmentNum - 1), 1); + return max(0, $heroProbability); + } + + public static function calcWeaponFragmentProbabilityPve($heroQuality, + $onlineNum, + $gunFragmentNum, + $todayPvpBattleTimes, + $instanceLevel, + $instanceRank, + $instanceRankRate, + $bossReward, + $todayPveGetFragmentNum) + { + $dropRate = max(1.15 - ($heroQuality - $instanceLevel) * 0.25, 0); + $dropMul = 0.8 - ($instanceRank - 1) * 0.25 + $bossReward * 0.2; + + $gunProbability = min($gunFragmentNum / $onlineNum * + $dropRate * ($instanceRankRate + $bossReward*0.2) * + pow(2, $todayPveBattleTimes - $todayPveGetFragmentNum - 1), 1); + return max(0, $gunProbability); + } + public static function getHeroPvpTiliTotalValue($heroDb) { //ROUND((0.0241*角色NFT阶数^3-0.5675*角色NFT阶数^2+7.1798*角色NFT阶数+2.4114)+(0.0161*角色幸运值^3-1.2943*角色幸运值^2+36.5664*角色幸运值-336.144),0)+系统参数