Feat: game over event to be seen in backog

This commit is contained in:
Grail Finder
2025-05-29 17:13:47 +03:00
parent 09e2b2f4b6
commit 6934b724ae
3 changed files with 24 additions and 1 deletions

View File

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

View File

@ -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

View File

@ -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;