Skip to content
Snippets Groups Projects

Some changes

Merged Max Wehmeier requested to merge some-changes into custom-server
All threads resolved!
Files
2
@@ -51,7 +51,6 @@ export default class SkribblWords {
/**
* Checks whether a given guess is close to the given word. A guess counts as close, if one letter is wrong,
* two letters are swapped or the guess has one letter too much or too little.
* @todo fix it (short words seem cause trouble (sd is close to und))
* @param {string} guess
* @param {string} word
*/
@@ -91,8 +90,8 @@ export default class SkribblWords {
//if one letter too much
if (guess.length - 1 == word.length) {
let errorCounter = 0; //also the offset
for (var i = 0; i < word.length; i++) {
if (word[i] != guess[i + errorCounter]) {
for (var i = 0; i < guess.length; i++) {
if (word[i - errorCounter] != guess[i]) {
errorCounter++;
if (errorCounter >= 2) {
return false;
@@ -105,8 +104,8 @@ export default class SkribblWords {
//if one letter too little
if (guess.length + 1 == word.length) {
let errorCounter = 0; //also the offset
for (var i = 0; i < guess.length; i++) {
if (word[i + errorCounter] != guess[i]) {
for (var i = 0; i < word.length; i++) {
if (word[i] != guess[i - errorCounter]) {
errorCounter++;
if (errorCounter >= 2) {
return false;