Have got progression
This commit is contained in:
parent
7312190c62
commit
11f658afcc
5 changed files with 47 additions and 12 deletions
|
|
@ -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}`);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue