Chore: refactor; mark words [WIP]

This commit is contained in:
Grail Finder
2025-06-27 13:22:00 +03:00
parent c5f04d348f
commit 72053281e2
7 changed files with 208 additions and 33 deletions

View File

@ -63,6 +63,11 @@ type BotPlayer struct {
Team UserTeam
}
type CardMark struct {
Username string
Active bool
}
type Room struct {
ID string `json:"id" db:"id"`
CreatedAt time.Time `json:"created_at" db:"created_at"` // limit?
@ -89,11 +94,24 @@ type Room struct {
RoundTime int32 `json:"round_time"`
IsOver bool
TeamWon UserTeam // blue | red
//
Mark CardMark // card is marked
// needed for debug
LogJournal []string
LastActionTS time.Time
}
func (r *Room) RemovePlayer(username string) {
r.RedTeam.Guessers = utils.RemoveFromSlice(username, r.RedTeam.Guessers)
r.BlueTeam.Guessers = utils.RemoveFromSlice(username, r.BlueTeam.Guessers)
if r.RedTeam.Mime == username {
r.RedTeam.Mime = ""
}
if r.BlueTeam.Mime == username {
r.BlueTeam.Mime = ""
}
}
// FindBotByTeamRole returns bot name if found; otherwise empty string
func (r *Room) FindBotByTeamRole(team, role string) string {
for bn, b := range r.BotMap {
@ -249,9 +267,10 @@ func (r *Room) RevealSpecificWord(word string) {
}
type WordCard struct {
Word string `json:"word"`
Color WordColor `json:"color"`
Revealed bool `json:"revealed"`
Word string `json:"word"`
Color WordColor `json:"color"`
Revealed bool `json:"revealed"`
Mark []CardMark `json:"marks"`
}
type GameSettings struct {