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())