aboutsummaryrefslogtreecommitdiff
path: root/draughts
diff options
context:
space:
mode:
authorThomas Voss <thomasvoss@live.com> 2022-01-13 22:57:18 +0100
committerThomas Voss <thomasvoss@live.com> 2022-01-13 22:57:18 +0100
commit1d51b46a00966e6bd651d704146ec4311514f640 (patch)
treeef269957787c65d8feeed0ca43632d7786daea8d /draughts
parenta24599cce84fa0a8ec14788b177c72ea41dcafa9 (diff)
Inform the clients of various events via alerts
Diffstat (limited to 'draughts')
-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 {