Enha: sse update on actions

This commit is contained in:
Grail Finder
2025-05-10 11:03:23 +03:00
parent 416cc63ec0
commit 35e215e26f
12 changed files with 89 additions and 73 deletions

View File

@ -7,4 +7,6 @@ var (
// cache
CacheRoomPrefix = "room#"
CacheStatePrefix = "state-"
// sse
NotifyRoomUpdatePrefix = "roomupdate_"
)

View File

@ -34,6 +34,7 @@ func StrToWordColor(s string) WordColor {
type Team struct {
Guessers []string
Mime string
Color string
}
type Room struct {
@ -109,6 +110,14 @@ func (r *Room) RevealAllCards() {
}
}
func (r *Room) RevealSpecificWord(word string) {
for i, card := range r.Cards {
if card.Word == word {
r.Cards[i].Revealed = true
}
}
}
type WordCard struct {
Word string
Color WordColor

View File

@ -75,8 +75,8 @@ func MakeTestState(creatorName string) *FullInfo {
{Word: "tomato", Color: "red"},
{Word: "cloud", Color: "white"},
}
redTeam := Team{Guessers: []string{"Adam", "Eve"}, Mime: "Serpent"}
blueTeam := Team{Guessers: []string{"Abel", "Kain"}}
redTeam := Team{Guessers: []string{"Adam", "Eve"}, Mime: "Serpent", Color: "red"}
blueTeam := Team{Guessers: []string{"Abel", "Kain"}, Color: "blue"}
room := &Room{
ID: "test-id",
CreatedAt: time.Now(),