Fix: show-color

This commit is contained in:
Grail Finder
2025-07-04 21:56:46 +03:00
parent 3e9a93fbb1
commit 56845e6141
2 changed files with 13 additions and 2 deletions

View File

@ -61,7 +61,16 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) {
Color: color,
Revealed: true,
}
fi.Room.RevealSpecificWord(word)
revCardID := fi.Room.RevealSpecificWord(word)
if revCardID == 0 {
// error
abortWithError(w, "word has 0 id")
return
}
if err := repo.WordCardReveal(r.Context(), word, fi.Room.ID); err != nil {
abortWithError(w, err.Error())
return
}
fi.Room.UpdateCounter()
action := models.Action{
Actor: fi.State.Username,

View File

@ -376,12 +376,14 @@ func (r *Room) GuesserView() {
}
}
func (r *Room) RevealSpecificWord(word string) {
func (r *Room) RevealSpecificWord(word string) uint32 {
for i, card := range r.Cards {
if card.Word == word {
r.Cards[i].Revealed = true
return card.ID
}
}
return 0
}
type WordCard struct {