Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions frontend/src/ts/test/funbox/funbox-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,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("");
Expand Down
8 changes: 8 additions & 0 deletions packages/funbox/src/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,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,
Expand Down
1 change: 1 addition & 0 deletions packages/schemas/src/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ export const FunboxNameSchema = z.enum([
"ALL_CAPS",
"polyglot",
"asl",
"rot13",
"no_quit",
]);
export type FunboxName = z.infer<typeof FunboxNameSchema>;
Expand Down