fix: 가오픈 동안 서버 게임 시계를 정지한다
정식 오픈 시각을 게임 시계 anchor로 전달하고, API가 실제 진행 상태와 시작 경계를 반환하게 한다. 프론트는 추가 조회 없이 경계에서 자동으로 시계를 시작한다.
This commit is contained in:
@@ -50,6 +50,7 @@ export interface ScenarioInstallOptions {
|
||||
joinMode?: 'full' | 'onlyRandom';
|
||||
autorunUser?: ScenarioAutorunOptions | null;
|
||||
preopenAt?: Date | null;
|
||||
openAt?: Date | null;
|
||||
season?: number;
|
||||
firstGameIdx?: number;
|
||||
serverId?: string;
|
||||
@@ -229,11 +230,14 @@ export const seedScenarioToDatabase = async (options: ScenarioSeedOptions): Prom
|
||||
const sync = install?.sync ?? false;
|
||||
const startState = resolveStartState(scenario.startYear ?? null, now, turnTermMinutes, sync);
|
||||
const gameClockMode = options.gameClockMode ?? 'realtime';
|
||||
// A realtime season prepared before its formal opening must not consume
|
||||
// wall time while users are only allowed to edit reserved commands.
|
||||
const initialClockWallAnchor = install?.openAt && install.openAt.getTime() > now.getTime() ? install.openAt : now;
|
||||
const initialClock = new GameClock({
|
||||
baseTime: startState.startTime,
|
||||
tick: 0,
|
||||
mode: gameClockMode,
|
||||
wallAnchor: now,
|
||||
wallAnchor: initialClockWallAnchor,
|
||||
turnSeconds: tickSeconds,
|
||||
});
|
||||
const initialClockTick = initialClock.dateToTick(now);
|
||||
@@ -410,7 +414,7 @@ export const seedScenarioToDatabase = async (options: ScenarioSeedOptions): Prom
|
||||
clockBaseTime: initialClock.baseTime,
|
||||
clockTick: BigInt(initialClockTick),
|
||||
clockMode: gameClockMode,
|
||||
clockWallAnchor: now,
|
||||
clockWallAnchor: initialClock.wallAnchor,
|
||||
lastTurnTick: BigInt(initialClockTick),
|
||||
config: asJson({ ...scenarioConfig, ...worldConfig }),
|
||||
meta: asJson(worldMeta),
|
||||
|
||||
@@ -50,6 +50,7 @@ type ScenarioSeederPrismaClient = {
|
||||
tickSeconds: number;
|
||||
currentYear: number;
|
||||
currentMonth: number;
|
||||
clockWallAnchor: Date | null;
|
||||
} | null>;
|
||||
};
|
||||
gameHistory: {
|
||||
@@ -364,6 +365,8 @@ describeDb('scenario database seed', () => {
|
||||
develop: true,
|
||||
},
|
||||
},
|
||||
preopenAt: new Date('2030-01-01T01:00:00Z'),
|
||||
openAt: new Date('2030-01-01T02:00:00Z'),
|
||||
},
|
||||
});
|
||||
|
||||
@@ -385,6 +388,7 @@ describeDb('scenario database seed', () => {
|
||||
}
|
||||
expect(worldState.tickSeconds).toBe(3600);
|
||||
expect(worldState.currentMonth).toBe(1);
|
||||
expect(worldState.clockWallAnchor).toEqual(new Date('2030-01-01T02:00:00.000Z'));
|
||||
|
||||
const config = (worldState.config ?? {}) as Record<string, unknown>;
|
||||
expect(config.extendedGeneral).toBe(false);
|
||||
|
||||
Reference in New Issue
Block a user