Require multiple question repeats
This commit is contained in:
parent
ed98005f9f
commit
e8853b289e
1 changed files with 6 additions and 4 deletions
10
nicolator.js
10
nicolator.js
|
@ -176,18 +176,18 @@ const timerFPS = 60;
|
||||||
let incorrectTimeout = null;
|
let incorrectTimeout = null;
|
||||||
let timerTimeout = null;
|
let timerTimeout = null;
|
||||||
let word = null;
|
let word = null;
|
||||||
let wrong = false;
|
let repeats = 0;
|
||||||
const reset = () => {
|
const reset = () => {
|
||||||
input.value = "";
|
input.value = "";
|
||||||
hint.innerHTML = "";
|
hint.innerHTML = "";
|
||||||
timer.value = 1;
|
timer.value = 1;
|
||||||
if (!wrong) {
|
if (repeats == 0) {
|
||||||
word = words[Math.round(Math.random() * words.length)];
|
word = words[Math.round(Math.random() * words.length)];
|
||||||
}
|
}
|
||||||
wordDisplay.innerHTML = word;
|
wordDisplay.innerHTML = word;
|
||||||
const typeTime = typeTimePerKana * word.length;
|
const typeTime = typeTimePerKana * word.length;
|
||||||
incorrectTimeout = setTimeout(() => {
|
incorrectTimeout = setTimeout(() => {
|
||||||
wrong = true;
|
repeats += repeats == 0 ? 3 : 1;
|
||||||
wordDisplay.innerHTML = `${word} ❌`;
|
wordDisplay.innerHTML = `${word} ❌`;
|
||||||
for (let i = 0; i < word.length; i++) {
|
for (let i = 0; i < word.length; i++) {
|
||||||
const letter = word[i];
|
const letter = word[i];
|
||||||
|
@ -221,6 +221,8 @@ const reset = () => {
|
||||||
timerTimeout = setInterval(() => {
|
timerTimeout = setInterval(() => {
|
||||||
timer.value -= (1 / timerFPS) / typeTime;
|
timer.value -= (1 / timerFPS) / typeTime;
|
||||||
}, 1000 / timerFPS);
|
}, 1000 / timerFPS);
|
||||||
wrong = false;
|
if (repeats > 0) {
|
||||||
|
repeats -= 1;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
reset();
|
reset();
|
||||||
|
|
Reference in a new issue