From 0316f4263bf43ef45a3b5f6a543a8f1e0347fb25 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 15 Nov 2024 00:23:43 +0100 Subject: Sending game "started - your turn" notifications. This reverts commit 46c3fddba7038c9472a2c7b1d04d8118c275ab65. --- server.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'server.js') diff --git a/server.js b/server.js index 840dab1..1443611 100644 --- a/server.js +++ b/server.js @@ -2136,7 +2136,7 @@ function start_game(game) { update_join_clients(game.game_id) - send_your_turn_notification_to_offline_users(game.game_id, null, state.active) + send_game_started_notification(game.game_id, state.active) } app.get("/api/replay/:game_id", function (req, res) { @@ -2462,6 +2462,17 @@ function send_chat_activity_notification(game_id, p) { send_play_notification(p, game_id, "Chat activity") } +function send_game_started_notification(game_id, active) { + let players = SQL_SELECT_PLAYERS.all(game_id) + for (let p of players) { + let p_is_active = active === p.role || active === "Both" + if (p_is_active) + send_play_notification(p, game_id, "Started - Your turn") + else + send_play_notification(p, game_id, "Started") + } +} + function send_your_turn_notification_to_offline_users(game_id, old_active, active) { // Only send notifications when the active player changes. if (old_active === active) -- cgit v1.2.3