feat: added game evaluation

This commit is contained in:
Smigz 2023-12-13 17:17:20 -05:00
parent 75b99514de
commit 8a97cde4fa

View file

@ -120,10 +120,6 @@ function block() {
};
};
const gameController = (() => {
// Controls the overall flow of the game
let players = [
@ -147,7 +143,10 @@ const gameController = (() => {
marker.addToken(player);
tictactoeBoard.placeOnBoard(position, marker); // position on board
tictactoeBoard.printGameBoard();
let gameOver = evalGameOutcome(tictactoeBoard);
if (!gameOver) {
switchPlayerTurn();
}
} else {
return
}
@ -168,7 +167,9 @@ const gameController = (() => {
let checkGameBoard = [gameBoard, diagArray, vertArray];
for (i = 0; i < 3; i++) {
let outcome = _evalGameOutcome(checkGameBoard[i]);
if (outcome) return outcome[0];
if (outcome) {
return true;
};
};
return false;
};
@ -196,8 +197,6 @@ gameController.playRound(4);
gameController.playRound(4);
gameController.playRound(5);
// tictactoeBoard.placeOnBoard(1, block)
// tictactoeBoard.printGameBoard();
// const inputController = (function(){