From e58ffab2a2b8fc2851631aefdc1c5af1bd702588 Mon Sep 17 00:00:00 2001 From: hided62 Date: Sun, 26 Jul 2026 01:44:22 +0000 Subject: [PATCH] test: project nation receive-assist state --- hwe/compare/turn_command_trace.php | 5 ++- hwe/compare/turn_state_snapshot.php | 50 +++++++++++++++++------------ 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/hwe/compare/turn_command_trace.php b/hwe/compare/turn_command_trace.php index 4f36f84f..2473d522 100644 --- a/hwe/compare/turn_command_trace.php +++ b/hwe/compare/turn_command_trace.php @@ -206,12 +206,15 @@ function comparisonApplyTurnFixtureSetup(mixed $setup): void 'aux' => '{}', ]; $db->insertUpdate('nation', $data, $data); + $nationStor = KVStorage::getStorage($db, $row['id'], 'nation_env'); + if (($setup['isolateWorld'] ?? false) === true) { + $nationStor->deleteValue('recv_assist'); + } if (array_key_exists('turnLastByOfficerLevel', $row)) { $turnLastByOfficerLevel = $row['turnLastByOfficerLevel']; if (!is_array($turnLastByOfficerLevel)) { throw new \InvalidArgumentException('setup.nations.turnLastByOfficerLevel must be an object'); } - $nationStor = KVStorage::getStorage($db, $row['id'], 'nation_env'); foreach ($turnLastByOfficerLevel as $officerLevel => $lastTurn) { $officerLevel = filter_var($officerLevel, FILTER_VALIDATE_INT); if ( diff --git a/hwe/compare/turn_state_snapshot.php b/hwe/compare/turn_state_snapshot.php index bb1c95bb..ffd8fd97 100644 --- a/hwe/compare/turn_state_snapshot.php +++ b/hwe/compare/turn_state_snapshot.php @@ -215,27 +215,35 @@ function comparisonTurnStateSnapshot(array $request): array ); $nations = array_map( - static fn(array $row): array => comparisonPickRow( - $row, - [ - 'id' => 'nation', - 'name' => 'name', - 'color' => 'color', - 'capitalCityId' => 'capital', - 'gold' => 'gold', - 'rice' => 'rice', - 'tech' => 'tech', - 'level' => 'level', - 'typeCode' => 'type', - 'generalCount' => 'gennum', - 'power' => 'power', - 'war' => 'war', - 'diplomacyLimit' => 'surlimit', - 'capitalRevision' => 'capset', - 'meta' => 'aux', - ], - ['aux'], - ), + static function (array $row) use ($db): array { + $projected = comparisonPickRow( + $row, + [ + 'id' => 'nation', + 'name' => 'name', + 'color' => 'color', + 'capitalCityId' => 'capital', + 'gold' => 'gold', + 'rice' => 'rice', + 'tech' => 'tech', + 'level' => 'level', + 'typeCode' => 'type', + 'generalCount' => 'gennum', + 'power' => 'power', + 'war' => 'war', + 'diplomacyLimit' => 'surlimit', + 'capitalRevision' => 'capset', + 'meta' => 'aux', + ], + ['aux'], + ); + $nationStor = KVStorage::getStorage($db, (int)$row['nation'], 'nation_env'); + $receivedAssist = $nationStor->getValue('recv_assist'); + if (is_array($receivedAssist) && $receivedAssist !== []) { + $projected['meta']['recv_assist'] = $receivedAssist; + } + return $projected; + }, comparisonRowsById('nation', 'nation', $nationIds), );