Feat: update stats

This commit is contained in:
Grail Finder
2025-07-10 20:12:37 +03:00
parent 8392a764a2
commit 8040586043
3 changed files with 92 additions and 1 deletions

View File

@ -71,6 +71,7 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) {
abortWithError(w, err.Error())
return
}
updateStatsOnCardReveal(r.Context(), fi.State, color)
fi.Room.UpdateCounter()
action := models.Action{
Actor: fi.State.Username,
@ -121,6 +122,7 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) {
fi.Room.ActionHistory = append(fi.Room.ActionHistory, action)
clearMarks = true
StopTurnTimer(fi.Room.ID)
updateStatsOnGameOver(r.Context(), fi.Room)
case string(models.WordColorWhite), string(oppositeColor):
log.Debug("opened white or opposite color word", "word", word, "opposite-color", oppositeColor)
// end turn
@ -144,6 +146,7 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) {
Action: models.ActionTypeGameOver,
}
fi.Room.ActionHistory = append(fi.Room.ActionHistory, action)
updateStatsOnGameOver(r.Context(), fi.Room)
}
if fi.Room.RedCounter == 0 {
// red won
@ -158,6 +161,7 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) {
Action: models.ActionTypeGameOver,
}
fi.Room.ActionHistory = append(fi.Room.ActionHistory, action)
updateStatsOnGameOver(r.Context(), fi.Room)
}
default: // same color as the team
// check if game over
@ -173,6 +177,7 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) {
Action: models.ActionTypeGameOver,
}
fi.Room.ActionHistory = append(fi.Room.ActionHistory, action)
updateStatsOnGameOver(r.Context(), fi.Room)
}
}
if clearMarks {