diff --git a/handlers/elements.go b/handlers/elements.go index 592c452..605e2bc 100644 --- a/handlers/elements.go +++ b/handlers/elements.go @@ -109,6 +109,7 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) { fi.Room.IsOver = true fi.Room.TeamWon = oppositeColor action := models.Action{ + RoomID: fi.Room.ID, Actor: fi.State.Username, ActorColor: string(fi.State.Team), WordColor: models.WordColorBlack, @@ -134,6 +135,7 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) { fi.Room.IsOver = true fi.Room.TeamWon = "blue" action := models.Action{ + RoomID: fi.Room.ID, Actor: fi.State.Username, ActorColor: string(fi.State.Team), WordColor: models.WordColorBlue, @@ -148,6 +150,7 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) { fi.Room.IsOver = true fi.Room.TeamWon = "red" action := models.Action{ + RoomID: fi.Room.ID, Actor: fi.State.Username, ActorColor: string(fi.State.Team), WordColor: models.WordColorRed, @@ -163,6 +166,7 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) { fi.Room.IsOver = true fi.Room.TeamWon = fi.State.Team action := models.Action{ + RoomID: fi.Room.ID, Actor: fi.State.Username, ActorColor: string(fi.State.Team), WordColor: models.WordColorRed, diff --git a/handlers/game.go b/handlers/game.go index cc06b63..4d03808 100644 --- a/handlers/game.go +++ b/handlers/game.go @@ -173,6 +173,8 @@ func HandleStartGame(w http.ResponseWriter, r *http.Request) { fi.Room.UpdateCounter() fi.Room.TeamWon = "" action := models.Action{ + RoomID: fi.Room.ID, + CreatedAt: time.Now(), Actor: fi.State.Username, ActorColor: string(fi.State.Team), WordColor: string(fi.State.Team), @@ -188,8 +190,6 @@ func HandleStartGame(w http.ResponseWriter, r *http.Request) { // return // } // Save action history - action.RoomID = fi.Room.ID - action.CreatedAt = time.Now() if err := repo.ActionCreate(ctx, &action); err != nil { if err := tx.Rollback(); err != nil { log.Error("failed to rollback transaction", "error", err) diff --git a/llmapi/main.go b/llmapi/main.go index 14e674a..d358c18 100644 --- a/llmapi/main.go +++ b/llmapi/main.go @@ -79,6 +79,7 @@ func (b *Bot) checkGuess(word string, room *models.Room) error { room.RevealSpecificWord(word) room.UpdateCounter() action := models.Action{ + RoomID: room.ID, Actor: b.BotName, ActorColor: b.Team, WordColor: string(color), @@ -108,6 +109,7 @@ func (b *Bot) checkGuess(word string, room *models.Room) error { room.OpenedThisTurn = 0 room.ThisTurnLimit = 0 action := models.Action{ + RoomID: room.ID, Actor: b.BotName, ActorColor: string(b.Team), WordColor: models.WordColorBlack, @@ -130,6 +132,7 @@ func (b *Bot) checkGuess(word string, room *models.Room) error { room.OpenedThisTurn = 0 room.ThisTurnLimit = 0 action := models.Action{ + RoomID: room.ID, Actor: b.BotName, ActorColor: string(b.Team), WordColor: models.WordColorBlack, @@ -145,6 +148,7 @@ func (b *Bot) checkGuess(word string, room *models.Room) error { room.OpenedThisTurn = 0 room.ThisTurnLimit = 0 action := models.Action{ + RoomID: room.ID, Actor: b.BotName, ActorColor: string(b.Team), WordColor: models.WordColorBlack, @@ -232,6 +236,7 @@ func (b *Bot) BotMove() { return } action := models.Action{ + RoomID: room.ID, Actor: b.BotName, ActorColor: b.Team, WordColor: b.Team,