test: project nation receive-assist state
This commit is contained in:
@@ -206,12 +206,15 @@ function comparisonApplyTurnFixtureSetup(mixed $setup): void
|
|||||||
'aux' => '{}',
|
'aux' => '{}',
|
||||||
];
|
];
|
||||||
$db->insertUpdate('nation', $data, $data);
|
$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)) {
|
if (array_key_exists('turnLastByOfficerLevel', $row)) {
|
||||||
$turnLastByOfficerLevel = $row['turnLastByOfficerLevel'];
|
$turnLastByOfficerLevel = $row['turnLastByOfficerLevel'];
|
||||||
if (!is_array($turnLastByOfficerLevel)) {
|
if (!is_array($turnLastByOfficerLevel)) {
|
||||||
throw new \InvalidArgumentException('setup.nations.turnLastByOfficerLevel must be an object');
|
throw new \InvalidArgumentException('setup.nations.turnLastByOfficerLevel must be an object');
|
||||||
}
|
}
|
||||||
$nationStor = KVStorage::getStorage($db, $row['id'], 'nation_env');
|
|
||||||
foreach ($turnLastByOfficerLevel as $officerLevel => $lastTurn) {
|
foreach ($turnLastByOfficerLevel as $officerLevel => $lastTurn) {
|
||||||
$officerLevel = filter_var($officerLevel, FILTER_VALIDATE_INT);
|
$officerLevel = filter_var($officerLevel, FILTER_VALIDATE_INT);
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -215,7 +215,8 @@ function comparisonTurnStateSnapshot(array $request): array
|
|||||||
);
|
);
|
||||||
|
|
||||||
$nations = array_map(
|
$nations = array_map(
|
||||||
static fn(array $row): array => comparisonPickRow(
|
static function (array $row) use ($db): array {
|
||||||
|
$projected = comparisonPickRow(
|
||||||
$row,
|
$row,
|
||||||
[
|
[
|
||||||
'id' => 'nation',
|
'id' => 'nation',
|
||||||
@@ -235,7 +236,14 @@ function comparisonTurnStateSnapshot(array $request): array
|
|||||||
'meta' => 'aux',
|
'meta' => 'aux',
|
||||||
],
|
],
|
||||||
['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),
|
comparisonRowsById('nation', 'nation', $nationIds),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user