merge: 명령 행렬 fixture 격리를 ng_compare에 반영한다
This commit is contained in:
@@ -124,6 +124,20 @@ function comparisonApplyTurnFixtureSetup(mixed $setup): void
|
|||||||
}
|
}
|
||||||
$game->setValue($key, $value);
|
$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();
|
$game->resetCache();
|
||||||
if (array_key_exists('hiddenSeed', $world)) {
|
if (array_key_exists('hiddenSeed', $world)) {
|
||||||
$hiddenSeed = $world['hiddenSeed'];
|
$hiddenSeed = $world['hiddenSeed'];
|
||||||
@@ -412,8 +426,32 @@ function comparisonApplyTurnFixtureSetup(mixed $setup): void
|
|||||||
if (!is_array($row) || !is_int($row['id'] ?? null) || $row['id'] < 1) {
|
if (!is_array($row) || !is_int($row['id'] ?? null) || $row['id'] < 1) {
|
||||||
throw new \InvalidArgumentException('setup.generals requires positive integer ids');
|
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, [
|
$patch = comparisonMappedPatch($row, [
|
||||||
'name' => 'name',
|
'name' => 'name',
|
||||||
|
'ownerId' => 'owner',
|
||||||
'nationId' => 'nation',
|
'nationId' => 'nation',
|
||||||
'cityId' => 'city',
|
'cityId' => 'city',
|
||||||
'troopId' => 'troop',
|
'troopId' => 'troop',
|
||||||
@@ -460,6 +498,9 @@ function comparisonApplyTurnFixtureSetup(mixed $setup): void
|
|||||||
'itemBook' => 'book',
|
'itemBook' => 'book',
|
||||||
'itemExtra' => 'item',
|
'itemExtra' => 'item',
|
||||||
]);
|
]);
|
||||||
|
if (($setup['isolateWorld'] ?? false) === true && !array_key_exists('ownerId', $row)) {
|
||||||
|
$patch['owner'] = 0;
|
||||||
|
}
|
||||||
if (isset($row['meta'])) {
|
if (isset($row['meta'])) {
|
||||||
$patch['aux'] = Json::encode($row['meta']);
|
$patch['aux'] = Json::encode($row['meta']);
|
||||||
}
|
}
|
||||||
@@ -475,6 +516,12 @@ function comparisonApplyTurnFixtureSetup(mixed $setup): void
|
|||||||
if ($patch !== []) {
|
if ($patch !== []) {
|
||||||
$db->update('general', $patch, 'no = %i', $row['id']);
|
$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)) {
|
if (array_key_exists('nationId', $row)) {
|
||||||
$db->update('rank_data', [
|
$db->update('rank_data', [
|
||||||
'nation_id' => $row['nationId'],
|
'nation_id' => $row['nationId'],
|
||||||
|
|||||||
Reference in New Issue
Block a user