mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-28 08:43:07 +08:00
added morse code to the funbox (#4451) epicjoanna
* added morse code mode to funbox * actioned changes
This commit is contained in:
parent
06ca56bfc8
commit
6d88c4f4e3
5 changed files with 89 additions and 0 deletions
|
@ -307,6 +307,13 @@ const FunboxList: MonkeyTypes.FunboxMetadata[] = [
|
|||
frontendFunctions: ["getWordsFrequencyMode"],
|
||||
name: "zipf",
|
||||
},
|
||||
{
|
||||
canGetPb: false,
|
||||
difficultyLevel: 1,
|
||||
properties: ["ignoresLanguage", "ignoresLayout", "noLetters", "noSpace"],
|
||||
frontendFunctions: ["alterText"],
|
||||
name: "morse",
|
||||
},
|
||||
];
|
||||
|
||||
export default FunboxList;
|
||||
|
|
|
@ -224,6 +224,11 @@ const list: MonkeyTypes.FunboxMetadata[] = [
|
|||
info: "Words are generated according to Zipf's law. (not all languages will produce Zipfy results, use with caution)",
|
||||
properties: ["changesWordsFrequency"],
|
||||
},
|
||||
{
|
||||
name: "morse",
|
||||
info: "-.../././.--./ -.../---/---/.--./-.-.--/ ",
|
||||
properties: ["ignoresLanguage", "ignoresLayout", "noLetters", "nospace"],
|
||||
},
|
||||
];
|
||||
|
||||
export function getAll(): MonkeyTypes.FunboxMetadata[] {
|
||||
|
|
|
@ -723,3 +723,9 @@ export async function rememberSettings(): Promise<void> {
|
|||
if (funbox.functions?.rememberSettings) funbox.functions.rememberSettings();
|
||||
});
|
||||
}
|
||||
|
||||
FunboxList.setFunboxFunctions("morse", {
|
||||
alterText(word: string): string {
|
||||
return Misc.convertToMorse(word);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1539,3 +1539,69 @@ export function isToday(timestamp: number): boolean {
|
|||
|
||||
return today === date;
|
||||
}
|
||||
|
||||
export function convertToMorse(word: string): string {
|
||||
const morseCode: { [id: string]: string } = {
|
||||
a: ".-",
|
||||
b: "-...",
|
||||
c: "-.-.",
|
||||
d: "-..",
|
||||
e: ".",
|
||||
f: "..-.",
|
||||
g: "--.",
|
||||
h: "....",
|
||||
i: "..",
|
||||
j: ".---",
|
||||
k: "-.-",
|
||||
l: ".-..",
|
||||
m: "--",
|
||||
n: "-.",
|
||||
o: "---",
|
||||
p: ".--.",
|
||||
q: "--.-",
|
||||
r: ".-.",
|
||||
s: "...",
|
||||
t: "-",
|
||||
u: "..-",
|
||||
v: "...-",
|
||||
w: ".--",
|
||||
x: "-..-",
|
||||
y: "-.--",
|
||||
z: "--..",
|
||||
"0": "-----",
|
||||
"1": ".----",
|
||||
"2": "..---",
|
||||
"3": "...--",
|
||||
"4": "....-",
|
||||
"5": ".....",
|
||||
"6": "-....",
|
||||
"7": "--...",
|
||||
"8": "---..",
|
||||
"9": "----.",
|
||||
".": ".-.-.-",
|
||||
",": "--..--",
|
||||
"?": "..--..",
|
||||
"'": ".----.",
|
||||
"/": "-..-.",
|
||||
"(": "-.--.",
|
||||
")": "-.--.-",
|
||||
"&": ".-...",
|
||||
":": "---...",
|
||||
";": "-.-.-.",
|
||||
"=": "-...-",
|
||||
"+": ".-.-.",
|
||||
"-": "-....-",
|
||||
_: "..--.-",
|
||||
'"': ".-..-.",
|
||||
$: "...-..-",
|
||||
"!": "-.-.--",
|
||||
"@": ".--.-.",
|
||||
};
|
||||
|
||||
let morseWord = "";
|
||||
|
||||
for (let i = 0; i < word.length; i++) {
|
||||
morseWord += morseCode[word.toLowerCase()[i]] + "/";
|
||||
}
|
||||
return morseWord;
|
||||
}
|
||||
|
|
|
@ -165,5 +165,10 @@
|
|||
"name": "zipf",
|
||||
"info": "Words are generated according to Zipf's law. (not all languages will produce Zipfy results, use with caution)",
|
||||
"canGetPb": false
|
||||
},
|
||||
{
|
||||
"name": "morse",
|
||||
"info": "-.../././.--./ -.../---/---/.--./-.-.--/ ",
|
||||
"canGetPb": false
|
||||
}
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue