60 lines
2.8 KiB
TypeScript
60 lines
2.8 KiB
TypeScript
/**
|
|
* Guard (docs/04 §6, reviewer request): betting-game UI text must never look like real money.
|
|
* Scans the betting games' screens and shared chip/card components for currency-like wording.
|
|
*
|
|
* Exception (2026-10-13, user request "한게임 섯다처럼 원과 판돈으로"): 섯다 shows its room-only play money in "원" and
|
|
* calls the pot "판돈", like 한게임 섯다. Only those two are allowed there; currency symbols, 현금·머니·골드, "돈을/돈이/돈은"
|
|
* and transaction words (충전·환전·결제 …) stay forbidden in 섯다 too.
|
|
*/
|
|
import { expect, test } from 'bun:test';
|
|
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
|
|
import { join } from 'node:path';
|
|
|
|
const ROOTS = ['games/poker', 'games/seotda', 'games/gostop', 'games/marble', 'games/las-vegas', 'components/cards'].map((p) => join(import.meta.dir, p));
|
|
const SEOTDA = join(import.meta.dir, 'games/seotda');
|
|
const FORBIDDEN: [RegExp, string][] = [
|
|
[/₩|\$\s?\d|\d\s?\$/, '통화 기호'],
|
|
[/\d[\d,]*\s*(만\s*)?원(?![가-힣])/, '"원" 단위'],
|
|
[/판돈|돈을|돈이|돈은|현금|머니|골드/, '돈을 떠올리는 낱말'],
|
|
[/충전|환전|입금|출금|송금|결제|구매/, '거래 낱말'],
|
|
];
|
|
|
|
function files(dir: string): string[] {
|
|
if (!existsSync(dir)) return [];
|
|
return readdirSync(dir).flatMap((f) => {
|
|
const p = join(dir, f);
|
|
return statSync(p).isDirectory() ? files(p) : /\.(tsx?|css)$/.test(f) ? [p] : [];
|
|
});
|
|
}
|
|
|
|
/** Only string literals / JSX text matter; comments are ignored. */
|
|
function visibleText(src: string): string {
|
|
return src.replace(/\/\*[\s\S]*?\*\//g, '').replace(/(^|[^:])\/\/.*$/gm, '$1');
|
|
}
|
|
|
|
test('no currency-like wording in betting game UI', () => {
|
|
const problems: string[] = [];
|
|
for (const f of ROOTS.flatMap(files)) {
|
|
const seotda = f.startsWith(SEOTDA);
|
|
const text = visibleText(readFileSync(f, 'utf8'));
|
|
text.split('\n').forEach((line, i) => {
|
|
// 섯다: "판돈" is the game's word for the pot; the other 돈 words are still checked.
|
|
const checked = seotda ? line.replace(/판돈/g, '') : line;
|
|
for (const [re, why] of FORBIDDEN) {
|
|
if (seotda && why === '"원" 단위') continue;
|
|
if (re.test(checked)) problems.push(`${f.split('/src/')[1]}:${i + 1} ${why}: ${line.trim().slice(0, 80)}`);
|
|
}
|
|
});
|
|
}
|
|
expect(problems).toEqual([]);
|
|
});
|
|
|
|
test('섯다 exception is narrow: 원 and 판돈 only', () => {
|
|
const lines = ['판돈 1만원', '판돈은 그대로', '10만원 충전', '₩1000', '게임머니', '돈을 걸어요', '현금'];
|
|
const bad = lines.filter((line) => {
|
|
const checked = line.replace(/판돈/g, '');
|
|
return FORBIDDEN.some(([re, why]) => why !== '"원" 단위' && re.test(checked));
|
|
});
|
|
expect(bad).toEqual(['10만원 충전', '₩1000', '게임머니', '돈을 걸어요', '현금']);
|
|
});
|