Have got progression

This commit is contained in:
Leon Mika 2025-01-22 22:04:24 +11:00
parent 7312190c62
commit 11f658afcc
5 changed files with 47 additions and 12 deletions

View file

@ -25,6 +25,16 @@ export class GameController {
return this._guesses;
}
nextWord() {
if (!this._wordSource.nextWord()) {
return false;
}
this._currentWord = this._wordSource.getCurrentWord();
this._guesses = 5;
return true;
}
checkGuess(guess) {
if (guess.length != this._currentWord.length) {
throw Error(`Expected length to be ${this._currentWord.length} but was ${guess.length}`);

View file

@ -18,6 +18,11 @@ export class WordSource {
}
nextWord() {
this._currentWord += 1;
if (this._currentWord >= this._words.length - 1) {
return false;
}
this._currentWord += 1;
return true;
}
}