mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2024-09-20 15:26:15 +08:00
refactor: move test finish/fail logic, add all words generated check
This commit is contained in:
parent
148fa1e519
commit
faf7efa043
|
@ -234,11 +234,6 @@ function handleSpace(): void {
|
|||
void Sound.playClick();
|
||||
}
|
||||
Replay.addReplayEvent("submitCorrectWord");
|
||||
if (TestWords.words.currentIndex === TestWords.words.length) {
|
||||
//submitted last word (checking this in case the test doesnt stop automatically on correct last keypress)
|
||||
void TestLogic.finish();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (!nospace) {
|
||||
if (Config.playSoundOnError === "off" || Config.blindMode) {
|
||||
|
@ -284,17 +279,24 @@ function handleSpace(): void {
|
|||
void Caret.updatePosition();
|
||||
TestInput.incrementKeypressCount();
|
||||
TestInput.pushKeypressWord(TestWords.words.currentIndex);
|
||||
if (Config.difficulty === "expert" || Config.difficulty === "master") {
|
||||
TestLogic.fail("difficulty");
|
||||
return;
|
||||
} else if (TestWords.words.currentIndex === TestWords.words.length) {
|
||||
//submitted last word that is incorrect
|
||||
void TestLogic.finish();
|
||||
return;
|
||||
}
|
||||
Replay.addReplayEvent("submitErrorWord");
|
||||
}
|
||||
|
||||
if (
|
||||
TestLogic.areAllTestWordsGenerated() &&
|
||||
TestWords.words.currentIndex === TestWords.words.length
|
||||
) {
|
||||
if (
|
||||
!isWordCorrect &&
|
||||
(Config.difficulty === "expert" || Config.difficulty === "master")
|
||||
) {
|
||||
TestLogic.fail("difficulty");
|
||||
} else {
|
||||
void TestLogic.finish();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
let wordLength: number;
|
||||
if (Config.mode === "zen") {
|
||||
wordLength = TestInput.input.current.length;
|
||||
|
|
Loading…
Reference in a new issue