Fix: check game over by opening cards

This commit is contained in:
Grail Finder
2025-06-30 15:49:56 +03:00
parent 288e74c95b
commit 87a0f870e8

View File

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