Skip to content

Commit

Permalink
Message display above the board instead of console
Browse files Browse the repository at this point in the history
  • Loading branch information
zalbright90 committed Aug 21, 2024
1 parent e3f7a21 commit 5b991e9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div id="message"></div>
<div class="board" id="gameBoard">
<div class="cell" data-index="0"></div>
<div class="cell" data-index="1"></div>
Expand Down
7 changes: 4 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ const GameController = (function(Gameboard) {
const playTurn = (index) => {
if (Gameboard.placeMarker(index, currentPlayer.marker)) {
if (checkWin()) {
console.log(`Sigurvegari! (Winner!) ${currentPlayer.name}`);
document.getElementById('message').textContent = `Sigurvegari! (Winner!) ${currentPlayer.name}`;
} else if (checkTie()) {
console.log("JAFNTEFLI! (It's a tie game!)");
document.getElementById('message').textContent = "JAFNTEFLI! (It's a tie game!)";
} else {
switchTurn();
document.getElementById('message').textContent = `${getCurrentPlayer().name}'s turn!`;
}
} else {
console.log("Invalid move. Try again.");
document.getElementById('message').textContent = "Invalid move. Try again.";
}
};

Expand Down

0 comments on commit 5b991e9

Please sign in to comment.