test: trace monthly scout policy actions

This commit is contained in:
2026-07-25 20:28:33 +00:00
parent de357cfe95
commit f2dcb4d4d1
3 changed files with 61 additions and 2 deletions
+13 -2
View File
@@ -33,7 +33,7 @@ function comparisonMonthlyPatch(string $table, int $id, array $values): void
'idColumn' => 'nation',
'allowed' => [
'name', 'color', 'capital', 'gennum', 'gold', 'rice', 'tech',
'power', 'level', 'type', 'rate_tmp', 'aux',
'power', 'level', 'type', 'rate_tmp', 'scout', 'aux',
],
],
'general' => [
@@ -142,6 +142,7 @@ function comparisonMonthlyDetails(array $observe, int $worldHistoryAfterId): arr
'rice' => 'rice',
'rate' => 'rate_tmp',
'typeCode' => 'type',
'scout' => 'scout',
],
),
comparisonRowsById('nation', 'nation', comparisonIntegerList($observe['nationIds'] ?? [], 'nationIds')),
@@ -209,6 +210,8 @@ function comparisonMonthlyEventTraceMain(): void
'ProvideNPCTroopLeader',
'OpenNationBetting',
'FinishNationBetting',
'BlockScoutAction',
'UnblockScoutAction',
];
if (!in_array($actionName, $supportedActions, true)) {
throw new \InvalidArgumentException('unsupported monthly action');
@@ -420,7 +423,7 @@ function comparisonMonthlyEventTraceMain(): void
throw new \InvalidArgumentException('ProcessSemiAnnual requires resource');
}
$action = new $actionClass($resource);
} elseif (in_array($actionName, ['CreateManyNPC', 'RegNPC', 'RegNeutralNPC', 'RaiseInvader', 'AutoDeleteInvader', 'ChangeCity', 'OpenNationBetting', 'FinishNationBetting'], true)) {
} elseif (in_array($actionName, ['CreateManyNPC', 'RegNPC', 'RegNeutralNPC', 'RaiseInvader', 'AutoDeleteInvader', 'ChangeCity', 'OpenNationBetting', 'FinishNationBetting', 'BlockScoutAction', 'UnblockScoutAction'], true)) {
$args = $request['args'] ?? [];
if (!is_array($args)) {
throw new \InvalidArgumentException("{$actionName} args must be an array");
@@ -440,6 +443,9 @@ function comparisonMonthlyEventTraceMain(): void
if ($actionName === 'FinishNationBetting' && count($args) !== 1) {
throw new \InvalidArgumentException('FinishNationBetting args must have exactly one entry');
}
if (in_array($actionName, ['BlockScoutAction', 'UnblockScoutAction'], true) && count($args) > 1) {
throw new \InvalidArgumentException("{$actionName} args must have at most one entry");
}
$action = new $actionClass(...$args);
} else {
$action = new $actionClass();
@@ -657,6 +663,11 @@ function comparisonMonthlyEventTraceMain(): void
$response['inheritancePrevious'][(string)$ownerId] = is_array($value) ? ($value[0] ?? 0) : 0;
}
}
if (in_array($actionName, ['BlockScoutAction', 'UnblockScoutAction'], true)) {
$response['gameEnvironment'] = KVStorage::getStorage(DB::db(), 'game_env')->getValues([
'block_change_scout',
]);
}
if ($actionName === 'RaiseInvader') {
$response['createdEvents'] = array_map(
static fn(array $row): array => comparisonPickRow(