merge: trace instant diplomacy responses
This commit is contained in:
@@ -211,6 +211,19 @@ function comparisonApplyTurnFixtureSetup(mixed $setup): void
|
|||||||
$nationStor = KVStorage::getStorage($db, $row['id'], 'nation_env');
|
$nationStor = KVStorage::getStorage($db, $row['id'], 'nation_env');
|
||||||
if (($setup['isolateWorld'] ?? false) === true) {
|
if (($setup['isolateWorld'] ?? false) === true) {
|
||||||
$nationStor->deleteValue('recv_assist');
|
$nationStor->deleteValue('recv_assist');
|
||||||
|
$nationStor->deleteValue('resp_assist');
|
||||||
|
}
|
||||||
|
if (array_key_exists('nationEnv', $row)) {
|
||||||
|
if (!is_array($row['nationEnv'])) {
|
||||||
|
throw new \InvalidArgumentException('setup.nations.nationEnv must be an object');
|
||||||
|
}
|
||||||
|
foreach ($row['nationEnv'] as $key => $value) {
|
||||||
|
if (!is_string($key) || $key === '') {
|
||||||
|
throw new \InvalidArgumentException('setup.nations.nationEnv keys must be non-empty strings');
|
||||||
|
}
|
||||||
|
$nationStor->setValue($key, $value);
|
||||||
|
}
|
||||||
|
$nationStor->resetCache();
|
||||||
}
|
}
|
||||||
if (array_key_exists('turnLastByOfficerLevel', $row)) {
|
if (array_key_exists('turnLastByOfficerLevel', $row)) {
|
||||||
$turnLastByOfficerLevel = $row['turnLastByOfficerLevel'];
|
$turnLastByOfficerLevel = $row['turnLastByOfficerLevel'];
|
||||||
@@ -278,6 +291,7 @@ function comparisonApplyTurnFixtureSetup(mixed $setup): void
|
|||||||
throw new \InvalidArgumentException('setup.generals requires positive integer ids');
|
throw new \InvalidArgumentException('setup.generals requires positive integer ids');
|
||||||
}
|
}
|
||||||
$patch = comparisonMappedPatch($row, [
|
$patch = comparisonMappedPatch($row, [
|
||||||
|
'name' => 'name',
|
||||||
'nationId' => 'nation',
|
'nationId' => 'nation',
|
||||||
'cityId' => 'city',
|
'cityId' => 'city',
|
||||||
'troopId' => 'troop',
|
'troopId' => 'troop',
|
||||||
@@ -382,8 +396,8 @@ function comparisonRunTurnCommand(array $request): array
|
|||||||
throw new \RuntimeException('TURN_DIFFERENTIAL_ENABLED=1 is required');
|
throw new \RuntimeException('TURN_DIFFERENTIAL_ENABLED=1 is required');
|
||||||
}
|
}
|
||||||
$kind = $request['kind'] ?? null;
|
$kind = $request['kind'] ?? null;
|
||||||
if ($kind !== 'general' && $kind !== 'nation') {
|
if (!in_array($kind, ['general', 'nation', 'instantNation'], true)) {
|
||||||
throw new \InvalidArgumentException('kind must be general or nation');
|
throw new \InvalidArgumentException('kind must be general, nation, or instantNation');
|
||||||
}
|
}
|
||||||
$actorGeneralId = $request['actorGeneralId'] ?? null;
|
$actorGeneralId = $request['actorGeneralId'] ?? null;
|
||||||
$action = $request['action'] ?? null;
|
$action = $request['action'] ?? null;
|
||||||
@@ -403,6 +417,36 @@ function comparisonRunTurnCommand(array $request): array
|
|||||||
$gameStorage->resetCache();
|
$gameStorage->resetCache();
|
||||||
$environment = $gameStorage->getAll();
|
$environment = $gameStorage->getAll();
|
||||||
$general = General::createObjFromDB($actorGeneralId);
|
$general = General::createObjFromDB($actorGeneralId);
|
||||||
|
if ($kind === 'instantNation') {
|
||||||
|
$command = buildNationCommandClass($action, $general, $environment, new LastTurn(), $args);
|
||||||
|
if (!$command->hasFullConditionMet()) {
|
||||||
|
throw new \RuntimeException($command->getFailString());
|
||||||
|
}
|
||||||
|
$completed = $command->run(NoRNG::rngInstance());
|
||||||
|
$command->setNextAvailable();
|
||||||
|
$general->getLogger()->flush();
|
||||||
|
$after = comparisonTurnStateSnapshot($snapshotRequest);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'schemaVersion' => 1,
|
||||||
|
'engine' => 'ref',
|
||||||
|
'execution' => [
|
||||||
|
'kind' => $kind,
|
||||||
|
'actorGeneralId' => $actorGeneralId,
|
||||||
|
'action' => $action,
|
||||||
|
'args' => $args,
|
||||||
|
'seedDomain' => 'none',
|
||||||
|
'outcome' => [
|
||||||
|
'lastTurn' => (object)[],
|
||||||
|
'commandName' => $command->getName(),
|
||||||
|
'completed' => $completed,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'before' => $before,
|
||||||
|
'after' => $after,
|
||||||
|
'rng' => [],
|
||||||
|
];
|
||||||
|
}
|
||||||
$turn = new TurnExecutionHelper($general);
|
$turn = new TurnExecutionHelper($general);
|
||||||
$general->increaseInheritancePoint(Enums\InheritanceKey::lived_month, 1);
|
$general->increaseInheritancePoint(Enums\InheritanceKey::lived_month, 1);
|
||||||
$preprocessRng = new RandUtil(new LiteHashDRBG(Util::simpleSerialize(
|
$preprocessRng = new RandUtil(new LiteHashDRBG(Util::simpleSerialize(
|
||||||
|
|||||||
@@ -243,6 +243,10 @@ function comparisonTurnStateSnapshot(array $request): array
|
|||||||
if (is_array($receivedAssist) && $receivedAssist !== []) {
|
if (is_array($receivedAssist) && $receivedAssist !== []) {
|
||||||
$projected['meta']['recv_assist'] = $receivedAssist;
|
$projected['meta']['recv_assist'] = $receivedAssist;
|
||||||
}
|
}
|
||||||
|
$respondedAssist = $nationStor->getValue('resp_assist');
|
||||||
|
if (is_array($respondedAssist) && $respondedAssist !== []) {
|
||||||
|
$projected['meta']['resp_assist'] = $respondedAssist;
|
||||||
|
}
|
||||||
return $projected;
|
return $projected;
|
||||||
},
|
},
|
||||||
comparisonRowsById('nation', 'nation', $nationIds),
|
comparisonRowsById('nation', 'nation', $nationIds),
|
||||||
|
|||||||
Reference in New Issue
Block a user