From 87a0f870e80c46ceb434c7af876564f901d4e97a Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Mon, 30 Jun 2025 15:49:56 +0300 Subject: [PATCH] Fix: check game over by opening cards --- handlers/elements.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/handlers/elements.go b/handlers/elements.go index 60b4196..201a792 100644 --- a/handlers/elements.go +++ b/handlers/elements.go @@ -138,6 +138,21 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) { fi.Room.ActionHistory = append(fi.Room.ActionHistory, action) fi.Room.ClearMarks() } + default: // same color as the team + // check if game over + if fi.Room.RedCounter == 0 || fi.Room.BlueCounter == 0 { + fi.Room.IsRunning = false + fi.Room.IsOver = true + fi.Room.TeamWon = fi.State.Team + action := models.Action{ + Actor: fi.State.Username, + ActorColor: string(fi.State.Team), + WordColor: models.WordColorRed, + Action: models.ActionTypeGameOver, + } + fi.Room.ActionHistory = append(fi.Room.ActionHistory, action) + fi.Room.ClearMarks() + } } if err := saveFullInfo(fi); err != nil { abortWithError(w, err.Error())