Feat: bot ends game to the stats

This commit is contained in:
Grail Finder
2025-07-10 20:21:10 +03:00
parent 8040586043
commit 89572e8fb5
2 changed files with 73 additions and 0 deletions

View File

@ -107,6 +107,7 @@ func (b *Bot) checkGuess(word string, room *models.Room) error {
}
room.ActionHistory = append(room.ActionHistory, action)
b.StopTurnTimer()
updateStatsOnGameOver(context.Background(), room)
case string(models.WordColorWhite), string(oppositeColor):
// end turn
room.TeamTurn = oppositeColor
@ -132,6 +133,7 @@ func (b *Bot) checkGuess(word string, room *models.Room) error {
}
room.ActionHistory = append(room.ActionHistory, action)
b.StopTurnTimer()
updateStatsOnGameOver(context.Background(), room)
}
if room.RedCounter == 0 {
// red won
@ -149,6 +151,7 @@ func (b *Bot) checkGuess(word string, room *models.Room) error {
}
room.ActionHistory = append(room.ActionHistory, action)
b.StopTurnTimer()
updateStatsOnGameOver(context.Background(), room)
}
ctx, tx, err := repo.InitTx(context.Background())
// nolint: errcheck