Merge branch 'master' into newads

This commit is contained in:
Miodec 2023-03-27 22:22:29 +02:00
commit 54c1826ad5
6 changed files with 29 additions and 16 deletions

View file

@ -159,8 +159,8 @@ FunboxList.setFunboxFunctions("choo_choo", {
});
FunboxList.setFunboxFunctions("arrows", {
getWord(): string {
return Misc.chart2Word();
getWord(_wordset, wordIndex): string {
return Misc.chart2Word(wordIndex === 0);
},
applyConfig(): void {
$("#words").addClass("arrows");

View file

@ -687,12 +687,16 @@ function getFunboxWordsFrequency():
return undefined;
}
function getFunboxWord(word: string, wordset?: Misc.Wordset): string {
function getFunboxWord(
word: string,
wordIndex: number,
wordset?: Misc.Wordset
): string {
const wordFunbox = FunboxList.get(Config.funbox).find(
(f) => f.functions?.getWord
);
if (wordFunbox?.functions?.getWord) {
word = wordFunbox.functions.getWord(wordset);
word = wordFunbox.functions.getWord(wordset, wordIndex);
}
return word;
}
@ -725,6 +729,7 @@ function applyLazyModeToWord(
async function getNextWord(
wordset: Misc.Wordset,
wordIndex: number,
language: MonkeyTypes.LanguageObject,
wordsBound: number
): Promise<string> {
@ -789,7 +794,7 @@ async function getNextWord(
randomWord = randomWord.replace(/ +/gm, " ");
randomWord = randomWord.replace(/(^ )|( $)/gm, "");
randomWord = applyLazyModeToWord(randomWord, language);
randomWord = getFunboxWord(randomWord, wordset);
randomWord = getFunboxWord(randomWord, wordIndex, wordset);
randomWord = await applyBritishEnglishToWord(randomWord);
if (Config.punctuation) {
@ -1029,7 +1034,7 @@ export async function init(): Promise<void> {
if (wordCount == 0) {
for (let i = 0; i < wordsBound; i++) {
const randomWord = await getNextWord(wordset, language, wordsBound);
const randomWord = await getNextWord(wordset, i, language, wordsBound);
if (/\t/g.test(randomWord)) {
TestWords.setHasTab(true);
@ -1273,7 +1278,12 @@ export async function addWord(): Promise<void> {
};
const wordset = await Wordset.withWords(language.words);
const randomWord = await getNextWord(wordset, language, bound);
const randomWord = await getNextWord(
wordset,
TestWords.words.length,
language,
bound
);
const split = randomWord.split(" ");
if (split.length > 1) {

View file

@ -214,7 +214,7 @@ declare namespace MonkeyTypes {
| "changesWordsFrequency";
interface FunboxFunctions {
getWord?: (wordset?: Misc.Wordset) => string;
getWord?: (wordset?: Misc.Wordset, wordIndex?: number) => string;
punctuateWord?: (word: string) => string;
withWords?: (words?: string[]) => Promise<Misc.Wordset>;
alterText?: (word: string) => string;

View file

@ -725,7 +725,6 @@ export function getASCII(): string {
// 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;
@ -733,12 +732,11 @@ let lastLeftStep = 0,
lastRightStep = 3,
leftStepCount = 0,
rightStepCount = 0;
function generateStep(): number {
function generateStep(leftRightOverride: boolean): number {
facingCount--;
let randomStep = Math.round(Math.random());
let stepValue = Math.round(Math.random() * 5 - 0.5);
if (first) {
first = !first;
if (leftRightOverride) {
footTrack = Boolean(Math.round(Math.random()));
if (footTrack) stepValue = 3;
else stepValue = 0;
@ -776,12 +774,11 @@ function generateStep(): number {
return stepValue;
}
export function chart2Word(): string {
export function chart2Word(first: boolean): string {
const arrowArray = ["←", "↓", "↑", "→"];
let measure = "";
for (let i = 0; i < 4; i++) {
measure += arrowArray[generateStep()];
measure += arrowArray[generateStep(i === 0 && first)];
}
return measure;

View file

@ -81,6 +81,10 @@
"name": "korean",
"languages": ["korean", "korean_1k", "korean_5k"]
},
{
"name": "chinese",
"languages": ["chinese_traditional"]
},
{
"name": "russian",
"languages": [
@ -154,7 +158,7 @@
},
{
"name": "turkish",
"languages": ["turkish"]
"languages": ["turkish", "turkish_1k"]
},
{
"name": "irish",

View file

@ -32,6 +32,7 @@
,"korean"
,"korean_1k"
,"korean_5k"
,"chinese_traditional"
,"russian"
,"russian_1k"
,"russian_10k"
@ -78,6 +79,7 @@
,"greek_10k"
,"greek_25k"
,"turkish"
,"turkish_1k"
,"irish"
,"italian"
,"italian_1k"