aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--draughts/app.js1
-rw-r--r--draughts/public/javascripts/game.js9
-rw-r--r--draughts/public/javascripts/messages.js1
-rw-r--r--draughts/public/stylesheets/game.css5
4 files changed, 11 insertions, 5 deletions
diff --git a/draughts/app.js b/draughts/app.js
index ba1d957..64ce815 100644
--- a/draughts/app.js
+++ b/draughts/app.js
@@ -45,6 +45,7 @@ wss.on("connection", ws => {
game.redPlayer = ws
game.ongoing = true
game.messageClient({ head: Messages.WELCOME, body: Color.RED }, ws)
+ game.messageOpponent({ head: Messages.START }, ws)
game.nextTurn()
}
diff --git a/draughts/public/javascripts/game.js b/draughts/public/javascripts/game.js
index a60401e..6fe82dd 100644
--- a/draughts/public/javascripts/game.js
+++ b/draughts/public/javascripts/game.js
@@ -113,14 +113,17 @@ ws.addEventListener("message", ({ data }) => {
data = JSON.parse(data)
switch (data.head) {
case Messages.WELCOME:
- colorPrefix = data.body
setupPieceEventListeners()
+ if ((colorPrefix = data.body) == Color.BLUE)
+ alert("You are the blue player! Currently waiting for the opponent to join...")
+ else
+ alert("You are the red player!")
break
case Messages.RESIGN:
- console.log("The opponent has resigned, you win!")
+ alert("The opponent has resigned, you win!")
break
case Messages.DISCONNECT:
- console.log("The opponent has disconnected, you win!")
+ alert("The opponent has disconnected, you win!")
break
case Messages.COMMENCE:
ourTurn = true
diff --git a/draughts/public/javascripts/messages.js b/draughts/public/javascripts/messages.js
index 94837d8..c7c2ee1 100644
--- a/draughts/public/javascripts/messages.js
+++ b/draughts/public/javascripts/messages.js
@@ -4,4 +4,5 @@
exports.DISCONNECT = 2 // S --> C :: Inform the client that the opponent disconnected
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
})(typeof(exports) == "undefined" ? (this.Messages = {}) : exports)
diff --git a/draughts/public/stylesheets/game.css b/draughts/public/stylesheets/game.css
index e636b92..afec158 100644
--- a/draughts/public/stylesheets/game.css
+++ b/draughts/public/stylesheets/game.css
@@ -137,9 +137,10 @@ body > div {
}
#resign:hover {
- /* Make the resign button darker and add an outline when you hover over it */
- border: 3px grey solid;
+ /* Make the resign button darker */
background-color: var(--darker-blue);
+
+ cursor: pointer;
}
#resign p {