merge: observe generated nation command generals

This commit is contained in:
2026-07-26 02:29:03 +00:00
+8
View File
@@ -158,6 +158,7 @@ function comparisonApplyTurnFixtureSetup(mixed $setup): void
throw new \InvalidArgumentException('isolateWorld requires generals and nations');
}
$db->delete('general_turn', 'general_id NOT IN %li', $generalIds);
$db->delete('rank_data', 'general_id NOT IN %li', $generalIds);
$db->delete('nation_turn', 'nation_id NOT IN %li', $nationIds);
$db->delete('troop', '1 = 1');
$db->delete('diplomacy', '1 = 1');
@@ -325,6 +326,13 @@ function comparisonApplyTurnFixtureSetup(mixed $setup): void
$db->update('general', $patch, 'no = %i', $row['id']);
}
}
if (($setup['isolateWorld'] ?? false) === true && ($setup['generals'] ?? []) !== []) {
$maxGeneralId = max(array_map(
static fn(array $row): int => (int)$row['id'],
$setup['generals'],
));
$db->query('ALTER TABLE general AUTO_INCREMENT = %i', $maxGeneralId + 1);
}
foreach ($setup['troops'] ?? [] as $row) {
if (