From cfe7d17c53d01178586764834093daf488ba2c3a Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 8 Oct 2024 14:14:24 +0800 Subject: [PATCH 01/48] 1 --- webapp/controller/BattleController.class.php | 8 +++ webapp/services/BattleBoxService.php | 54 ++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 webapp/services/BattleBoxService.php diff --git a/webapp/controller/BattleController.class.php b/webapp/controller/BattleController.class.php index 50ed53d1..c0103046 100644 --- a/webapp/controller/BattleController.class.php +++ b/webapp/controller/BattleController.class.php @@ -15,6 +15,7 @@ require_once('services/BattleDataService.php'); require_once('services/TameBattleDataService.php'); require_once('services/RoomBattleDataService.php'); require_once('services/FormulaService.php'); +require_once('services/BattleBoxService.php'); require_once('mt/RankSeason.php'); require_once('mt/Robot.php'); require_once('mt/Skill.php'); @@ -1308,6 +1309,13 @@ class BattleController extends BaseAuthedController { $r->setPx(DEC_BATTLE_TICKET . $roomUuid, 1, 1000 * 3600); } + public function requestAllocBoxNumNew() { + $boxNum = services\BattleBoxService::allocBox(); + myself()->_rspData(array( + 'box_num' => $boxNum + )); + } + public function requestAllocBoxNum() { if (!myself()->_switchIsOpen('bigEventBoxDrop')) { diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php new file mode 100644 index 00000000..1402f282 --- /dev/null +++ b/webapp/services/BattleBoxService.php @@ -0,0 +1,54 @@ +_switchIsOpen('bigEventBoxDrop')) { + return 0; + } + $currPhase = self::getCurrentPhase(); + + } + + public static function getCurrentPhase() + { + return 0; + } + + private static function getDailyPhaseDropLastTime($phase, $lastTime) + { + $key = self::DAILY_PHASE_DROP_LAST_TIME_KEY . $phase . ':' . $lastTime; + $r = $this->_getRedis($key); + $time = $r->get($key); + return empty($time) ? 0 : $time; + } + + private static function getDailyPhaseDropTotalNum($phase, $lastTime) + { + $key = self::DAILY_PHASE_DROP_TOTAL_KEY . $phase . ':' . $lastTime; + $r = $this->_getRedis($key); + $num = $r->get($key); + return empty($num) ? 0 : $num; + } + + private static function incAlreadyTodayAllocBoxNum($val) + { + $key = 'box_daily_already_alloc_num:' . myself()->_getNowDaySeconds(); + $r = $this->_getRedis($key); + $num = intval($r->get($key)); + if (empty($num)) { + $r->setPx($key, $val, 1000 * 3600 * 24 * 7); + } else { + $r->setPx($key, $num + $val, 1000 * 3600 * 24 * 7); + } + } + +} From b85a1903e0170803d94b3451af91413a90559452 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 8 Oct 2024 14:51:35 +0800 Subject: [PATCH 02/48] 1 --- webapp/services/BattleBoxService.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index 1402f282..ed6affa2 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -6,8 +6,8 @@ require_once('mt/Parameter.php'); class BattleBoxService { - const DAILY_PHASE_DROP_LAST_TIME_KEY = ''; - const DAILY_PHASE_DROP_TOTAL_KEY = ''; + const DAILY_PHASE_DROP_LAST_TIME_KEY = ':'; + const DAILY_PHASE_DROP_TOTAL_KEY = ':'; public static function allocBox() { @@ -23,17 +23,17 @@ class BattleBoxService { return 0; } - private static function getDailyPhaseDropLastTime($phase, $lastTime) + private static function getDailyPhaseDropLastTime($phase, $time) { - $key = self::DAILY_PHASE_DROP_LAST_TIME_KEY . $phase . ':' . $lastTime; + $key = self::DAILY_PHASE_DROP_LAST_TIME_KEY . $phase . ':' . $time; $r = $this->_getRedis($key); - $time = $r->get($key); - return empty($time) ? 0 : $time; + $lastTime = $r->get($key); + return empty($lastTime) ? 0 : $lastTime; } - private static function getDailyPhaseDropTotalNum($phase, $lastTime) + private static function getDailyPhaseDropTotalNum($phase, $time) { - $key = self::DAILY_PHASE_DROP_TOTAL_KEY . $phase . ':' . $lastTime; + $key = self::DAILY_PHASE_DROP_TOTAL_KEY . $phase . ':' . $time; $r = $this->_getRedis($key); $num = $r->get($key); return empty($num) ? 0 : $num; From 6267ef51a7e8c02ce230a5434b4a40fd3fed5972 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 8 Oct 2024 15:10:15 +0800 Subject: [PATCH 03/48] 1 --- webapp/services/BattleBoxService.php | 40 +++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index ed6affa2..db16d810 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -8,14 +8,36 @@ class BattleBoxService { const DAILY_PHASE_DROP_LAST_TIME_KEY = ':'; const DAILY_PHASE_DROP_TOTAL_KEY = ':'; + const DAILY_PHASE_ALLOC_NUM_KEY = ':'; + const DAILY_PHASE_ALREADY_ALLOC_NUM_KEY = ':'; public static function allocBox() { if (!myself()->_switchIsOpen('bigEventBoxDrop')) { return 0; } + $boxNum = 0; $currPhase = self::getCurrentPhase(); - + $allocableNum = self::getDailyPhaseAllocNum($currPhase, myself()->_getNowDaySeconds()); + $alreadyAllocNum = self::getDailyPhaseAlreadyAllocNum($currPhase, myself()->_getNowDaySeconds()); + if ($allocNum > 0) { + $lstVal = mt\Parameter::getListValue('battle_event_loot_per_game'); + if ($allocableNum <= 0 || empty($lstVal) || count($lstVal) < 2) { + myself()->_rspData(array( + 'box_num' => 0 + )); + return; + } + $rnd = rand($lstVal[0], $lstVal[1]); + if ($rnd <= 0) { + myself()->_rspData(array( + 'box_num' => 0 + )); + return; + } + $boxNum = min($rnd, $allocableNum); + } + return $boxNum; } public static function getCurrentPhase() @@ -39,6 +61,22 @@ class BattleBoxService { return empty($num) ? 0 : $num; } + private static function getDailyPhaseAllocNum($phase, $time) + { + $key = self::DAILY_PHASE_ALLOC_NUM_KEY . $phase . ':' . $time; + $r = $this->_getRedis($key); + $num = $r->get($key); + return empty($num) ? 0 : $num; + } + + private static function getDailyPhaseAlreadyAllocNum($phase, $time) + { + $key = self::DAILY_PHASE_ALREADY_ALLOC_NUM_KEY . $phase . ':' . $time; + $r = $this->_getRedis($key); + $num = $r->get($key); + return empty($num) ? 0 : $num; + } + private static function incAlreadyTodayAllocBoxNum($val) { $key = 'box_daily_already_alloc_num:' . myself()->_getNowDaySeconds(); From b6f62d22b4579338e75472f23c2f5341c847402e Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 8 Oct 2024 15:12:07 +0800 Subject: [PATCH 04/48] 1 --- webapp/services/BattleBoxService.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index db16d810..b7b25383 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -20,19 +20,13 @@ class BattleBoxService { $currPhase = self::getCurrentPhase(); $allocableNum = self::getDailyPhaseAllocNum($currPhase, myself()->_getNowDaySeconds()); $alreadyAllocNum = self::getDailyPhaseAlreadyAllocNum($currPhase, myself()->_getNowDaySeconds()); - if ($allocNum > 0) { + if ($allocableNum > 0) { $lstVal = mt\Parameter::getListValue('battle_event_loot_per_game'); if ($allocableNum <= 0 || empty($lstVal) || count($lstVal) < 2) { - myself()->_rspData(array( - 'box_num' => 0 - )); return; } $rnd = rand($lstVal[0], $lstVal[1]); if ($rnd <= 0) { - myself()->_rspData(array( - 'box_num' => 0 - )); return; } $boxNum = min($rnd, $allocableNum); From 52b6a66dfafa9f9b70251851184f40d9c54b4d50 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 8 Oct 2024 15:15:23 +0800 Subject: [PATCH 05/48] 1 --- webapp/services/BattleBoxService.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index b7b25383..de88a3e9 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -22,14 +22,13 @@ class BattleBoxService { $alreadyAllocNum = self::getDailyPhaseAlreadyAllocNum($currPhase, myself()->_getNowDaySeconds()); if ($allocableNum > 0) { $lstVal = mt\Parameter::getListValue('battle_event_loot_per_game'); - if ($allocableNum <= 0 || empty($lstVal) || count($lstVal) < 2) { - return; + if (!$allocableNum <= 0 || empty($lstVal) || count($lstVal) < 2) { + $rnd = rand($lstVal[0], $lstVal[1]); + if ($rnd <= 0) { + return; + } + $boxNum = min($rnd, $allocableNum); } - $rnd = rand($lstVal[0], $lstVal[1]); - if ($rnd <= 0) { - return; - } - $boxNum = min($rnd, $allocableNum); } return $boxNum; } From 22e24628b4fda033fae09910628e293667e41b04 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 8 Oct 2024 15:19:03 +0800 Subject: [PATCH 06/48] 1 --- webapp/services/BattleBoxService.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index de88a3e9..8bc3e2b2 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -24,10 +24,9 @@ class BattleBoxService { $lstVal = mt\Parameter::getListValue('battle_event_loot_per_game'); if (!$allocableNum <= 0 || empty($lstVal) || count($lstVal) < 2) { $rnd = rand($lstVal[0], $lstVal[1]); - if ($rnd <= 0) { - return; + if ($rnd > 0) { + $boxNum = min($rnd, $allocableNum); } - $boxNum = min($rnd, $allocableNum); } } return $boxNum; From 41ab453c086159df34d6cc7a27b13f81953355d6 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 8 Oct 2024 15:20:56 +0800 Subject: [PATCH 07/48] 1 --- webapp/services/BattleBoxService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index 8bc3e2b2..2c54974b 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -22,7 +22,7 @@ class BattleBoxService { $alreadyAllocNum = self::getDailyPhaseAlreadyAllocNum($currPhase, myself()->_getNowDaySeconds()); if ($allocableNum > 0) { $lstVal = mt\Parameter::getListValue('battle_event_loot_per_game'); - if (!$allocableNum <= 0 || empty($lstVal) || count($lstVal) < 2) { + if (!($allocableNum <= 0 || empty($lstVal) || count($lstVal) < 2)) { $rnd = rand($lstVal[0], $lstVal[1]); if ($rnd > 0) { $boxNum = min($rnd, $allocableNum); From 9abaecfbfb77d40d1d84d825df6f6dbd4af62ad5 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 8 Oct 2024 15:26:54 +0800 Subject: [PATCH 08/48] 1 --- webapp/services/BattleBoxService.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index 2c54974b..4264bc29 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -29,6 +29,19 @@ class BattleBoxService { } } } + if ($boxNum > 0) { + SqlHelper::insert( + $this->_getSelfMysql(), + 't_box_alloc', + array( + 'room_uuid' => $roomUuid, + 'account_id' => myself()->_getAccountId(), + 'box_num' => $boxNum, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime(), + ) + ); + } return $boxNum; } @@ -69,9 +82,9 @@ class BattleBoxService { return empty($num) ? 0 : $num; } - private static function incAlreadyTodayAllocBoxNum($val) + private static function incAlreadyAllocNum($phase, $time, $val) { - $key = 'box_daily_already_alloc_num:' . myself()->_getNowDaySeconds(); + $key = self::DAILY_PHASE_ALREADY_ALLOC_NUM_KEY . $phase . ':' . $time; $r = $this->_getRedis($key); $num = intval($r->get($key)); if (empty($num)) { From 3a03526fbf706ecfec76a77ab892610b0df1e195 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 8 Oct 2024 15:28:57 +0800 Subject: [PATCH 09/48] 1 --- webapp/services/BattleBoxService.php | 1 + 1 file changed, 1 insertion(+) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index 4264bc29..00653b39 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -41,6 +41,7 @@ class BattleBoxService { 'modifytime' => myself()->_getNowTime(), ) ); + self::incAlreadyAllocNum($currPhase, myself()->_getNowDaySeconds(), $boxNum); } return $boxNum; } From 7f7afec29e3c2f0ecb1cab43d1b18365e9e39368 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 8 Oct 2024 15:29:22 +0800 Subject: [PATCH 10/48] 1 --- webapp/services/BattleBoxService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index 00653b39..c2a22d76 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -11,7 +11,7 @@ class BattleBoxService { const DAILY_PHASE_ALLOC_NUM_KEY = ':'; const DAILY_PHASE_ALREADY_ALLOC_NUM_KEY = ':'; - public static function allocBox() + public static function allocBox($roomUuid) { if (!myself()->_switchIsOpen('bigEventBoxDrop')) { return 0; From 707dea9b00129207c2ca198265660dc4b9ac031d Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 8 Oct 2024 15:40:16 +0800 Subject: [PATCH 11/48] 1 --- webapp/services/BattleBoxService.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index c2a22d76..554202bd 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -18,8 +18,14 @@ class BattleBoxService { } $boxNum = 0; $currPhase = self::getCurrentPhase(); + $startTime = 0; + $endTime = 0; $allocableNum = self::getDailyPhaseAllocNum($currPhase, myself()->_getNowDaySeconds()); $alreadyAllocNum = self::getDailyPhaseAlreadyAllocNum($currPhase, myself()->_getNowDaySeconds()); + if ($allocableNum <= 0) { + $yesterDayLastDropTime = self::getDailyPhaseDropLastTime($currPhase, myself()->_getNowDaySeconds()); + $yesterDayDropTotal = self::getDailyPhaseDropTotalNum($currPhase, myself()->_getNowDaySeconds()); + } if ($allocableNum > 0) { $lstVal = mt\Parameter::getListValue('battle_event_loot_per_game'); if (!($allocableNum <= 0 || empty($lstVal) || count($lstVal) < 2)) { From a1c99dd9aef9a3af91d3ddb07b12e6a26e518797 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 8 Oct 2024 15:43:31 +0800 Subject: [PATCH 12/48] 1 --- webapp/services/BattleBoxService.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index 554202bd..af74c08a 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -20,6 +20,8 @@ class BattleBoxService { $currPhase = self::getCurrentPhase(); $startTime = 0; $endTime = 0; + + $allocableNum = self::getDailyPhaseAllocNum($currPhase, myself()->_getNowDaySeconds()); $alreadyAllocNum = self::getDailyPhaseAlreadyAllocNum($currPhase, myself()->_getNowDaySeconds()); if ($allocableNum <= 0) { From 63f815ddd6230fe6ebcb185d201c0e40e3da3ddc Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 8 Oct 2024 16:02:57 +0800 Subject: [PATCH 13/48] 1 --- webapp/services/BattleBoxService.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index af74c08a..789c1734 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -20,13 +20,18 @@ class BattleBoxService { $currPhase = self::getCurrentPhase(); $startTime = 0; $endTime = 0; - + $maxNum = 0; $allocableNum = self::getDailyPhaseAllocNum($currPhase, myself()->_getNowDaySeconds()); $alreadyAllocNum = self::getDailyPhaseAlreadyAllocNum($currPhase, myself()->_getNowDaySeconds()); if ($allocableNum <= 0) { - $yesterDayLastDropTime = self::getDailyPhaseDropLastTime($currPhase, myself()->_getNowDaySeconds()); - $yesterDayDropTotal = self::getDailyPhaseDropTotalNum($currPhase, myself()->_getNowDaySeconds()); + $yesterDayTime = myself()->_getNowDaySeconds() - 3600 * 24; + $yesterDayLastDropTime = self::getDailyPhaseDropLastTime($currPhase, $yesterDayTime); + $yesterDayDropTotal = self::getDailyPhaseDropTotalNum($currPhase, $yesterDayTime); + $yesterDayAllocNum = self::getDailyPhaseAllocNum($currPhase, $yesterDayTime); + if ($yesterDayAllocNum >= 0) { + $allocableNum = $maxNum; + } } if ($allocableNum > 0) { $lstVal = mt\Parameter::getListValue('battle_event_loot_per_game'); From ace3e78cdd2a725db5aa13236b9315885563c766 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 8 Oct 2024 16:04:18 +0800 Subject: [PATCH 14/48] 1 --- webapp/services/BattleBoxService.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index 789c1734..09020de5 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -88,6 +88,30 @@ class BattleBoxService { return empty($num) ? 0 : $num; } + private static function setDailyPhaseDropLastTime($phase, $time) + { + $key = self::DAILY_PHASE_DROP_LAST_TIME_KEY . $phase . ':' . $time; + $r = $this->_getRedis($key); + $lastTime = $r->get($key); + return empty($lastTime) ? 0 : $lastTime; + } + + private static function setDailyPhaseDropTotalNum($phase, $time) + { + $key = self::DAILY_PHASE_DROP_TOTAL_KEY . $phase . ':' . $time; + $r = $this->_getRedis($key); + $num = $r->get($key); + return empty($num) ? 0 : $num; + } + + private static function setDailyPhaseAllocNum($phase, $time) + { + $key = self::DAILY_PHASE_ALLOC_NUM_KEY . $phase . ':' . $time; + $r = $this->_getRedis($key); + $num = $r->get($key); + return empty($num) ? 0 : $num; + } + private static function getDailyPhaseAlreadyAllocNum($phase, $time) { $key = self::DAILY_PHASE_ALREADY_ALLOC_NUM_KEY . $phase . ':' . $time; From 2f9c065b24ee6b827b7e358b06e3ff4b47b3391a Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 8 Oct 2024 16:08:13 +0800 Subject: [PATCH 15/48] 1 --- webapp/services/BattleBoxService.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index 09020de5..89bda969 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -88,28 +88,25 @@ class BattleBoxService { return empty($num) ? 0 : $num; } - private static function setDailyPhaseDropLastTime($phase, $time) + private static function setDailyPhaseDropLastTime($phase, $time, $val) { $key = self::DAILY_PHASE_DROP_LAST_TIME_KEY . $phase . ':' . $time; $r = $this->_getRedis($key); - $lastTime = $r->get($key); - return empty($lastTime) ? 0 : $lastTime; + $r->setPx($key, $val, 1000 * 3600 * 24 * 7); } private static function setDailyPhaseDropTotalNum($phase, $time) { $key = self::DAILY_PHASE_DROP_TOTAL_KEY . $phase . ':' . $time; $r = $this->_getRedis($key); - $num = $r->get($key); - return empty($num) ? 0 : $num; + $r->setPx($key, $val, 1000 * 3600 * 24 * 7); } private static function setDailyPhaseAllocNum($phase, $time) { $key = self::DAILY_PHASE_ALLOC_NUM_KEY . $phase . ':' . $time; $r = $this->_getRedis($key); - $num = $r->get($key); - return empty($num) ? 0 : $num; + $r->setPx($key, $val, 1000 * 3600 * 24 * 7); } private static function getDailyPhaseAlreadyAllocNum($phase, $time) From 47cc3523fc5b08dc48de64b5cbd4c56539b55e71 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 8 Oct 2024 16:20:10 +0800 Subject: [PATCH 16/48] 1 --- webapp/services/BattleBoxService.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index 89bda969..0bf7f42e 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -29,9 +29,12 @@ class BattleBoxService { $yesterDayLastDropTime = self::getDailyPhaseDropLastTime($currPhase, $yesterDayTime); $yesterDayDropTotal = self::getDailyPhaseDropTotalNum($currPhase, $yesterDayTime); $yesterDayAllocNum = self::getDailyPhaseAllocNum($currPhase, $yesterDayTime); - if ($yesterDayAllocNum >= 0) { + if ($yesterDayAllocNum <= 0) { $allocableNum = $maxNum; } + if ($allocableNum) { + self::setDailyPhaseAllocNum($currPhase, $allocableNum); + } } if ($allocableNum > 0) { $lstVal = mt\Parameter::getListValue('battle_event_loot_per_game'); From 9d2ba39efced2e5bc5892c51528692f3351d3460 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 8 Oct 2024 17:13:47 +0800 Subject: [PATCH 17/48] 1 --- webapp/services/BattleBoxService.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index 0bf7f42e..969503d1 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -4,6 +4,15 @@ namespace services; require_once('mt/Parameter.php'); +/* +1、周期没害没结束,箱子就掉完了 +完成度=T max/T cost time(last time-start time) +2、周期结束,箱子也还没掉完 +完成度=N real num/N max + +下-天的投放数量(下一天max) +下一天max=min(today max*today 完成度,qlobal max) + */ class BattleBoxService { const DAILY_PHASE_DROP_LAST_TIME_KEY = ':'; @@ -31,6 +40,8 @@ class BattleBoxService { $yesterDayAllocNum = self::getDailyPhaseAllocNum($currPhase, $yesterDayTime); if ($yesterDayAllocNum <= 0) { $allocableNum = $maxNum; + } else { + } if ($allocableNum) { self::setDailyPhaseAllocNum($currPhase, $allocableNum); From f88aca789aee3363ec6a3c4ac33bd94ac1ddb5e4 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 8 Oct 2024 17:16:41 +0800 Subject: [PATCH 18/48] 1 --- webapp/services/BattleBoxService.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index 969503d1..2bb8979b 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -5,14 +5,15 @@ namespace services; require_once('mt/Parameter.php'); /* -1、周期没害没结束,箱子就掉完了 +1、周还害没结束,箱子就掉完了 完成度=T max/T cost time(last time-start time) + 2、周期结束,箱子也还没掉完 完成度=N real num/N max -下-天的投放数量(下一天max) +下一天的投放数量(下一天max) 下一天max=min(today max*today 完成度,qlobal max) - */ +*/ class BattleBoxService { const DAILY_PHASE_DROP_LAST_TIME_KEY = ':'; From 59a23a84d2450ece2e99f908f2420130f3692b5f Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 8 Oct 2024 17:28:33 +0800 Subject: [PATCH 19/48] 1 --- webapp/services/BattleBoxService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index 2bb8979b..d31e84a2 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -5,7 +5,7 @@ namespace services; require_once('mt/Parameter.php'); /* -1、周还害没结束,箱子就掉完了 +1、周期还害没结束,箱子就掉完了 完成度=T max/T cost time(last time-start time) 2、周期结束,箱子也还没掉完 From fcd8d966d8e095161bac7a45395b5453e30e9bef Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 8 Oct 2024 17:45:44 +0800 Subject: [PATCH 20/48] 1 --- webapp/services/BattleBoxService.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index d31e84a2..d0e49678 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -31,6 +31,7 @@ class BattleBoxService { $startTime = 0; $endTime = 0; $maxNum = 0; + $completionDegree = 0; $allocableNum = self::getDailyPhaseAllocNum($currPhase, myself()->_getNowDaySeconds()); $alreadyAllocNum = self::getDailyPhaseAlreadyAllocNum($currPhase, myself()->_getNowDaySeconds()); @@ -42,7 +43,11 @@ class BattleBoxService { if ($yesterDayAllocNum <= 0) { $allocableNum = $maxNum; } else { - + if ($yesterDayDropTotal >= $yesterDayAllocNum) { + //掉完了 + } else { + //没掉完 + } } if ($allocableNum) { self::setDailyPhaseAllocNum($currPhase, $allocableNum); From 73ada9cf7f7175e0f5b8672c2e44a678b9fd85a4 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 8 Oct 2024 18:24:11 +0800 Subject: [PATCH 21/48] 1 --- webapp/services/BattleBoxService.php | 1 + 1 file changed, 1 insertion(+) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index d0e49678..aa7da1ff 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -45,6 +45,7 @@ class BattleBoxService { } else { if ($yesterDayDropTotal >= $yesterDayAllocNum) { //掉完了 + $costTime = 0; } else { //没掉完 } From a0f694f8192c8902adc80b43cb835a93be4935dc Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 8 Oct 2024 18:33:41 +0800 Subject: [PATCH 22/48] 1 --- webapp/services/BattleBoxService.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index aa7da1ff..002f0d75 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -37,7 +37,7 @@ class BattleBoxService { $alreadyAllocNum = self::getDailyPhaseAlreadyAllocNum($currPhase, myself()->_getNowDaySeconds()); if ($allocableNum <= 0) { $yesterDayTime = myself()->_getNowDaySeconds() - 3600 * 24; - $yesterDayLastDropTime = self::getDailyPhaseDropLastTime($currPhase, $yesterDayTime); + $yesterDayDropLastTime = self::getDailyPhaseDropLastTime($currPhase, $yesterDayTime); $yesterDayDropTotal = self::getDailyPhaseDropTotalNum($currPhase, $yesterDayTime); $yesterDayAllocNum = self::getDailyPhaseAllocNum($currPhase, $yesterDayTime); if ($yesterDayAllocNum <= 0) { @@ -45,9 +45,15 @@ class BattleBoxService { } else { if ($yesterDayDropTotal >= $yesterDayAllocNum) { //掉完了 - $costTime = 0; + $costTime = myself()->_getDaySecondsOffset($yesterDayDropLastTime) - $startTime; + if ($costTime <= 0) { + $completionDegree = 1; + } else { + $completionDegree = ($endTime - $startTime) / $costTime; + } } else { //没掉完 + $completionDegree = $yesterDayDropTotal / $yesterDayAllocNum; } } if ($allocableNum) { From 9a3f73c81bc8058d3d8903e2d4ade1c079dad6f1 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 8 Oct 2024 19:06:02 +0800 Subject: [PATCH 23/48] 1 --- webapp/services/BattleBoxService.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index 002f0d75..c53a037c 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -30,7 +30,9 @@ class BattleBoxService { $currPhase = self::getCurrentPhase(); $startTime = 0; $endTime = 0; + $minNum = 0; $maxNum = 0; + $maxNumLimit = 0; $completionDegree = 0; $allocableNum = self::getDailyPhaseAllocNum($currPhase, myself()->_getNowDaySeconds()); @@ -55,6 +57,7 @@ class BattleBoxService { //没掉完 $completionDegree = $yesterDayDropTotal / $yesterDayAllocNum; } + $allocableNum = min(5000, $maxNum * $completionDegree); } if ($allocableNum) { self::setDailyPhaseAllocNum($currPhase, $allocableNum); From 3bed24ae5a3097ba7222c1cff1eee4f1f457f94e Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 8 Oct 2024 19:10:58 +0800 Subject: [PATCH 24/48] b --- webapp/services/BattleBoxService.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index c53a037c..e3a5c037 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -16,10 +16,10 @@ require_once('mt/Parameter.php'); */ class BattleBoxService { - const DAILY_PHASE_DROP_LAST_TIME_KEY = ':'; - const DAILY_PHASE_DROP_TOTAL_KEY = ':'; - const DAILY_PHASE_ALLOC_NUM_KEY = ':'; - const DAILY_PHASE_ALREADY_ALLOC_NUM_KEY = ':'; + const DAILY_PHASE_DROP_LAST_TIME_KEY = 'daily_phase_drop_last_time:'; + const DAILY_PHASE_DROP_TOTAL_KEY = 'daily_phase_drop_total:'; + const DAILY_PHASE_ALLOC_NUM_KEY = 'daily_phase_alloc_num:'; + const DAILY_PHASE_ALREADY_ALLOC_NUM_KEY = 'daily_phase_already_alloc_num:'; public static function allocBox($roomUuid) { From 77ee55fa55fda76a8e5047b6e0ab555bb6f139fc Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 8 Oct 2024 19:27:33 +0800 Subject: [PATCH 25/48] 1 --- webapp/mt/MapMode.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/webapp/mt/MapMode.php b/webapp/mt/MapMode.php index e33f1cb6..3cc9ab11 100644 --- a/webapp/mt/MapMode.php +++ b/webapp/mt/MapMode.php @@ -123,6 +123,18 @@ class MapMode return !empty($meta['daily_open_time_2']) && !empty($meta['daily_end_time_2']); } + public static function getCurrentBoxDropInfo(&$mapModeMeta, &$phase, &$startTime, &$endTime) + { + self::traverseMeta(function ($meta) + use (&$mapModeMeta, &$phase, &$startTime, &$endTime) { + if ($meta['mapMode'] == self::TREASURE_BOX_MODE) { + if (self::configedDailyTimeLimit1($meta) || self::configedDailyTimeLimit2($meta)) { + } + } + return true; + }); + } + protected static function getMetaList() { if (!self::$metaList) { From 249c62cd72a900cd899bef8b9e3fd2ab7f3814c0 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 8 Oct 2024 19:31:31 +0800 Subject: [PATCH 26/48] 1 --- webapp/mt/MapMode.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/webapp/mt/MapMode.php b/webapp/mt/MapMode.php index 3cc9ab11..23a369e5 100644 --- a/webapp/mt/MapMode.php +++ b/webapp/mt/MapMode.php @@ -128,7 +128,19 @@ class MapMode self::traverseMeta(function ($meta) use (&$mapModeMeta, &$phase, &$startTime, &$endTime) { if ($meta['mapMode'] == self::TREASURE_BOX_MODE) { - if (self::configedDailyTimeLimit1($meta) || self::configedDailyTimeLimit2($meta)) { + if (self::configedDailyTimeLimit1($meta)) { + $mapNodeMeta = $meta; + $phase = 1; + $startTime = $meta['daily_open_time']; + $endTime = $meta['daily_end_time']; + return false; + } + if (self::configedDailyTimeLimit2($meta)) { + $mapNodeMeta = $meta; + $phase = 2; + $startTime = $meta['daily_open_time_2']; + $endTime = $meta['daily_end_time_2']; + return false; } } return true; From 9487c41783230b4c5d198f17cdb81138ca14bec9 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 9 Oct 2024 10:29:44 +0800 Subject: [PATCH 27/48] 1 --- webapp/controller/BattleController.class.php | 2 +- webapp/mt/MapMode.php | 4 ++-- webapp/services/BattleBoxService.php | 18 ++++++++++++------ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/webapp/controller/BattleController.class.php b/webapp/controller/BattleController.class.php index c0103046..f5528504 100644 --- a/webapp/controller/BattleController.class.php +++ b/webapp/controller/BattleController.class.php @@ -1310,7 +1310,7 @@ class BattleController extends BaseAuthedController { } public function requestAllocBoxNumNew() { - $boxNum = services\BattleBoxService::allocBox(); + $boxNum = services\BattleBoxService::allocBox(''); myself()->_rspData(array( 'box_num' => $boxNum )); diff --git a/webapp/mt/MapMode.php b/webapp/mt/MapMode.php index 23a369e5..71cbdfa5 100644 --- a/webapp/mt/MapMode.php +++ b/webapp/mt/MapMode.php @@ -129,14 +129,14 @@ class MapMode use (&$mapModeMeta, &$phase, &$startTime, &$endTime) { if ($meta['mapMode'] == self::TREASURE_BOX_MODE) { if (self::configedDailyTimeLimit1($meta)) { - $mapNodeMeta = $meta; + $mapModeMeta = $meta; $phase = 1; $startTime = $meta['daily_open_time']; $endTime = $meta['daily_end_time']; return false; } if (self::configedDailyTimeLimit2($meta)) { - $mapNodeMeta = $meta; + $mapModeMeta = $meta; $phase = 2; $startTime = $meta['daily_open_time_2']; $endTime = $meta['daily_end_time_2']; diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index e3a5c037..f33b1deb 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -3,7 +3,9 @@ namespace services; require_once('mt/Parameter.php'); +require_once('mt/MapMode.php'); +use mt; /* 1、周期还害没结束,箱子就掉完了 完成度=T max/T cost time(last time-start time) @@ -27,13 +29,22 @@ class BattleBoxService { return 0; } $boxNum = 0; - $currPhase = self::getCurrentPhase(); + $currPhase = 0; $startTime = 0; $endTime = 0; $minNum = 0; $maxNum = 0; $maxNumLimit = 0; $completionDegree = 0; + $mapModeMeta = null; + mt\MapMode::getCurrentBoxDropInfo($mapModeMeta, $currPhase, $startTime, $endTime); + error_log(json_encode(array( + 'mapNodeMeta' => $mapModeMeta, + 'currPhase' => $currPhase, + 'startTime' => $startTime, + 'endTime' => $endTime, + ))); + return; $allocableNum = self::getDailyPhaseAllocNum($currPhase, myself()->_getNowDaySeconds()); $alreadyAllocNum = self::getDailyPhaseAlreadyAllocNum($currPhase, myself()->_getNowDaySeconds()); @@ -89,11 +100,6 @@ class BattleBoxService { return $boxNum; } - public static function getCurrentPhase() - { - return 0; - } - private static function getDailyPhaseDropLastTime($phase, $time) { $key = self::DAILY_PHASE_DROP_LAST_TIME_KEY . $phase . ':' . $time; From 71905d628c95a97e3b3754e151a9b185664a5735 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 9 Oct 2024 10:37:26 +0800 Subject: [PATCH 28/48] 1 --- webapp/services/BattleBoxService.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index f33b1deb..3242dc8b 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -29,22 +29,36 @@ class BattleBoxService { return 0; } $boxNum = 0; + + $mapModeMeta = null; $currPhase = 0; $startTime = 0; $endTime = 0; + $minNum = 0; $maxNum = 0; - $maxNumLimit = 0; + $maxNumLimit = 5000; $completionDegree = 0; - $mapModeMeta = null; mt\MapMode::getCurrentBoxDropInfo($mapModeMeta, $currPhase, $startTime, $endTime); + $maxLst0 = mt\Parameter::getListValue('battle_event_loot_daily_period_max_0'); + $maxLst1 = mt\Parameter::getListValue('battle_event_loot_daily_period_max_1'); + if (count($maxLst0) != 2 || count($maxLst1) != 2) { + return 0; + } + if ($currPhase < 1 || $currPhase > 2) { + return 0; + } + $minNum = $maxLst0[$currPhase]; + $maxNum = $maxLst0[$currPhase]; + error_log(json_encode(array( 'mapNodeMeta' => $mapModeMeta, 'currPhase' => $currPhase, 'startTime' => $startTime, 'endTime' => $endTime, + 'maxLst0' => $maxLst0, + 'maxLst1' => $maxLst1, ))); - return; $allocableNum = self::getDailyPhaseAllocNum($currPhase, myself()->_getNowDaySeconds()); $alreadyAllocNum = self::getDailyPhaseAlreadyAllocNum($currPhase, myself()->_getNowDaySeconds()); From 7b8beb94fb3d87fe54bcba3445895f368f0622be Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 9 Oct 2024 10:38:09 +0800 Subject: [PATCH 29/48] 1 --- webapp/services/BattleBoxService.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index 3242dc8b..2cd9a6e5 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -117,7 +117,7 @@ class BattleBoxService { private static function getDailyPhaseDropLastTime($phase, $time) { $key = self::DAILY_PHASE_DROP_LAST_TIME_KEY . $phase . ':' . $time; - $r = $this->_getRedis($key); + $r = myself()->_getRedis($key); $lastTime = $r->get($key); return empty($lastTime) ? 0 : $lastTime; } @@ -125,7 +125,7 @@ class BattleBoxService { private static function getDailyPhaseDropTotalNum($phase, $time) { $key = self::DAILY_PHASE_DROP_TOTAL_KEY . $phase . ':' . $time; - $r = $this->_getRedis($key); + $r = myself()->_getRedis($key); $num = $r->get($key); return empty($num) ? 0 : $num; } @@ -133,7 +133,7 @@ class BattleBoxService { private static function getDailyPhaseAllocNum($phase, $time) { $key = self::DAILY_PHASE_ALLOC_NUM_KEY . $phase . ':' . $time; - $r = $this->_getRedis($key); + $r = myself()->_getRedis($key); $num = $r->get($key); return empty($num) ? 0 : $num; } @@ -141,28 +141,28 @@ class BattleBoxService { private static function setDailyPhaseDropLastTime($phase, $time, $val) { $key = self::DAILY_PHASE_DROP_LAST_TIME_KEY . $phase . ':' . $time; - $r = $this->_getRedis($key); + $r = myself()->_getRedis($key); $r->setPx($key, $val, 1000 * 3600 * 24 * 7); } private static function setDailyPhaseDropTotalNum($phase, $time) { $key = self::DAILY_PHASE_DROP_TOTAL_KEY . $phase . ':' . $time; - $r = $this->_getRedis($key); + $r = myself()->_getRedis($key); $r->setPx($key, $val, 1000 * 3600 * 24 * 7); } private static function setDailyPhaseAllocNum($phase, $time) { $key = self::DAILY_PHASE_ALLOC_NUM_KEY . $phase . ':' . $time; - $r = $this->_getRedis($key); + $r = myself()->_getRedis($key); $r->setPx($key, $val, 1000 * 3600 * 24 * 7); } private static function getDailyPhaseAlreadyAllocNum($phase, $time) { $key = self::DAILY_PHASE_ALREADY_ALLOC_NUM_KEY . $phase . ':' . $time; - $r = $this->_getRedis($key); + $r = myself()->_getRedis($key); $num = $r->get($key); return empty($num) ? 0 : $num; } @@ -170,7 +170,7 @@ class BattleBoxService { private static function incAlreadyAllocNum($phase, $time, $val) { $key = self::DAILY_PHASE_ALREADY_ALLOC_NUM_KEY . $phase . ':' . $time; - $r = $this->_getRedis($key); + $r = myself()->_getRedis($key); $num = intval($r->get($key)); if (empty($num)) { $r->setPx($key, $val, 1000 * 3600 * 24 * 7); From 6dd6e74b53cb47cd0f286a3ef7fcb45c879072ab Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 9 Oct 2024 10:40:37 +0800 Subject: [PATCH 30/48] 1 --- webapp/services/BattleBoxService.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index 2cd9a6e5..af79aed9 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -6,6 +6,7 @@ require_once('mt/Parameter.php'); require_once('mt/MapMode.php'); use mt; +use phpcommon\SqlHelper; /* 1、周期还害没结束,箱子就掉完了 完成度=T max/T cost time(last time-start time) @@ -85,7 +86,7 @@ class BattleBoxService { $allocableNum = min(5000, $maxNum * $completionDegree); } if ($allocableNum) { - self::setDailyPhaseAllocNum($currPhase, $allocableNum); + self::setDailyPhaseAllocNum($currPhase, myself()->_getNowDaySeconds(), $allocableNum); } } if ($allocableNum > 0) { @@ -99,7 +100,7 @@ class BattleBoxService { } if ($boxNum > 0) { SqlHelper::insert( - $this->_getSelfMysql(), + myself()->_getSelfMysql(), 't_box_alloc', array( 'room_uuid' => $roomUuid, @@ -145,14 +146,14 @@ class BattleBoxService { $r->setPx($key, $val, 1000 * 3600 * 24 * 7); } - private static function setDailyPhaseDropTotalNum($phase, $time) + private static function setDailyPhaseDropTotalNum($phase, $time, $val) { $key = self::DAILY_PHASE_DROP_TOTAL_KEY . $phase . ':' . $time; $r = myself()->_getRedis($key); $r->setPx($key, $val, 1000 * 3600 * 24 * 7); } - private static function setDailyPhaseAllocNum($phase, $time) + private static function setDailyPhaseAllocNum($phase, $time, $val) { $key = self::DAILY_PHASE_ALLOC_NUM_KEY . $phase . ':' . $time; $r = myself()->_getRedis($key); From 81f37155a017085c3870966bf044747f17255364 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 9 Oct 2024 11:02:59 +0800 Subject: [PATCH 31/48] 1 --- webapp/controller/ToolsController.class.php | 8 ++++++++ webapp/services/BattleBoxService.php | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/webapp/controller/ToolsController.class.php b/webapp/controller/ToolsController.class.php index 24cdda7b..52efd211 100644 --- a/webapp/controller/ToolsController.class.php +++ b/webapp/controller/ToolsController.class.php @@ -3,11 +3,13 @@ require_once('phpcommon/bignumber.php'); require_once('phpcommon/sqlhelper.php'); require_once('services/BlockChainService.php'); +require_once('services/BattleBoxService.php'); require_once('models/BuyRecord.php'); use models\Battle; use phpcommon\SqlHelper; use services\BlockChainService; +use services\BattleBoxService; use models\BuyRecord; class ToolsController extends BaseController { @@ -489,4 +491,10 @@ class ToolsController extends BaseController { echo $checkSql2; } + public function battleBoxDumpToday() + { + $phase = getReqVal('phase', ''); + BattleBoxService::dumpToday(phase); + } + } diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index af79aed9..d76194ee 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -115,6 +115,11 @@ class BattleBoxService { return $boxNum; } + public static function dumpToday($phase) + { + + } + private static function getDailyPhaseDropLastTime($phase, $time) { $key = self::DAILY_PHASE_DROP_LAST_TIME_KEY . $phase . ':' . $time; From fd644c4bf5b7ffd1d5b35c17a9df8a5b773a4104 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 9 Oct 2024 11:14:55 +0800 Subject: [PATCH 32/48] 1 --- webapp/controller/ToolsController.class.php | 2 +- webapp/services/BattleBoxService.php | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/webapp/controller/ToolsController.class.php b/webapp/controller/ToolsController.class.php index 52efd211..589d143c 100644 --- a/webapp/controller/ToolsController.class.php +++ b/webapp/controller/ToolsController.class.php @@ -494,7 +494,7 @@ class ToolsController extends BaseController { public function battleBoxDumpToday() { $phase = getReqVal('phase', ''); - BattleBoxService::dumpToday(phase); + BattleBoxService::dumpToday($phase); } } diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index d76194ee..444f7391 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -117,7 +117,14 @@ class BattleBoxService { public static function dumpToday($phase) { - + $data = array( + 'phase' => $phase, + 'drop_last_time' => self::getDailyPhaseDropLastTime($phase, myself()->_getNowDaySeconds()), + 'drop_curr_total' => self::getDailyPhaseDropTotalNum($phase, myself()->_getNowDaySeconds()), + 'alloc_num' => self::getDailyPhaseAllocNum($phase, myself()->_getNowDaySeconds()), + 'already_alloced_num' => self::getDailyPhaseAlreadyAllocNum($phase, myself()->_getNowDaySeconds()), + ); + myself()->_rspData($data); } private static function getDailyPhaseDropLastTime($phase, $time) From e968bf049ad323e649ad035289c3a337b23bd8b9 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 9 Oct 2024 11:18:26 +0800 Subject: [PATCH 33/48] 1 --- webapp/controller/ToolsController.class.php | 5 +++-- webapp/services/BattleBoxService.php | 11 ++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/webapp/controller/ToolsController.class.php b/webapp/controller/ToolsController.class.php index 589d143c..dfdf761d 100644 --- a/webapp/controller/ToolsController.class.php +++ b/webapp/controller/ToolsController.class.php @@ -491,10 +491,11 @@ class ToolsController extends BaseController { echo $checkSql2; } - public function battleBoxDumpToday() + public function battleBoxDump() { $phase = getReqVal('phase', ''); - BattleBoxService::dumpToday($phase); + $day = getReqVal('day', ''); + BattleBoxService::dump($phase, $day); } } diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index 444f7391..1dcc71dc 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -115,14 +115,15 @@ class BattleBoxService { return $boxNum; } - public static function dumpToday($phase) + public static function dump($phase, $day) { + $daySeconds = myself()->_getNowDaySeconds() + $day * 3600 * 24; $data = array( 'phase' => $phase, - 'drop_last_time' => self::getDailyPhaseDropLastTime($phase, myself()->_getNowDaySeconds()), - 'drop_curr_total' => self::getDailyPhaseDropTotalNum($phase, myself()->_getNowDaySeconds()), - 'alloc_num' => self::getDailyPhaseAllocNum($phase, myself()->_getNowDaySeconds()), - 'already_alloced_num' => self::getDailyPhaseAlreadyAllocNum($phase, myself()->_getNowDaySeconds()), + 'drop_last_time' => self::getDailyPhaseDropLastTime($phase, $daySeconds), + 'drop_curr_total' => self::getDailyPhaseDropTotalNum($phase, $daySeconds), + 'alloc_num' => self::getDailyPhaseAllocNum($phase, $daySeconds), + 'already_alloced_num' => self::getDailyPhaseAlreadyAllocNum($phase, $daySeconds), ); myself()->_rspData($data); } From eb9c4271da3316e84909237033a456424e377c56 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 9 Oct 2024 11:56:47 +0800 Subject: [PATCH 34/48] 1 --- webapp/controller/ToolsController.class.php | 14 ++++++++++ webapp/services/BattleBoxService.php | 29 ++++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/webapp/controller/ToolsController.class.php b/webapp/controller/ToolsController.class.php index dfdf761d..d551e0dc 100644 --- a/webapp/controller/ToolsController.class.php +++ b/webapp/controller/ToolsController.class.php @@ -498,4 +498,18 @@ class ToolsController extends BaseController { BattleBoxService::dump($phase, $day); } + public function battleBoxClear() + { + $phase = getReqVal('phase', ''); + $day = getReqVal('day', ''); + BattleBoxService::clear($phase, $day); + } + + public function battleBoxSet() + { + $phase = getReqVal('phase', ''); + $day = getReqVal('day', ''); + BattleBoxService::set($phase, $day); + } + } diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index 1dcc71dc..cf225851 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -121,13 +121,33 @@ class BattleBoxService { $data = array( 'phase' => $phase, 'drop_last_time' => self::getDailyPhaseDropLastTime($phase, $daySeconds), - 'drop_curr_total' => self::getDailyPhaseDropTotalNum($phase, $daySeconds), + 'drop_total' => self::getDailyPhaseDropTotalNum($phase, $daySeconds), 'alloc_num' => self::getDailyPhaseAllocNum($phase, $daySeconds), 'already_alloced_num' => self::getDailyPhaseAlreadyAllocNum($phase, $daySeconds), ); myself()->_rspData($data); } + public static function clear($phase, $day) + { + $daySeconds = myself()->_getNowDaySeconds() + $day * 3600 * 24; + self::getDailyPhaseDropLastTime($phase, $daySeconds, 0); + self::setDailyPhaseDropTotalNum($phase, $daySeconds, 0); + self::setDailyPhaseAllocNum($phase, $daySeconds, 0); + self::setDailyPhaseAlreadyAllocNum($phase, $daySeconds, 0); + self::dump($phase, $day); + } + + public static function set($phase, $day) + { + $daySeconds = myself()->_getNowDaySeconds() + $day * 3600 * 24; + self::getDailyPhaseDropLastTime($phase, $daySeconds, getReqVal('drop_last_time',0 )); + self::setDailyPhaseDropTotalNum($phase, $daySeconds, getReqVal('drop_total',0 )); + self::setDailyPhaseAllocNum($phase, $daySeconds, $daySeconds, getReqVal('alloc_num',0 )); + self::setDailyPhaseAlreadyAllocNum($phase, $daySeconds, getReqVal('already_alloced_num',0 )); + self::dump($phase, $day); + } + private static function getDailyPhaseDropLastTime($phase, $time) { $key = self::DAILY_PHASE_DROP_LAST_TIME_KEY . $phase . ':' . $time; @@ -173,6 +193,13 @@ class BattleBoxService { $r->setPx($key, $val, 1000 * 3600 * 24 * 7); } + private static function setDailyPhaseAlreadyAllocNum($phase, $time, $val) + { + $key = self::DAILY_PHASE_ALREADY_ALLOC_NUM_KEY . $phase . ':' . $time; + $r = myself()->_getRedis($key); + $r->set($key, $val); + } + private static function getDailyPhaseAlreadyAllocNum($phase, $time) { $key = self::DAILY_PHASE_ALREADY_ALLOC_NUM_KEY . $phase . ':' . $time; From 9fd04c4207b7f71b98cdc81739e0fade14896716 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 9 Oct 2024 11:58:14 +0800 Subject: [PATCH 35/48] 1 --- webapp/services/BattleBoxService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index cf225851..31498a8e 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -143,7 +143,7 @@ class BattleBoxService { $daySeconds = myself()->_getNowDaySeconds() + $day * 3600 * 24; self::getDailyPhaseDropLastTime($phase, $daySeconds, getReqVal('drop_last_time',0 )); self::setDailyPhaseDropTotalNum($phase, $daySeconds, getReqVal('drop_total',0 )); - self::setDailyPhaseAllocNum($phase, $daySeconds, $daySeconds, getReqVal('alloc_num',0 )); + self::setDailyPhaseAllocNum($phase, $daySeconds, getReqVal('alloc_num',0 )); self::setDailyPhaseAlreadyAllocNum($phase, $daySeconds, getReqVal('already_alloced_num',0 )); self::dump($phase, $day); } From 52b8da81a9f56163fa8cfcee20ab264a5ab276f4 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 9 Oct 2024 13:19:28 +0800 Subject: [PATCH 36/48] 1 --- webapp/controller/ToolsController.class.php | 9 +++++++++ webapp/services/BattleBoxService.php | 10 ++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/webapp/controller/ToolsController.class.php b/webapp/controller/ToolsController.class.php index d551e0dc..46b9afe1 100644 --- a/webapp/controller/ToolsController.class.php +++ b/webapp/controller/ToolsController.class.php @@ -491,6 +491,15 @@ class ToolsController extends BaseController { echo $checkSql2; } + public function battleBoxAlloc() + { + $phase = getReqVal('phase', ''); + $day = 0; + BattleBoxService::internalClear($phase, $day); + BattleBoxService::allocBox(myself()->_getNowTime()); + BattleBoxService::dump($phase, $day); + } + public function battleBoxDump() { $phase = getReqVal('phase', ''); diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index 31498a8e..3a445a33 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -83,7 +83,7 @@ class BattleBoxService { //没掉完 $completionDegree = $yesterDayDropTotal / $yesterDayAllocNum; } - $allocableNum = min(5000, $maxNum * $completionDegree); + $allocableNum = min($maxNumLimit, $maxNum * $completionDegree); } if ($allocableNum) { self::setDailyPhaseAllocNum($currPhase, myself()->_getNowDaySeconds(), $allocableNum); @@ -128,7 +128,7 @@ class BattleBoxService { myself()->_rspData($data); } - public static function clear($phase, $day) + public static function internalClear($phase, $day) { $daySeconds = myself()->_getNowDaySeconds() + $day * 3600 * 24; self::getDailyPhaseDropLastTime($phase, $daySeconds, 0); @@ -138,6 +138,12 @@ class BattleBoxService { self::dump($phase, $day); } + public static function clear($phase, $day) + { + self::internalClear($phase, $day); + self::dump($phase, $day); + } + public static function set($phase, $day) { $daySeconds = myself()->_getNowDaySeconds() + $day * 3600 * 24; From d359937c1b289945196d77a3ede3db48cf190a1e Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 9 Oct 2024 13:26:14 +0800 Subject: [PATCH 37/48] 1 --- webapp/services/BattleBoxService.php | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index 3a445a33..24b63a33 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -99,17 +99,19 @@ class BattleBoxService { } } if ($boxNum > 0) { - SqlHelper::insert( - myself()->_getSelfMysql(), - 't_box_alloc', - array( - 'room_uuid' => $roomUuid, - 'account_id' => myself()->_getAccountId(), - 'box_num' => $boxNum, - 'createtime' => myself()->_getNowTime(), - 'modifytime' => myself()->_getNowTime(), - ) - ); + if (getReqVal('c', '') != 'Tools') { + SqlHelper::insert( + myself()->_getSelfMysql(), + 't_box_alloc', + array( + 'room_uuid' => $roomUuid, + 'account_id' => myself()->_getAccountId(), + 'box_num' => $boxNum, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime(), + ) + ); + } self::incAlreadyAllocNum($currPhase, myself()->_getNowDaySeconds(), $boxNum); } return $boxNum; From e2825d9804c93eb84f430c2ac9a9fa281405bbc1 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 9 Oct 2024 13:26:48 +0800 Subject: [PATCH 38/48] 1 --- webapp/services/BattleBoxService.php | 1 - 1 file changed, 1 deletion(-) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index 24b63a33..b7d485a7 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -137,7 +137,6 @@ class BattleBoxService { self::setDailyPhaseDropTotalNum($phase, $daySeconds, 0); self::setDailyPhaseAllocNum($phase, $daySeconds, 0); self::setDailyPhaseAlreadyAllocNum($phase, $daySeconds, 0); - self::dump($phase, $day); } public static function clear($phase, $day) From 9e733b837c63e36f44a17340a73a8e652fe905ab Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 9 Oct 2024 13:37:23 +0800 Subject: [PATCH 39/48] 1 --- webapp/mt/MapMode.php | 8 ++++---- webapp/services/BattleBoxService.php | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/webapp/mt/MapMode.php b/webapp/mt/MapMode.php index 71cbdfa5..7cca86d5 100644 --- a/webapp/mt/MapMode.php +++ b/webapp/mt/MapMode.php @@ -131,15 +131,15 @@ class MapMode if (self::configedDailyTimeLimit1($meta)) { $mapModeMeta = $meta; $phase = 1; - $startTime = $meta['daily_open_time']; - $endTime = $meta['daily_end_time']; + $startTime = myself()->_getDaySecondsOffset(strtotime("2024-6-22 ". $meta['daily_open_time'])); + $endTime = myself()->_getDaySecondsOffset(strtotime("2024-6-22 ". $meta['daily_end_time'])); return false; } if (self::configedDailyTimeLimit2($meta)) { $mapModeMeta = $meta; $phase = 2; - $startTime = $meta['daily_open_time_2']; - $endTime = $meta['daily_end_time_2']; + $startTime = myself()->_getDaySecondsOffset(strtotime("2024-6-22 ". $meta['daily_open_time2'])); + $endTime = myself()->_getDaySecondsOffset(strtotime("2024-6-22 ". $meta['daily_end_time2'])); return false; } } diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index b7d485a7..0dc2d889 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -73,6 +73,11 @@ class BattleBoxService { } else { if ($yesterDayDropTotal >= $yesterDayAllocNum) { //掉完了 + error_log(json_encode(array( + 'yesterDayDropLastTime' => $yesterDayDropLastTime, + 'yesterDayDropLastTime2' => myself()->_getDaySecondsOffset($yesterDayDropLastTime), + 'startTime' => $startTime, + ))); $costTime = myself()->_getDaySecondsOffset($yesterDayDropLastTime) - $startTime; if ($costTime <= 0) { $completionDegree = 1; From be803d23e5514bac4cf1f775e73eaf0070aa0521 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 9 Oct 2024 13:48:32 +0800 Subject: [PATCH 40/48] 1 --- webapp/services/BattleBoxService.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index 0dc2d889..8211c80f 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -73,17 +73,19 @@ class BattleBoxService { } else { if ($yesterDayDropTotal >= $yesterDayAllocNum) { //掉完了 - error_log(json_encode(array( - 'yesterDayDropLastTime' => $yesterDayDropLastTime, - 'yesterDayDropLastTime2' => myself()->_getDaySecondsOffset($yesterDayDropLastTime), - 'startTime' => $startTime, - ))); $costTime = myself()->_getDaySecondsOffset($yesterDayDropLastTime) - $startTime; if ($costTime <= 0) { $completionDegree = 1; } else { $completionDegree = ($endTime - $startTime) / $costTime; } + error_log(json_encode(array( + 'yesterDayDropLastTime' => $yesterDayDropLastTime, + 'yesterDayDropLastTime2' => myself()->_getDaySecondsOffset($yesterDayDropLastTime), + 'startTime' => $startTime, + 'costTime' => $costTime, + 'completionDegree' => $completionDegree, + ))); } else { //没掉完 $completionDegree = $yesterDayDropTotal / $yesterDayAllocNum; @@ -153,10 +155,10 @@ class BattleBoxService { public static function set($phase, $day) { $daySeconds = myself()->_getNowDaySeconds() + $day * 3600 * 24; - self::getDailyPhaseDropLastTime($phase, $daySeconds, getReqVal('drop_last_time',0 )); - self::setDailyPhaseDropTotalNum($phase, $daySeconds, getReqVal('drop_total',0 )); - self::setDailyPhaseAllocNum($phase, $daySeconds, getReqVal('alloc_num',0 )); - self::setDailyPhaseAlreadyAllocNum($phase, $daySeconds, getReqVal('already_alloced_num',0 )); + self::setDailyPhaseDropLastTime($phase, $daySeconds, getReqVal('drop_last_time', 0)); + self::setDailyPhaseDropTotalNum($phase, $daySeconds, getReqVal('drop_total', 0)); + self::setDailyPhaseAllocNum($phase, $daySeconds, getReqVal('alloc_num', 0)); + self::setDailyPhaseAlreadyAllocNum($phase, $daySeconds, getReqVal('already_alloced_num', 0)); self::dump($phase, $day); } From d909dcfb37f6ba1e19c4158d57ddd14dd16e6c76 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 9 Oct 2024 14:53:45 +0800 Subject: [PATCH 41/48] 1 --- sql/gamedb.sql | 3 ++- webapp/services/BattleBoxService.php | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 4835120d..2407cc48 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -1940,6 +1940,7 @@ CREATE TABLE `t_box_alloc` ( `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', `room_uuid` varchar(60) NOT NULL COMMENT '公告标题', `account_id` varchar(60) CHARACTER SET utf8 NOT NULL DEFAULT '' COMMENT 'account_id', + `phase` int(11) NOT NULL DEFAULT '0' COMMENT '阶段', `used_num` int(11) NOT NULL DEFAULT '0' COMMENT '已消耗的箱子数', `box_num` int(11) NOT NULL DEFAULT '0' COMMENT '分配的箱子数', `return_account_id` varchar(60) CHARACTER SET utf8 NOT NULL DEFAULT '' COMMENT 'return_account_id', @@ -2116,4 +2117,4 @@ CREATE TABLE `t_user_invitation_code_bind` ( PRIMARY KEY (`idx`), UNIQUE KEY `account_id` (`account_id`) ) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -/*!40101 SET character_set_client = @saved_cs_client */; \ No newline at end of file +/*!40101 SET character_set_client = @saved_cs_client */; diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index 8211c80f..37887e6e 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -113,6 +113,7 @@ class BattleBoxService { array( 'room_uuid' => $roomUuid, 'account_id' => myself()->_getAccountId(), + 'phase' => $phase, 'box_num' => $boxNum, 'createtime' => myself()->_getNowTime(), 'modifytime' => myself()->_getNowTime(), From 8ae383cea85fd6e2e98dbdaecb23542940e2f070 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 9 Oct 2024 14:55:12 +0800 Subject: [PATCH 42/48] 1 --- webapp/services/BattleBoxService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index 37887e6e..8d2af4c1 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -113,7 +113,7 @@ class BattleBoxService { array( 'room_uuid' => $roomUuid, 'account_id' => myself()->_getAccountId(), - 'phase' => $phase, + 'phase' => $currPhase, 'box_num' => $boxNum, 'createtime' => myself()->_getNowTime(), 'modifytime' => myself()->_getNowTime(), From 209b7ba3ffa06b4a16008c25fe636d2531ee1297 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 9 Oct 2024 15:03:03 +0800 Subject: [PATCH 43/48] 1 --- webapp/controller/BattleController.class.php | 67 ++------------------ webapp/services/BattleBoxService.php | 2 +- 2 files changed, 6 insertions(+), 63 deletions(-) diff --git a/webapp/controller/BattleController.class.php b/webapp/controller/BattleController.class.php index f5528504..5690cae0 100644 --- a/webapp/controller/BattleController.class.php +++ b/webapp/controller/BattleController.class.php @@ -1309,15 +1309,7 @@ class BattleController extends BaseAuthedController { $r->setPx(DEC_BATTLE_TICKET . $roomUuid, 1, 1000 * 3600); } - public function requestAllocBoxNumNew() { - $boxNum = services\BattleBoxService::allocBox(''); - myself()->_rspData(array( - 'box_num' => $boxNum - )); - } - - public function requestAllocBoxNum() - { + public function requestAllocBoxNum() { if (!myself()->_switchIsOpen('bigEventBoxDrop')) { myself()->_rspData(array( 'box_num' => 0 @@ -1332,7 +1324,6 @@ class BattleController extends BaseAuthedController { 'room_uuid' => $roomUuid, ) ); - $boxNum = 0; if (!empty($row)) { if ($row['createtime'] > myself()->_getNowDaySeconds()) { $boxNum = $row['box_num']; @@ -1342,40 +1333,10 @@ class BattleController extends BaseAuthedController { )); return; } - $alreadyAllocBoxNum = $this->getAlreadyAllocBoxNum(); - $dailyMaxNum = mt\Parameter::getVal('battle_event_loot_daily_max', 0); - $allocableNum = intval($dailyMaxNum - $alreadyAllocBoxNum); - $lstVal = mt\Parameter::getListValue('battle_event_loot_per_game'); - if ($allocableNum <= 0 || empty($lstVal) || count($lstVal) < 2) { - myself()->_rspData(array( - 'box_num' => 0 - )); - return; - } - $rnd = rand($lstVal[0], $lstVal[1]); - if ($rnd <= 0) { - myself()->_rspData(array( - 'box_num' => 0 - )); - return; - } - $boxNum = min($rnd, $allocableNum); - SqlHelper::insert( - $this->_getSelfMysql(), - 't_box_alloc', - array( - 'room_uuid' => $roomUuid, - 'account_id' => myself()->_getAccountId(), - 'box_num' => $boxNum, - 'createtime' => myself()->_getNowTime(), - 'modifytime' => myself()->_getNowTime(), - ) - ); - $this->incAlreadyAllocBoxNum($boxNum); + $boxNum = services\BattleBoxService::allocBox($roomUuid); myself()->_rspData(array( 'box_num' => $boxNum )); - return; } public function requestReturnBoxNum() @@ -1406,28 +1367,10 @@ class BattleController extends BaseAuthedController { 'return_time' => myself()->_getNowTime(), ) ); - $this->incAlreadyAllocBoxNum(-max(0, $allocBoxNum - $usedNum)); + services\BattleBoxService::incAlreadyAllocBoxNum($row['phase'], + $row['createtime'], + -max(0, $allocBoxNum - $usedNum)); myself()->_rspOk(); } - private function getAlreadyAllocBoxNum() - { - $key = 'box_daily_already_alloc_num:' . myself()->_getNowDaySeconds(); - $r = $this->_getRedis($key); - $num = $r->get($key); - return empty($num) ? 0 : $num; - } - - private function incAlreadyAllocBoxNum($val) - { - $key = 'box_daily_already_alloc_num:' . myself()->_getNowDaySeconds(); - $r = $this->_getRedis($key); - $num = intval($r->get($key)); - if (empty($num)) { - $r->setPx($key, $val, 1000 * 3600 * 24 * 7); - } else { - $r->setPx($key, $num + $val, 1000 * 3600 * 24 * 7); - } - } - } diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index 8d2af4c1..3a78b019 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -223,7 +223,7 @@ class BattleBoxService { return empty($num) ? 0 : $num; } - private static function incAlreadyAllocNum($phase, $time, $val) + public static function incAlreadyAllocNum($phase, $time, $val) { $key = self::DAILY_PHASE_ALREADY_ALLOC_NUM_KEY . $phase . ':' . $time; $r = myself()->_getRedis($key); From 8ac3cd2786761a322d2f854ef59a5722d05f501a Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 9 Oct 2024 15:15:26 +0800 Subject: [PATCH 44/48] 1 --- webapp/services/BattleBoxService.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index 3a78b019..6829b5b1 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -92,9 +92,11 @@ class BattleBoxService { } $allocableNum = min($maxNumLimit, $maxNum * $completionDegree); } - if ($allocableNum) { + if ($allocableNum > 0) { self::setDailyPhaseAllocNum($currPhase, myself()->_getNowDaySeconds(), $allocableNum); } + } else { + } if ($allocableNum > 0) { $lstVal = mt\Parameter::getListValue('battle_event_loot_per_game'); From befc76d16ba8aa30ca4d1d71532eb77c4ba55b48 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 9 Oct 2024 15:20:20 +0800 Subject: [PATCH 45/48] 1 --- webapp/services/BattleBoxService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index 6829b5b1..e7f9dc40 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -96,7 +96,7 @@ class BattleBoxService { self::setDailyPhaseAllocNum($currPhase, myself()->_getNowDaySeconds(), $allocableNum); } } else { - + $allocableNum = max(0, $allocableNum - $alreadyAllocNum); } if ($allocableNum > 0) { $lstVal = mt\Parameter::getListValue('battle_event_loot_per_game'); From 217fd6f543fb37abbc98867e71f7a33396730fe3 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 9 Oct 2024 15:59:50 +0800 Subject: [PATCH 46/48] 1 --- webapp/services/BattleBoxService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/services/BattleBoxService.php b/webapp/services/BattleBoxService.php index e7f9dc40..eaf55b49 100644 --- a/webapp/services/BattleBoxService.php +++ b/webapp/services/BattleBoxService.php @@ -90,7 +90,7 @@ class BattleBoxService { //没掉完 $completionDegree = $yesterDayDropTotal / $yesterDayAllocNum; } - $allocableNum = min($maxNumLimit, $maxNum * $completionDegree); + $allocableNum = min($maxNumLimit, $yesterDayAllocNum * $completionDegree); } if ($allocableNum > 0) { self::setDailyPhaseAllocNum($currPhase, myself()->_getNowDaySeconds(), $allocableNum); From 9af091e1145d642e219b9cacaded4f5c24ec8dca Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 9 Oct 2024 16:32:18 +0800 Subject: [PATCH 47/48] 1 --- webapp/services/RoomBattleDataService.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/webapp/services/RoomBattleDataService.php b/webapp/services/RoomBattleDataService.php index 804b43ed..bfcaba07 100644 --- a/webapp/services/RoomBattleDataService.php +++ b/webapp/services/RoomBattleDataService.php @@ -142,17 +142,17 @@ class RoomBattleDataService extends BaseService { } } + $battleSingleDb = BattleSettlement::findSingle($this->battleSettlementDb['battle_uuid']); if ($this->mapMode == mt\MapMode::TREASURE_BOX_MODE && $member['move_distance'] <= 2000 ){ error_log("金币模式:消极战斗"); }else{ - $this->_getBattleRewards($userDb,$heroDb,$battleScore,$myTeamScoreAvg,$myTeamScore,$member['reward'], $member); + $this->_getBattleRewards($battleSingleDb, $userDb,$heroDb,$battleScore,$myTeamScoreAvg,$myTeamScore,$member['reward'], $member); myself()->_addItems($member['reward'], $awardService,$propertyChgService); if ($this->mapMode == mt\MapMode::GOLD_MODE){ $member['today_hero_battles'] = $heroDb['idx'] . '|' .myself()->_getDailyV(TN_DAILY_GOLD_MODE_BATTLE_TIMES,$heroDb['idx']); } } - $battleSingleDb = BattleSettlement::findSingle($this->battleSettlementDb['battle_uuid']); if ($battleSingleDb){ $battleSingleData = emptyReplace(json_decode($battleSingleDb['data'], true), array()); $battleSingleData['reward'] = $member['reward']; @@ -177,7 +177,7 @@ class RoomBattleDataService extends BaseService { } - public function _getBattleRewards($userDb,$heroDb,$battleScore,$teamScoreAvg,$teamScore,&$reward, $member){ + public function _getBattleRewards($battleSingleDb, $userDb,$heroDb,$battleScore,$teamScoreAvg,$teamScore,&$reward, $member){ error_log('settlementReward -> _getBattleRewards'); $mapModeMeta = mt\MapMode::findByMapMode($this->mapMode); $teamRank = getXVal($this->teamData,'pvp_team_rank', 0); From d70c8aae9b1e7e5ea17957c178796e47cae77d93 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 9 Oct 2024 16:36:01 +0800 Subject: [PATCH 48/48] 1 --- webapp/services/RoomBattleDataService.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/services/RoomBattleDataService.php b/webapp/services/RoomBattleDataService.php index bfcaba07..da5fb11e 100644 --- a/webapp/services/RoomBattleDataService.php +++ b/webapp/services/RoomBattleDataService.php @@ -229,7 +229,7 @@ class RoomBattleDataService extends BaseService { } //宝箱掉落 - $this->_dropBox($rewardMeta,$teamRank,$reward,$member); + $this->_dropBox($battleSingleDb, $rewardMeta,$teamRank,$reward,$member); } } @@ -328,7 +328,7 @@ class RoomBattleDataService extends BaseService { return $gold; } - private function _dropBox($rewardMeta,$teamRank,&$reward,$member){ + private function _dropBox($battleSingleDb, $rewardMeta,$teamRank,&$reward,$member){ //宝箱掉落 $chestLootProbArr = explode(";",$rewardMeta['chestLootProb']); $rate = isset($chestLootProbArr[$teamRank-1]) ? $chestLootProbArr[$teamRank-1] : 0;