diff --git a/frontend/src/ts/test/funbox/funbox-functions.ts b/frontend/src/ts/test/funbox/funbox-functions.ts index d26512871..f461fe6b3 100644 --- a/frontend/src/ts/test/funbox/funbox-functions.ts +++ b/frontend/src/ts/test/funbox/funbox-functions.ts @@ -332,6 +332,30 @@ const list: Partial> = { return randomcaseword; }, }, + rot13: { + alterText(word: string): string { + let alphabet = "abcdefghijklmnopqrstuvwxyz"; + + let rot13Word = ""; + + for (let ch of word) { + let chIndex = alphabet.indexOf(ch.toLowerCase()); + if (chIndex === -1) { + rot13Word += ch; + continue; + } + + let rot13Ch = (chIndex + 13) % 26; + if (ch.toUpperCase() === ch) { + rot13Word += alphabet[rot13Ch]?.toUpperCase(); + } else { + rot13Word += alphabet[rot13Ch]; + } + } + + return rot13Word; + }, + }, backwards: { alterText(word: string): string { return word.split("").reverse().join(""); diff --git a/packages/funbox/src/list.ts b/packages/funbox/src/list.ts index 84aab9025..3c1819982 100644 --- a/packages/funbox/src/list.ts +++ b/packages/funbox/src/list.ts @@ -460,6 +460,14 @@ const list: Record = { name: "asl", cssModifications: ["words"], }, + rot13: { + description: "Vg znl abg or frpher, ohg vg vf sha gb glcr!", + canGetPb: true, + difficultyLevel: 1, + properties: [], + frontendFunctions: ["alterText"], + name: "rot13", + }, no_quit: { description: "You can't restart the test.", canGetPb: true, diff --git a/packages/schemas/src/configs.ts b/packages/schemas/src/configs.ts index 3007b5435..e7a88b2cc 100644 --- a/packages/schemas/src/configs.ts +++ b/packages/schemas/src/configs.ts @@ -304,6 +304,7 @@ export const FunboxNameSchema = z.enum([ "ALL_CAPS", "polyglot", "asl", + "rot13", "no_quit", ]); export type FunboxName = z.infer;