V1.0.0
Two Keys: co-op mystery games for couples. Eight games on four engines (story, defuse, sync, labyrinth), two-device and couch play, mobile-first UI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Answer normalizer: uppercase → strip accents → drop everything except A-Z and 0-9.
|
||||
* "20:40" and "20 40" → "2040"; "Fire Swart, Friday!" → "FIRESWARTFRIDAY".
|
||||
*/
|
||||
export function normalizeAnswer(input: string): string {
|
||||
return String(input)
|
||||
.toUpperCase()
|
||||
.normalize('NFD')
|
||||
.replace(/[̀-ͯ]/g, '')
|
||||
.replace(/[^A-Z0-9]/g, '');
|
||||
}
|
||||
|
||||
/** True if the normalized input equals any normalized accepted answer. */
|
||||
export function matchesAnswer(input: string, answers: readonly string[]): boolean {
|
||||
const value = normalizeAnswer(input);
|
||||
if (value === '') return false;
|
||||
return answers.some((answer) => normalizeAnswer(answer) === value);
|
||||
}
|
||||
Reference in New Issue
Block a user