fix(backend): 생성 장수 첫 턴을 접수 시각에 맞춤
daemon 완료 시각이 뒤처져도 신규 장수 턴을 접수된 논리 게임 시각부터 한 턴 안에 배정한다. 로비 응답에는 보정 시계가 사용할 서버 게임 시각과 clock mode를 추가한다.
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
||||
buildJoinCreateGeneralSeed,
|
||||
cutJoinTurnTime,
|
||||
JOIN_WELCOME_MESSAGE,
|
||||
resolveJoinTurnTime,
|
||||
} from '../src/turn/joinCreateGeneralService.js';
|
||||
|
||||
describe('generic join legacy time contracts', () => {
|
||||
@@ -19,6 +20,35 @@ describe('generic join legacy time contracts', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('schedules a new general within one turn of the accepted game time even when the daemon cursor is stale', () => {
|
||||
const calls: Array<[number, number]> = [];
|
||||
const values = [59, 250_000];
|
||||
const rng = {
|
||||
nextRangeInt(min: number, max: number) {
|
||||
calls.push([min, max]);
|
||||
return values.shift() ?? min;
|
||||
},
|
||||
};
|
||||
const acceptedAt = new Date('2026-08-15T17:57:05.837Z');
|
||||
const staleRuntimeTurnTime = new Date('2026-08-15T07:10:00.000Z');
|
||||
|
||||
const turnTime = resolveJoinTurnTime(
|
||||
rng,
|
||||
{ tickSeconds: 120 } as Parameters<typeof resolveJoinTurnTime>[1],
|
||||
acceptedAt,
|
||||
staleRuntimeTurnTime,
|
||||
undefined
|
||||
);
|
||||
|
||||
expect(turnTime.toISOString()).toBe('2026-08-15T17:58:05.087Z');
|
||||
expect(turnTime.getTime()).toBeGreaterThan(acceptedAt.getTime());
|
||||
expect(turnTime.getTime()).toBeLessThanOrEqual(acceptedAt.getTime() + 120_000);
|
||||
expect(calls).toEqual([
|
||||
[0, 119],
|
||||
[0, 999_999],
|
||||
]);
|
||||
});
|
||||
|
||||
it('uses the HiDCHe product name without the legacy PHP runtime label', () => {
|
||||
expect(JOIN_WELCOME_MESSAGE).toBe('삼국지 모의전투 HiDCHe의 세계에 오신 것을 환영합니다 ^o^');
|
||||
expect(JOIN_WELCOME_MESSAGE).not.toContain('PHP');
|
||||
|
||||
Reference in New Issue
Block a user