From 6934b724ae7101abe50a56b72192557ca673630a Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Thu, 29 May 2025 17:13:47 +0300 Subject: [PATCH] Feat: game over event to be seen in backog --- handlers/elements.go | 21 +++++++++++++++++++++ models/main.go | 2 +- todos.md | 2 ++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/handlers/elements.go b/handlers/elements.go index 666a71f..50b1df1 100644 --- a/handlers/elements.go +++ b/handlers/elements.go @@ -90,6 +90,13 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) { fi.Room.IsRunning = false fi.Room.IsOver = true fi.Room.TeamWon = oppositeColor + action := models.Action{ + Actor: fi.State.Username, + ActorColor: string(fi.State.Team), + WordColor: "black", + Action: "game over", + } + fi.Room.ActionHistory = append(fi.Room.ActionHistory, action) case "white", string(oppositeColor): // end turn fi.Room.TeamTurn = oppositeColor @@ -101,12 +108,26 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) { fi.Room.IsRunning = false fi.Room.IsOver = true fi.Room.TeamWon = "blue" + action := models.Action{ + Actor: fi.State.Username, + ActorColor: string(fi.State.Team), + WordColor: "blue", + Action: "game over", + } + fi.Room.ActionHistory = append(fi.Room.ActionHistory, action) } if fi.Room.RedCounter == 0 { // red won fi.Room.IsRunning = false fi.Room.IsOver = true fi.Room.TeamWon = "red" + action := models.Action{ + Actor: fi.State.Username, + ActorColor: string(fi.State.Team), + WordColor: "red", + Action: "game over", + } + fi.Room.ActionHistory = append(fi.Room.ActionHistory, action) } if err := saveFullInfo(fi); err != nil { abortWithError(w, err.Error()) diff --git a/models/main.go b/models/main.go index 7fc81db..17583a6 100644 --- a/models/main.go +++ b/models/main.go @@ -42,7 +42,7 @@ type Team struct { type Action struct { Actor string ActorColor string - Action WordColor // clue | guess + Action string // clue | guess Word string WordColor string Number string // for clue diff --git a/todos.md b/todos.md index 1d13446..5d7bef1 100644 --- a/todos.md +++ b/todos.md @@ -25,3 +25,5 @@ - cleanup backlog after new game is started; - guessers should not be able to open more cards, than mime gave them +1; - sse hangs / fails connection which causes to wait for cards to open a few seconds (on local machine); +- after starting a new game (after old one) blue mime has no clue input; +- gameover to backlog;