- packages/engine: 시드 RNG(sfc32), GameDefinition 타입, 무작위 대국·정보 유출 테스트 도구 - packages/shared: WS 프로토콜 스키마, 닉네임·방 코드 규칙, 게임 카탈로그 - packages/games/omok: 한국식·렌주·자유룰, 재귀 금수 판정, 무르기·무승부·시계 (테스트 27개) - apps/server: SQLite 스키마, 게스트·디스코드 로그인, 세션, 방 관리(저장·복구·타이머·재접속), WS 게이트웨이, HTTP API Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
21 lines
727 B
TypeScript
21 lines
727 B
TypeScript
/** 6-digit numeric room codes, docs/06-lobby-rooms.md §3. */
|
|
export function normalizeRoomCode(input: string): string | null {
|
|
const m = input.match(/\/r\/(\d{6})\b/);
|
|
if (m) return m[1]!;
|
|
const digits = input.replace(/[\s\-]/g, '');
|
|
return /^\d{6}$/.test(digits) ? digits : null;
|
|
}
|
|
|
|
export function isAllowedRoomCode(code: string): boolean {
|
|
if (!/^\d{6}$/.test(code)) return false;
|
|
if (/^(\d)\1{5}$/.test(code)) return false; // 000000, 111111, ...
|
|
const asc = '0123456789';
|
|
const desc = '9876543210';
|
|
if (asc.includes(code) || desc.includes(code)) return false; // 123456, 654321
|
|
return true;
|
|
}
|
|
|
|
export function formatRoomCode(code: string): string {
|
|
return `${code.slice(0, 3)} ${code.slice(3)}`;
|
|
}
|