Prepare game updates and single-process PM2 deployment
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { DEFAULT_GLOBAL_SETTINGS } from '../constants/global-settings.js';
|
||||
import { createMatchEngine } from '../src/shared/match-engine.js';
|
||||
import { matchIntroductionDuration, matchIntroductionMessage } from '../src/shared/match-introduction.js';
|
||||
|
||||
for (const ranked of [false, true]) test(`configurable introduction preserves preparation and first turn (ranked: ${ranked})`, () => {
|
||||
let now = 0;
|
||||
const settings = { ...DEFAULT_GLOBAL_SETTINGS, matchingDelayMs: 4000, matchSuccessDelayMs: 2000, matchPreparationDelayMs: 5000 };
|
||||
const engine = createMatchEngine({ matchId: 'intro', mode: 'friend', selfIndex: 0, clock: { now: () => now }, settings });
|
||||
engine.start(matchIntroductionDuration(settings, ranked));
|
||||
const message = () => matchIntroductionMessage({ ...engine.view(), ranked }, now);
|
||||
assert.equal(message(), ranked ? '랭킹대전 매칭 중…' : '친구 대전 매칭 성공!');
|
||||
if (ranked) { now = 4000; assert.equal(message(), '랭킹대전 매칭 성공!'); }
|
||||
now += 2000;
|
||||
assert.equal(message(), ranked ? '랭킹대전 준비 중…' : '친구 대전 준비 중…');
|
||||
assert.equal(engine.beginTurn(), false);
|
||||
now += 5000;
|
||||
assert.equal(engine.beginTurn(), true);
|
||||
assert.equal(message(), undefined);
|
||||
assert.equal(engine.view().deadline - now, settings.turnDurationMs);
|
||||
});
|
||||
Reference in New Issue
Block a user