mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-27 17:27:32 +08:00
Implemented an ITG arrow mode to the funbox (#4084) spiritaxolotl
* added arrows ITG to the list
* added the implementation for arrows_ITG
I also updated "arrows" so it supported ijkl as well as the normal arrowkeys and wasd
* the actual implementation of the arrow generation
I forgot to commit this one whoops
* missed a curly bracket whoops
* overwritten the arrows generation
Instead of having two similar funboxes, miodec just said to implement the new generation in the existing arrows funbox.
removed the arrows_ITG now
next commit will remove it from the list as well
* removed arrows_ITG and updated arrows
* removed arrows' old generation method
* updated a mistake
* lint, prettier
* added the TODO comment back
didn't realize I removed it sorry
* remove spaces
* gave the variable names something more descriptive
* remove preivous variables
I hate working remotely
* small refactor
* simplify
* simplify
* remove export
* starts with a left or right
* prettier fix
* removed "export"
the function wasn't getting called outside of the file
* parity for a list description
* fixed that one character that got overwritten
* Revert "fixed that one character that got overwritten"
This reverts commit c8a394dc7b.
---------
Co-authored-by: Miodec <jack@monkeytype.com>
Co-authored-by: Evan <evanrayweigel@outlook.com>
Co-authored-by: Evan <64989416+Ferotiq@users.noreply.github.com>
This commit is contained in:
parent
ba4c7a1c61
commit
14da1438d9
4 changed files with 84 additions and 22 deletions
|
|
@ -38,7 +38,7 @@ const list: MonkeyTypes.FunboxMetadata[] = [
|
|||
},
|
||||
{
|
||||
name: "arrows",
|
||||
info: "Eurobeat Intensifies...",
|
||||
info: "Play it on a pad!",
|
||||
properties: [
|
||||
"ignoresLanguage",
|
||||
"ignoresLayout",
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ FunboxList.setFunboxFunctions("choo_choo", {
|
|||
|
||||
FunboxList.setFunboxFunctions("arrows", {
|
||||
getWord(): string {
|
||||
return Misc.getArrows();
|
||||
return Misc.chart2Word();
|
||||
},
|
||||
applyConfig(): void {
|
||||
$("#words").addClass("arrows");
|
||||
|
|
@ -169,31 +169,43 @@ FunboxList.setFunboxFunctions("arrows", {
|
|||
save("highlightMode", Config.highlightMode, UpdateConfig.setHighlightMode);
|
||||
},
|
||||
handleChar(char: string): string {
|
||||
if (char === "a" || char === "ArrowLeft") {
|
||||
if (char === "a" || char === "ArrowLeft" || char === "j") {
|
||||
return "←";
|
||||
}
|
||||
if (char === "s" || char === "ArrowDown") {
|
||||
if (char === "s" || char === "ArrowDown" || char === "k") {
|
||||
return "↓";
|
||||
}
|
||||
if (char === "w" || char === "ArrowUp") {
|
||||
if (char === "w" || char === "ArrowUp" || char === "i") {
|
||||
return "↑";
|
||||
}
|
||||
if (char === "d" || char === "ArrowRight") {
|
||||
if (char === "d" || char === "ArrowRight" || char === "l") {
|
||||
return "→";
|
||||
}
|
||||
return char;
|
||||
},
|
||||
isCharCorrect(char: string, originalChar: string): boolean {
|
||||
if ((char === "a" || char === "ArrowLeft") && originalChar === "←") {
|
||||
if (
|
||||
(char === "a" || char === "ArrowLeft" || char === "j") &&
|
||||
originalChar === "←"
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
if ((char === "s" || char === "ArrowDown") && originalChar === "↓") {
|
||||
if (
|
||||
(char === "s" || char === "ArrowDown" || char === "k") &&
|
||||
originalChar === "↓"
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
if ((char === "w" || char === "ArrowUp") && originalChar === "↑") {
|
||||
if (
|
||||
(char === "w" || char === "ArrowUp" || char === "i") &&
|
||||
originalChar === "↑"
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
if ((char === "d" || char === "ArrowRight") && originalChar === "→") {
|
||||
if (
|
||||
(char === "d" || char === "ArrowRight" || char === "l") &&
|
||||
originalChar === "→"
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -722,19 +722,69 @@ export function getASCII(): string {
|
|||
return ret;
|
||||
}
|
||||
|
||||
export function getArrows(): string {
|
||||
const arrowArray = ["←", "↑", "→", "↓"];
|
||||
let arrowWord = "";
|
||||
let lastchar;
|
||||
for (let i = 0; i < 5; i++) {
|
||||
let random = randomElementFromArray(arrowArray);
|
||||
while (random === lastchar) {
|
||||
random = randomElementFromArray(arrowArray);
|
||||
// code for "generateStep" is from Mirin's "Queue" modfile,
|
||||
// converted from lua to typescript by Spax
|
||||
// lineout: https://youtu.be/LnnArS9yrSs
|
||||
let first = true;
|
||||
let footTrack = false;
|
||||
let currFacing = 0;
|
||||
let facingCount = 0;
|
||||
let lastLeftStep = 0,
|
||||
lastRightStep = 3,
|
||||
leftStepCount = 0,
|
||||
rightStepCount = 0;
|
||||
function generateStep(): number {
|
||||
facingCount--;
|
||||
let randomStep = Math.round(Math.random());
|
||||
let stepValue = Math.round(Math.random() * 5 - 0.5);
|
||||
if (first) {
|
||||
first = !first;
|
||||
footTrack = Boolean(Math.round(Math.random()));
|
||||
if (footTrack) stepValue = 3;
|
||||
else stepValue = 0;
|
||||
} else {
|
||||
//right foot
|
||||
if (footTrack) {
|
||||
if (lastLeftStep === randomStep) leftStepCount++;
|
||||
else leftStepCount = 0;
|
||||
if (leftStepCount > 1 || (rightStepCount > 0 && leftStepCount > 0)) {
|
||||
randomStep = 1 - randomStep;
|
||||
leftStepCount = 0;
|
||||
}
|
||||
lastLeftStep = randomStep;
|
||||
stepValue = randomStep * (currFacing + 1);
|
||||
//left foot
|
||||
} else {
|
||||
if (lastRightStep === randomStep) rightStepCount++;
|
||||
else rightStepCount = 0;
|
||||
if (rightStepCount > 1 || (rightStepCount > 0 && leftStepCount > 0)) {
|
||||
randomStep = 1 - randomStep;
|
||||
rightStepCount = 0;
|
||||
}
|
||||
lastRightStep = randomStep;
|
||||
stepValue = 3 - randomStep * (currFacing + 1);
|
||||
}
|
||||
//alternation
|
||||
footTrack = !footTrack;
|
||||
|
||||
if (facingCount < 0 && randomStep === 0) {
|
||||
currFacing = 1 - currFacing;
|
||||
facingCount = Math.floor(Math.random() * 3) + 3;
|
||||
}
|
||||
lastchar = random;
|
||||
arrowWord += random;
|
||||
}
|
||||
return arrowWord;
|
||||
|
||||
return stepValue;
|
||||
}
|
||||
|
||||
export function chart2Word(): string {
|
||||
const arrowArray = ["←", "↓", "↑", "→"];
|
||||
|
||||
let measure = "";
|
||||
for (let i = 0; i < 4; i++) {
|
||||
measure += arrowArray[generateStep()];
|
||||
}
|
||||
|
||||
return measure;
|
||||
}
|
||||
|
||||
export function getPositionString(number: number): string {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
},
|
||||
{
|
||||
"name": "arrows",
|
||||
"info": "Eurobeat Intensifies...",
|
||||
"info": "Play it on a pad!",
|
||||
"canGetPb": false
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue