From 0ef69178a58d1fc30948617d8875c40918882727 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Sun, 11 Jun 2023 21:44:22 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=9D=B4=EB=AF=BC=EC=A1=B1=20=EB=B0=9C?= =?UTF-8?q?=EB=8F=99=20=EC=8B=9C=20=EC=9E=A5=EC=88=98=EC=88=98=EC=97=90=20?= =?UTF-8?q?=EB=94=B0=EB=9D=BC=20=ED=84=B4=EC=8B=9C=EA=B0=84=20=EC=A1=B0?= =?UTF-8?q?=EC=A0=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/Event/Action/RaiseInvader.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/hwe/sammo/Event/Action/RaiseInvader.php b/hwe/sammo/Event/Action/RaiseInvader.php index c58c069b..b1772f36 100644 --- a/hwe/sammo/Event/Action/RaiseInvader.php +++ b/hwe/sammo/Event/Action/RaiseInvader.php @@ -12,6 +12,8 @@ use sammo\LiteHashDRBG; use sammo\RandUtil; use sammo\Scenario\GeneralBuilder; use sammo\Scenario\Nation; +use sammo\ServerEnv; +use sammo\ServerTool; use sammo\UniqueConst; use sammo\Util; @@ -112,6 +114,9 @@ class RaiseInvader extends \sammo\Event\Action $gameStor = KVStorage::getStorage($db, 'game_env'); $gameStor->setValue('isunited', 1); + $turnterm = $gameStor->turnterm; + $generalCnt = $db->queryFirstField('SELECT count(*) FROM general'); + if ($npcEachCount < 0) { $npcEachCount = $db->queryFirstField('SELECT count(no) from general where npc < 4') / count($cities); @@ -119,6 +124,19 @@ class RaiseInvader extends \sammo\Event\Action } $npcEachCount = max(10, Util::toInt($npcEachCount)); + + $totalGenerals = $npcEachCount * count($cities) + $generalCnt; + if ($totalGenerals > ServerEnv::$maxGeneralsPerMinute * $turnterm) { + foreach ([1, 2, 5, 10, 20, 30, 60, 120] as $nextTurnterm) { + if ($totalGenerals > ServerEnv::$maxGeneralsPerMinute * $nextTurnterm) { + continue; + } + + ServerTool::changeServerTerm($nextTurnterm); + break; + } + } + $specAvg = $this->specAvg; if ($specAvg < 0) { $specAvg = $db->queryFirstField('SELECT avg((`leadership` + `strength` + `intel`)) from general where npc < 4');