fix matrix algo
This commit is contained in:
parent
48646c5740
commit
aaeb0d7752
19
game.js
19
game.js
|
@ -60,6 +60,22 @@ class Game {
|
|||
result.push(3)
|
||||
} else {
|
||||
if (this.expectedWord.indexOf(triedLetter) > -1) {
|
||||
let totalOk = 0
|
||||
let totalToTry = 0
|
||||
|
||||
for (let i = 0; i < this.expectedWord.length; i++) {
|
||||
if (this.expectedWord.charAt(i) === triedLetter) {
|
||||
totalToTry++
|
||||
|
||||
if (this.expectedWord.charAt(i) === this.triedWords[u].charAt(i)) {
|
||||
totalOk++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (totalToTry === totalOk) {
|
||||
result.push(1)
|
||||
} else {
|
||||
const numberOfTriedLetterInExpectedWord = this.expectedWord.split(triedLetter).length - 1
|
||||
const cuttedTriedWord = this.triedWords[u].substr(0, x + 1)
|
||||
const numberOfTriedLetterInCuttedWord = cuttedTriedWord.split(triedLetter).length - 1
|
||||
|
@ -69,8 +85,9 @@ class Game {
|
|||
} else {
|
||||
result.push(2)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result.push(1)
|
||||
result.push(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue