Moved to an easier dictionary and added invalid word guesses back
All checks were successful
/ publish (push) Successful in 1m19s
All checks were successful
/ publish (push) Successful in 1m19s
Also added a spinner
This commit is contained in:
parent
36b079681c
commit
566f55ed12
7 changed files with 105 additions and 57 deletions
|
|
@ -149,6 +149,18 @@ export class GameController {
|
|||
let misses = {};
|
||||
let hits = {};
|
||||
|
||||
if (!this._wordSource.isWord(guess)) {
|
||||
hits = {};
|
||||
for (let i = 0; i < guess.length; i++) {
|
||||
hits[guess[i]] = MARKERS.ATTEMPTED;
|
||||
}
|
||||
|
||||
return {
|
||||
hits: hits,
|
||||
guessResult: GUESS_RESULT.FOUL,
|
||||
};
|
||||
}
|
||||
|
||||
for (let i = 0; i < guess.length; i++) {
|
||||
if (guess[i] == this._currentWord[i]) {
|
||||
markers[i] = MARKERS.RIGHT_POS;
|
||||
|
|
|
|||
|
|
@ -19,38 +19,38 @@ function binSearch(list, word) {
|
|||
|
||||
export class WordSource {
|
||||
constructor() {
|
||||
this._dataVersion = null;
|
||||
this._wordData = null;
|
||||
this._otherWords = null;
|
||||
this._pattern = null;
|
||||
// this._currentWord = null;
|
||||
// this._progressionState=
|
||||
}
|
||||
|
||||
isWord(word) {
|
||||
let list = this._wordData.words[word.length.toString()];
|
||||
if (!list) {
|
||||
if (!this._wordData || !this._otherWords) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return binSearch(list, word);
|
||||
return binSearch(this._wordData[word.length.toString()], word) ||
|
||||
binSearch(this._otherWords[word.length.toString()], word);
|
||||
}
|
||||
|
||||
async needToResetProgression(prog) {
|
||||
await this._fetchAllWordsIfNecessary();
|
||||
return !prog || !prog.shuffleId || this._pattern.id !== prog.shuffleId;
|
||||
return !prog || !prog.shuffleId || this._dataVersion !== prog.shuffleId;
|
||||
}
|
||||
|
||||
async getPattenShuffleID() {
|
||||
return this._pattern.id;
|
||||
return this._dataVersion;
|
||||
}
|
||||
|
||||
async getCurrentWord(prog) {
|
||||
let words = await this._fetchAllWordsIfNecessary();
|
||||
await this._fetchAllWordsIfNecessary();
|
||||
|
||||
let wordLengthKey = prog.wordLength + "";
|
||||
let wordIndex = prog.wordIndex[wordLengthKey];
|
||||
let idx = this._pattern.index[wordLengthKey][wordIndex];
|
||||
let idx = this._pattern[wordLengthKey][wordIndex];
|
||||
|
||||
return words.words[wordLengthKey][idx];
|
||||
return this._wordData[wordLengthKey][idx];
|
||||
}
|
||||
|
||||
async _fetchAllWordsIfNecessary() {
|
||||
|
|
@ -58,8 +58,11 @@ export class WordSource {
|
|||
return this._wordData;
|
||||
}
|
||||
|
||||
this._wordData = await (await fetch("/assets/data/words.json")).json();
|
||||
this._pattern = await (await fetch("/assets/data/shuffle_pattern.json")).json();
|
||||
return this._wordData;
|
||||
let data = await (await fetch("/assets/data/data.json")).json();
|
||||
|
||||
this._dataVersion = data["versionId"];
|
||||
this._wordData = data["guessWords"];
|
||||
this._otherWords = data["otherWords"];
|
||||
this._pattern = data["shufflePattern"];
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue