From 7af9f675babf384d7bf8b25a66ebf1faf811b2b4 Mon Sep 17 00:00:00 2001 From: hided62 Date: Mon, 24 Aug 2026 19:45:28 +0000 Subject: [PATCH] =?UTF-8?q?test(compare):=20=EB=AA=85=EB=A0=B9=20=ED=96=89?= =?UTF-8?q?=EB=A0=AC=EC=9D=98=20=EC=84=B8=EA=B3=84=20=EB=B0=8F=20=EC=83=81?= =?UTF-8?q?=EC=86=8D=20fixture=EB=A5=BC=20=EA=B2=A9=EB=A6=AC=ED=95=9C?= =?UTF-8?q?=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/compare/turn_command_trace.php | 47 ++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/hwe/compare/turn_command_trace.php b/hwe/compare/turn_command_trace.php index 908439bc..be1a1b47 100644 --- a/hwe/compare/turn_command_trace.php +++ b/hwe/compare/turn_command_trace.php @@ -124,6 +124,20 @@ function comparisonApplyTurnFixtureSetup(mixed $setup): void } $game->setValue($key, $value); } + if (array_key_exists('develCost', $world)) { + $develCost = $world['develCost']; + if (!is_int($develCost) || $develCost < 0) { + throw new \InvalidArgumentException('setup.world.develCost is invalid'); + } + $game->setValue('develcost', $develCost); + } + if (array_key_exists('isUnited', $world)) { + $isUnited = $world['isUnited']; + if (!is_int($isUnited) || $isUnited < 0 || $isUnited > 3) { + throw new \InvalidArgumentException('setup.world.isUnited is invalid'); + } + $game->setValue('isunited', $isUnited); + } $game->resetCache(); if (array_key_exists('hiddenSeed', $world)) { $hiddenSeed = $world['hiddenSeed']; @@ -412,8 +426,32 @@ function comparisonApplyTurnFixtureSetup(mixed $setup): void if (!is_array($row) || !is_int($row['id'] ?? null) || $row['id'] < 1) { throw new \InvalidArgumentException('setup.generals requires positive integer ids'); } + if (array_key_exists('ownerId', $row) && (!is_int($row['ownerId']) || $row['ownerId'] < 0)) { + throw new \InvalidArgumentException('setup.generals.ownerId must be a non-negative integer'); + } + if ( + array_key_exists('inheritActiveActionPoints', $row) + && (!array_key_exists('ownerId', $row) || !is_int($row['ownerId']) || $row['ownerId'] < 1) + ) { + throw new \InvalidArgumentException( + 'setup.generals.inheritActiveActionPoints requires a positive ownerId', + ); + } + if ( + array_key_exists('inheritActiveActionPoints', $row) + && ( + (!is_int($row['inheritActiveActionPoints']) && !is_float($row['inheritActiveActionPoints'])) + || !is_finite($row['inheritActiveActionPoints']) + || $row['inheritActiveActionPoints'] < 0 + ) + ) { + throw new \InvalidArgumentException( + 'setup.generals.inheritActiveActionPoints must be a finite non-negative number', + ); + } $patch = comparisonMappedPatch($row, [ 'name' => 'name', + 'ownerId' => 'owner', 'nationId' => 'nation', 'cityId' => 'city', 'troopId' => 'troop', @@ -460,6 +498,9 @@ function comparisonApplyTurnFixtureSetup(mixed $setup): void 'itemBook' => 'book', 'itemExtra' => 'item', ]); + if (($setup['isolateWorld'] ?? false) === true && !array_key_exists('ownerId', $row)) { + $patch['owner'] = 0; + } if (isset($row['meta'])) { $patch['aux'] = Json::encode($row['meta']); } @@ -475,6 +516,12 @@ function comparisonApplyTurnFixtureSetup(mixed $setup): void if ($patch !== []) { $db->update('general', $patch, 'no = %i', $row['id']); } + if (array_key_exists('inheritActiveActionPoints', $row)) { + $ownerId = $row['ownerId']; + $inheritanceStorage = KVStorage::getStorage($db, "inheritance_{$ownerId}"); + $inheritanceStorage->setValue('active_action', [$row['inheritActiveActionPoints'], null]); + $inheritanceStorage->resetCache(); + } if (array_key_exists('nationId', $row)) { $db->update('rank_data', [ 'nation_id' => $row['nationId'],