Have got win and failures working
This commit is contained in:
parent
d9fa154a01
commit
a8e42da6fd
10 changed files with 255 additions and 28 deletions
|
|
@ -31,6 +31,11 @@ export class GameController {
|
|||
this._checkHasStarted();
|
||||
return this._guesses;
|
||||
}
|
||||
|
||||
currentWord() {
|
||||
this._checkHasStarted();
|
||||
return this._currentWord;
|
||||
}
|
||||
|
||||
async nextWord() {
|
||||
this._currentWord = await this._wordSource.getCurrentWord();
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ function binSearch(list, word) {
|
|||
export class WordSource {
|
||||
constructor() {
|
||||
this._wordData = null;
|
||||
this._pattern = null;
|
||||
this._currentWord = null;
|
||||
}
|
||||
|
||||
|
|
@ -38,7 +39,9 @@ export class WordSource {
|
|||
}
|
||||
|
||||
let words = await this._fetchAllWordsIfNecessary();
|
||||
this._currentWord = words.words["4"][7];
|
||||
let idx = this._pattern.index["4"][7];
|
||||
|
||||
this._currentWord = words.words["4"][idx];
|
||||
|
||||
return this._currentWord;
|
||||
}
|
||||
|
|
@ -57,8 +60,8 @@ export class WordSource {
|
|||
return this._wordData;
|
||||
}
|
||||
|
||||
let res = await fetch("/assets/data/words.json");
|
||||
this._wordData = await res.json();
|
||||
this._wordData = await (await fetch("/assets/data/words.json")).json();
|
||||
this._pattern = await (await fetch("/assets/data/shuffle_pattern.json")).json();
|
||||
return this._wordData;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue