gonne call it done

This commit is contained in:
Ben
2021-05-10 22:22:15 +01:00
parent f89b11f6aa
commit 4da8332992
7 changed files with 106 additions and 23 deletions

View File

@@ -411,13 +411,27 @@ function PlayTurn(gameuid, playeruid, turn)
}
// check dictionary
for (const word in wordbasic)
for (const word in wordsbasic)
{
let reversedword = word.split('').reverse().join('');
let reversedword = wordsbasic[word].split('').reverse().join('');
const doesexist = Dict.FindWord(game.locale, wordsbasic[word].toUpperCase());
const doesreversedexist = Dict.FindWord(game.locale, reversedword.toUpperCase());
if (!doesexist && !doesreversedexist)
{
const error = {
error: 'error-game-word-not-exist',
word: wordsbasic[word]
};
return [error, undefined, undefined, undefined]
}
if (doesreversedexist)
{
wordsbasic[word] = reversedword;
words[word].reverse();
}
Logger.game(`WORD ${wordsbasic[word]} FOUND`);
}
// update tiles with scores
turn.boardtiles = turn.oldboardtiles.concat(turn.boardtiles);
for (const tile in turn.boardtiles)
@@ -496,6 +510,7 @@ function PlayTurn(gameuid, playeruid, turn)
}
turn.outcome = outcome;
gameplayer.score += outcome.points;
ActiveGames[gameuid].gamestates.push(turn);
ActiveGames[gameuid].turn = turninfo.newTurn;
ActiveGames[gameuid].turntotal = turninfo.newTotalTurn;