mirror of
https://gitea.smigz.com/smiggiddy/odin-codeprojects.git
synced 2025-06-28 04:45:36 -04:00
feat: added game evaluation
This commit is contained in:
parent
75b99514de
commit
8a97cde4fa
1 changed files with 74 additions and 75 deletions
|
@ -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(){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue