diff options
author | TinWoodman92 <chrhodgden@gmail.com> | 2024-01-15 17:51:49 -0600 |
---|---|---|
committer | TinWoodman92 <chrhodgden@gmail.com> | 2024-01-15 17:51:49 -0600 |
commit | 4f41c8fce448933e88965833feff0fb3faab79b5 (patch) | |
tree | 6586d04a694a98bde4efe11c3e82163ec7a97853 /app.js | |
parent | 609cde41abfbae145a4ce0aa0aa8c83f6ab123ec (diff) |
color victory squares on vitory.
Diffstat (limited to 'app.js')
-rw-r--r-- | app.js | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -20,23 +20,27 @@ const checkVictory = function() { checkSum = checkRow.reduce((acc, value) => acc + value, 0); if (checkSum == 3) { victory = true; - board.victory_row = row; + this.victoryRow = row; }; checkRow = this.oBoard.filter((_, index) => row.includes(index)); checkSum = checkRow.reduce((acc, value) => acc + value, 0); if (checkSum == 3) { victory = true; - board.victory_row = row; + this.victoryRow = row; }; }); if (victory) { - board.victor = board.turn; + this.victor = this.turn; + this.colorVictoryRow(); }; return(victory); }; const colorVictoryRow = function () { - + this.victoryRow.forEach(squareIndex => { + this.squares[squareIndex].style.color = 'var(--background-color)'; + this.squares[squareIndex].style.backgroundColor = 'var(--foreground-color)'; + }); }; const squareClick = function() { @@ -77,6 +81,7 @@ const initBoard = function(board) { //diagonals [0, 4, 8], [2, 4, 6] ]; + board.colorVictoryRow = colorVictoryRow; }; const board = document.getElementById('board'); |