merge: 최신 core2026 main을 특수 명령 작업에 통합

This commit is contained in:
2026-08-15 18:42:17 +00:00
12 changed files with 254 additions and 48 deletions
+4
View File
@@ -4,6 +4,7 @@ import { asRecord } from '@sammo-ts/common';
import { zWorldStateConfig, zWorldStateMeta } from '../../context.js';
import { isSelectionPoolWorld, resolveSelectionMaxGeneral } from '@sammo-ts/game-engine/turn/selectPoolService.js';
import { loadCurrentGameTime } from '../../services/gameClock.js';
import { procedure, router } from '../../trpc.js';
export const lobbyRouter = router({
@@ -26,6 +27,7 @@ export const lobbyRouter = router({
const npcCnt = await ctx.db.general.count({ where: { npcState: { gte: 2 } } });
const nationCnt = await ctx.db.nation.count({ where: { level: { gt: 0 } } });
const scenarioTitle = asRecord(asRecord(rawWorldState.meta).scenarioMeta).title;
const gameTime = await loadCurrentGameTime(ctx.db);
let myGeneral = null;
if (ctx.auth?.user.id) {
@@ -54,6 +56,8 @@ export const lobbyRouter = router({
starttime: worldState.meta.starttime ?? '',
opentime: worldState.meta.opentime ?? '',
turntime: worldState.meta.turntime ?? '',
serverTime: gameTime.now.toISOString(),
clockMode: gameTime.mode ?? 'realtime',
otherTextInfo: worldState.meta.otherTextInfo ?? '',
isUnited: worldState.meta.isunited ?? worldState.meta.isUnited ?? 0,
selectionPoolEnabled: isSelectionPoolWorld(rawWorldState),
+32 -1
View File
@@ -3,7 +3,15 @@ import { describe, expect, it, vi } from 'vitest';
import type { DatabaseClient, GameApiContext } from '../src/context.js';
import { appRouter } from '../src/router.js';
const buildContext = (meta: Record<string, unknown>): GameApiContext =>
const buildContext = (
meta: Record<string, unknown>,
clock: {
baseTime?: Date;
tick?: bigint;
mode?: string;
wallAnchor?: Date;
} = {}
): GameApiContext =>
({
auth: null,
db: {
@@ -16,6 +24,10 @@ const buildContext = (meta: Record<string, unknown>): GameApiContext =>
tickSeconds: 3_600,
config: {},
meta,
clockBaseTime: clock.baseTime ?? null,
clockTick: clock.tick ?? null,
clockMode: clock.mode ?? 'realtime',
clockWallAnchor: clock.wallAnchor ?? null,
updatedAt: new Date('2026-07-31T00:00:00.000Z'),
})),
},
@@ -36,4 +48,23 @@ describe('lobby season state', () => {
expect(result.isUnited).toBe(isunited);
});
it('returns the projected server game time and whether the clock is running', async () => {
const result = await appRouter
.createCaller(
buildContext(
{},
{
baseTime: new Date('2026-08-15T00:00:00.000Z'),
tick: 72_000_000n,
mode: 'manual',
wallAnchor: new Date('2026-08-15T17:00:00.000Z'),
}
)
)
.lobby.info();
expect(result.serverTime).toBe('2026-08-15T02:00:00.000Z');
expect(result.clockMode).toBe('manual');
});
});