Skip to content

Commit

Permalink
Merge pull request #25 from kqngo/features
Browse files Browse the repository at this point in the history
Customize game message on Cat Game
  • Loading branch information
kqngo authored Apr 23, 2017
2 parents d8de0da + ed0503a commit 064b600
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion assets/scripts/game/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ let oWinCount = 0

document.turn = 'X'
document.winner = null
let gameOver = null

const setMessage = function (msg) {
document.getElementById('message').innerText = msg
Expand Down Expand Up @@ -42,6 +43,8 @@ const playerMove = function () {
const nextMove = function (square) {
if (document.winner != null) {
setMessage('Player "' + document.turn + '" already won. Click "Start New Game" below.')
} else if ((checkGameOver())) {
setMessage('Click "Start New Game" below.')
} else if (square.innerText === '') {
square.innerText = document.turn

Expand Down Expand Up @@ -155,7 +158,9 @@ const printWinStats = function () {
}

const tiedGame = function () {
$('#gameboard').show()
gameOver = "gameOver"

// $('#gameboard').hide()
$('#gameResultModal').show()

setResultMessage('Cats Game - You tied!')
Expand All @@ -167,6 +172,8 @@ const tiedGame = function () {
}

const newGame = function () {
gameOver = null

$('#gameResultModal').hide()
$('#gameboard').show()
$('.nav-btns').show()
Expand Down

0 comments on commit 064b600

Please sign in to comment.