feat: 이민족 발동 시 장수수에 따라 턴시간 조절

This commit is contained in:
2023-06-11 21:44:22 +09:00
parent 5596eca326
commit 0ef69178a5
+18
View File
@@ -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');