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);