diff options
-rw-r--r-- | draughts/public/javascripts/game.js | 6 | ||||
-rw-r--r-- | draughts/public/javascripts/messages.js | 1 |
2 files changed, 7 insertions, 0 deletions
diff --git a/draughts/public/javascripts/game.js b/draughts/public/javascripts/game.js index 20cceb8..dd0e9a2 100644 --- a/draughts/public/javascripts/game.js +++ b/draughts/public/javascripts/game.js @@ -167,6 +167,12 @@ ws.addEventListener("message", ({ data }) => { gameHistory = data.body.history drawHistory() break + case Messages.START: + alert("The opponent has joined, you can make your first move.") + break + case Messages.GAMEOVER: + alert(data.body == colorPrefix ? "Congratulations, you have won!" + : "Unfortunately, you have lost...") break } }) diff --git a/draughts/public/javascripts/messages.js b/draughts/public/javascripts/messages.js index c7c2ee1..04a96e9 100644 --- a/draughts/public/javascripts/messages.js +++ b/draughts/public/javascripts/messages.js @@ -5,4 +5,5 @@ exports.MOVED = 3 // S <-> C :: Inform the server/opponent that the client has moved a piece exports.WELCOME = 4 // S --> C :: Inform the client of their color when they join the game exports.START = 5 // s --> C :: Inform the blue player that they can make the first move + exports.GAMEOVER = 6 // S --> C :: Inform the clients that the game is over })(typeof(exports) == "undefined" ? (this.Messages = {}) : exports) |