feat(funbox): Add rot13 funbox (@Leonabcd123) (#7116)

### Description

Added a new funbox mode that implements the rot13 cipher, shifting each
character over by 13 places.

I'm not really sure which properties fit best with this...

Implements #6565
This commit is contained in:
Leonabcd123 2025-11-26 23:40:10 +02:00 committed by GitHub
parent ddd5eb40d7
commit e8339f0a1f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 33 additions and 0 deletions

View file

@ -332,6 +332,30 @@ const list: Partial<Record<FunboxName, FunboxFunctions>> = {
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("");

View file

@ -460,6 +460,14 @@ const list: Record<FunboxName, FunboxMetadata> = {
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,

View file

@ -304,6 +304,7 @@ export const FunboxNameSchema = z.enum([
"ALL_CAPS",
"polyglot",
"asl",
"rot13",
"no_quit",
]);
export type FunboxName = z.infer<typeof FunboxNameSchema>;