From fbac218c3418678a5e9cbf624a37ce6872147f6e Mon Sep 17 00:00:00 2001 From: Hide_D Date: Sat, 10 Jun 2023 22:41:19 +0900 Subject: [PATCH] =?UTF-8?q?fix:=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=B4=88=EA=B8=B0=20=EC=9D=B4?= =?UTF-8?q?=EC=84=B1=EC=9D=B4=20=EC=97=86=EC=9C=BC=EB=A9=B4=20=EB=8F=99?= =?UTF-8?q?=EC=9E=91=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8F=84=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/func_gamerule.php | 39 +++++++++++++++---------- hwe/sammo/Event/Action/RaiseInvader.php | 9 ++++-- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/hwe/func_gamerule.php b/hwe/func_gamerule.php index c1303323..3eb7f996 100644 --- a/hwe/func_gamerule.php +++ b/hwe/func_gamerule.php @@ -909,24 +909,33 @@ function checkEmperior() //연감 월결산 LogHistory(); - $invaderMsgCnt = 2; - foreach(range(12, 5, -1) as $chiefLevel){ - if(!key_exists($chiefLevel, $chiefs)){ - continue; - } - $targetChief = $chiefs[$chiefLevel]; - if($targetChief['npc'] >= 2){ - continue; - } - $invaderMsgs = RaiseInvaderMessage::buildRaiseInvaderMessage($targetChief['no']); - foreach($invaderMsgs as $invaderMsg){ - $invaderMsg->send(); - } - $invaderMsgCnt--; - if($invaderMsgCnt <= 0){ + $availableInvaderGame = false; + foreach(CityConst::all() as $city){ + if($city->level == 4){ + $availableInvaderGame = true; break; } } + if($availableInvaderGame){ + $invaderMsgCnt = 2; + foreach(range(12, 5, -1) as $chiefLevel){ + if(!key_exists($chiefLevel, $chiefs)){ + continue; + } + $targetChief = $chiefs[$chiefLevel]; + if($targetChief['npc'] >= 2){ + continue; + } + $invaderMsgs = RaiseInvaderMessage::buildRaiseInvaderMessage($targetChief['no']); + foreach($invaderMsgs as $invaderMsg){ + $invaderMsg->send(); + } + $invaderMsgCnt--; + if($invaderMsgCnt <= 0){ + break; + } + } + } } function updateMaxDomesticCritical(General $general, $score) diff --git a/hwe/sammo/Event/Action/RaiseInvader.php b/hwe/sammo/Event/Action/RaiseInvader.php index 3e151dd0..c58c069b 100644 --- a/hwe/sammo/Event/Action/RaiseInvader.php +++ b/hwe/sammo/Event/Action/RaiseInvader.php @@ -93,8 +93,6 @@ class RaiseInvader extends \sammo\Event\Action public function run(array $env) { $db = DB::db(); - $gameStor = KVStorage::getStorage($db, 'game_env'); - $gameStor->setValue('isunited', 1); $npcEachCount = $this->npcEachCount; @@ -107,6 +105,13 @@ class RaiseInvader extends \sammo\Event\Action $cities[] = $cityObj; } + if(!$cities){ + return [__CLASS__, 0]; + } + + $gameStor = KVStorage::getStorage($db, 'game_env'); + $gameStor->setValue('isunited', 1); + if ($npcEachCount < 0) { $npcEachCount = $db->queryFirstField('SELECT count(no) from general where npc < 4') / count($cities);