merge: support multi-turn nation command traces
This commit is contained in:
@@ -190,6 +190,7 @@ function comparisonApplyTurnFixtureSetup(mixed $setup): void
|
|||||||
'diplomacyLimit' => 'surlimit',
|
'diplomacyLimit' => 'surlimit',
|
||||||
'generalCount' => 'gennum',
|
'generalCount' => 'gennum',
|
||||||
'power' => 'power',
|
'power' => 'power',
|
||||||
|
'capitalRevision' => 'capset',
|
||||||
]);
|
]);
|
||||||
if (isset($row['meta'])) {
|
if (isset($row['meta'])) {
|
||||||
$data['aux'] = Json::encode($row['meta']);
|
$data['aux'] = Json::encode($row['meta']);
|
||||||
@@ -205,6 +206,28 @@ function comparisonApplyTurnFixtureSetup(mixed $setup): void
|
|||||||
'aux' => '{}',
|
'aux' => '{}',
|
||||||
];
|
];
|
||||||
$db->insertUpdate('nation', $data, $data);
|
$db->insertUpdate('nation', $data, $data);
|
||||||
|
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 (
|
||||||
|
$officerLevel === false
|
||||||
|
|| $officerLevel < 5
|
||||||
|
|| $officerLevel > 12
|
||||||
|
|| !is_array($lastTurn)
|
||||||
|
) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'setup.nations.turnLastByOfficerLevel requires officer levels 5 through 12'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$nationStor->setValue("turn_last_{$officerLevel}", $lastTurn);
|
||||||
|
}
|
||||||
|
$nationStor->resetCache();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (($setup['isolateWorld'] ?? false) === true && ($setup['nations'] ?? []) !== []) {
|
if (($setup['isolateWorld'] ?? false) === true && ($setup['nations'] ?? []) !== []) {
|
||||||
$maxNationId = max(array_map(
|
$maxNationId = max(array_map(
|
||||||
@@ -393,13 +416,19 @@ function comparisonRunTurnCommand(array $request): array
|
|||||||
\sammo\TextDecoration\SightseeingMessage::setComparisonRng($rng);
|
\sammo\TextDecoration\SightseeingMessage::setComparisonRng($rng);
|
||||||
}
|
}
|
||||||
|
|
||||||
$previousLastTurnRaw = $general->getLastTurn()->toRaw();
|
|
||||||
if ($kind === 'general') {
|
if ($kind === 'general') {
|
||||||
|
$previousLastTurn = $general->getLastTurn();
|
||||||
|
$previousLastTurnRaw = $previousLastTurn->toRaw();
|
||||||
$command = buildGeneralCommandClass($action, $general, $environment, $args);
|
$command = buildGeneralCommandClass($action, $general, $environment, $args);
|
||||||
$resultTurn = $turn->processCommand($rng, $command, false);
|
$resultTurn = $turn->processCommand($rng, $command, false);
|
||||||
} else {
|
} else {
|
||||||
$command = buildNationCommandClass($action, $general, $environment, $general->getLastTurn(), $args);
|
$nationStor = KVStorage::getStorage($db, $general->getNationID(), 'nation_env');
|
||||||
|
$lastNationTurnKey = "turn_last_{$general->getVar('officer_level')}";
|
||||||
|
$previousLastTurn = LastTurn::fromRaw($nationStor->getValue($lastNationTurnKey));
|
||||||
|
$previousLastTurnRaw = $previousLastTurn->toRaw();
|
||||||
|
$command = buildNationCommandClass($action, $general, $environment, $previousLastTurn, $args);
|
||||||
$resultTurn = $turn->processNationCommand($rng, $command);
|
$resultTurn = $turn->processNationCommand($rng, $command);
|
||||||
|
$nationStor->setValue($lastNationTurnKey, $resultTurn->toRaw());
|
||||||
}
|
}
|
||||||
|
|
||||||
$general->getLogger()->flush();
|
$general->getLogger()->flush();
|
||||||
|
|||||||
@@ -231,6 +231,7 @@ function comparisonTurnStateSnapshot(array $request): array
|
|||||||
'power' => 'power',
|
'power' => 'power',
|
||||||
'war' => 'war',
|
'war' => 'war',
|
||||||
'diplomacyLimit' => 'surlimit',
|
'diplomacyLimit' => 'surlimit',
|
||||||
|
'capitalRevision' => 'capset',
|
||||||
'meta' => 'aux',
|
'meta' => 'aux',
|
||||||
],
|
],
|
||||||
['aux'],
|
['aux'],
|
||||||
|
|||||||
Reference in New Issue
Block a user