forked from devsam/core
feat: 이민족 발동 시 장수수에 따라 턴시간 조절
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user