mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-12-29 11:26:13 +08:00
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:
parent
ddd5eb40d7
commit
e8339f0a1f
3 changed files with 33 additions and 0 deletions
|
|
@ -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("");
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -304,6 +304,7 @@ export const FunboxNameSchema = z.enum([
|
|||
"ALL_CAPS",
|
||||
"polyglot",
|
||||
"asl",
|
||||
"rot13",
|
||||
"no_quit",
|
||||
]);
|
||||
export type FunboxName = z.infer<typeof FunboxNameSchema>;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue