From f2dcb4d4d11a50eb5d4047ef5bbab5a5cf605686 Mon Sep 17 00:00:00 2001 From: hided62 Date: Sat, 25 Jul 2026 20:28:33 +0000 Subject: [PATCH] test: trace monthly scout policy actions --- hwe/compare/fixtures/monthly_block_scout.json | 24 +++++++++++++++++++ .../fixtures/monthly_unblock_scout.json | 24 +++++++++++++++++++ hwe/compare/monthly_event_trace.php | 15 ++++++++++-- 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 hwe/compare/fixtures/monthly_block_scout.json create mode 100644 hwe/compare/fixtures/monthly_unblock_scout.json diff --git a/hwe/compare/fixtures/monthly_block_scout.json b/hwe/compare/fixtures/monthly_block_scout.json new file mode 100644 index 00000000..407418c0 --- /dev/null +++ b/hwe/compare/fixtures/monthly_block_scout.json @@ -0,0 +1,24 @@ +{ + "action": "BlockScoutAction", + "args": [true], + "setup": { + "resetNations": true, + "deleteOtherNations": true, + "keepNationIds": [1, 2], + "nation": [ + { "id": 1, "values": { "name": "위", "level": 2, "scout": 0 } }, + { "id": 2, "values": { "name": "촉", "level": 2, "scout": 0 } } + ], + "gameEnvironment": { + "block_change_scout": false + } + }, + "environment": { + "year": 200, + "month": 1, + "startyear": 190 + }, + "observe": { + "nationIds": [1, 2] + } +} diff --git a/hwe/compare/fixtures/monthly_unblock_scout.json b/hwe/compare/fixtures/monthly_unblock_scout.json new file mode 100644 index 00000000..24e10089 --- /dev/null +++ b/hwe/compare/fixtures/monthly_unblock_scout.json @@ -0,0 +1,24 @@ +{ + "action": "UnblockScoutAction", + "args": [false], + "setup": { + "resetNations": true, + "deleteOtherNations": true, + "keepNationIds": [1, 2], + "nation": [ + { "id": 1, "values": { "name": "위", "level": 2, "scout": 1 } }, + { "id": 2, "values": { "name": "촉", "level": 2, "scout": 1 } } + ], + "gameEnvironment": { + "block_change_scout": true + } + }, + "environment": { + "year": 200, + "month": 1, + "startyear": 190 + }, + "observe": { + "nationIds": [1, 2] + } +} diff --git a/hwe/compare/monthly_event_trace.php b/hwe/compare/monthly_event_trace.php index fa0214aa..af0c8906 100644 --- a/hwe/compare/monthly_event_trace.php +++ b/hwe/compare/monthly_event_trace.php @@ -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(