merge: refresh ng_compare for logical game clock

This commit is contained in:
2026-08-04 12:09:58 +00:00
124 changed files with 2713 additions and 807 deletions
+24 -15
View File
@@ -231,6 +231,7 @@ function comparisonTurnStateSnapshot(array $request): array
$game = KVStorage::getStorage($db, 'game_env');
$game->resetCache();
$clock = GameClock::fromStorage($game);
$worldValues = $game->getValues([
'year',
'month',
@@ -270,7 +271,7 @@ function comparisonTurnStateSnapshot(array $request): array
);
$generals = array_map(
static function (array $row): array {
static function (array $row) use ($clock): array {
$result = comparisonPickRow(
$row,
[
@@ -338,6 +339,10 @@ function comparisonTurnStateSnapshot(array $request): array
] as $key) {
$result[$key] = comparisonOptionalCode($result[$key] ?? null);
}
$result['turnTime'] = $clock->formatTick(Util::toInt($row['turntime']), true);
$result['recentWarTime'] = $row['recent_war'] === null
? null
: $clock->formatTick(Util::toInt($row['recent_war']), true);
$result['maxBelong'] = (int)($result['meta']['max_belong'] ?? 0);
$ownerId = (int)($row['owner'] ?? 0);
$activeActionPoints = 0;
@@ -576,19 +581,23 @@ function comparisonTurnStateSnapshot(array $request): array
}
$messages = array_map(
static fn(array $row): array => comparisonPickRow(
$row,
[
'id' => 'id',
'mailbox' => 'mailbox',
'type' => 'type',
'sourceId' => 'src',
'destinationId' => 'dest',
'createdAt' => 'time',
'payload' => 'message',
],
['message'],
),
static function (array $row) use ($clock): array {
$result = comparisonPickRow(
$row,
[
'id' => 'id',
'mailbox' => 'mailbox',
'type' => 'type',
'sourceId' => 'src',
'destinationId' => 'dest',
'createdAt' => 'time',
'payload' => 'message',
],
['message'],
);
$result['createdAt'] = $clock->formatTick(Util::toInt($row['time']), true);
return $result;
},
$db->query(
'SELECT id, mailbox, type, src, dest, time, message FROM message WHERE id > %i ORDER BY id',
$messageAfterId,
@@ -602,7 +611,7 @@ function comparisonTurnStateSnapshot(array $request): array
'year' => (int)$worldValues['year'],
'month' => (int)$worldValues['month'],
'tickMinutes' => (int)$worldValues['turnterm'],
'turnTime' => (string)$worldValues['turntime'],
'turnTime' => $clock->formatTick(Util::toInt($worldValues['turntime']), true),
'isUnited' => (int)$worldValues['isunited'],
'scenarioId' => (int)$worldValues['scenario'],
'initYear' => (int)$worldValues['init_year'],