Feat: word loader

This commit is contained in:
Grail Finder
2025-05-13 07:49:16 +03:00
parent f752d2a162
commit 0c94811632
5 changed files with 6043 additions and 31 deletions

View File

@ -4,9 +4,11 @@ import (
"context"
"encoding/json"
"errors"
"fmt"
"golias/broker"
"golias/models"
"golias/utils"
"golias/wordloader"
"strings"
)
@ -248,3 +250,14 @@ func notify(event, msg string) {
Payload: msg,
}
}
func loadCards(room *models.Room) {
wl := wordloader.InitDefaultLoader("assets/words/en_nouns.txt")
cards, err := wl.Load()
if err != nil {
// no logger
fmt.Println("failed to load cards", "error", err)
}
room.Cards = cards
}

View File

@ -176,7 +176,8 @@ func HandleStartGame(w http.ResponseWriter, r *http.Request) {
fi.Room.IsRunning = true
fi.Room.IsOver = false
fi.Room.TeamTurn = "blue"
fi.Room.LoadTestCards()
// fi.Room.LoadTestCards()
loadCards(fi.Room)
fi.Room.UpdateCounter()
fi.Room.TeamWon = ""
if err := saveFullInfo(fi); err != nil {