Fix: load cards to remove old cards from db
This commit is contained in:
@ -174,26 +174,6 @@ func joinTeam(ctx context.Context, role, team string) (*models.FullInfo, error)
|
||||
return fi, nil
|
||||
}
|
||||
|
||||
// get all rooms
|
||||
// func listRooms(allRooms bool) []*models.Room {
|
||||
// cacheMap := memcache.GetAll()
|
||||
// publicRooms := []*models.Room{}
|
||||
// // no way to know if room is public until unmarshal -_-;
|
||||
// for key, value := range cacheMap {
|
||||
// if strings.HasPrefix(key, models.CacheRoomPrefix) {
|
||||
// room := &models.Room{}
|
||||
// if err := json.Unmarshal(value, &room); err != nil {
|
||||
// log.Warn("failed to unmarshal room", "error", err)
|
||||
// continue
|
||||
// }
|
||||
// if room.IsPublic || allRooms {
|
||||
// publicRooms = append(publicRooms, room)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return publicRooms
|
||||
// }
|
||||
|
||||
// get bots
|
||||
func listBots() []models.Player {
|
||||
bots, err := repo.PlayerList(context.Background(), true)
|
||||
@ -214,6 +194,9 @@ func notify(event, msg string) {
|
||||
func loadCards(room *models.Room) {
|
||||
// remove old cards
|
||||
room.Cards = []models.WordCard{}
|
||||
// try to delete old cards from db (in case players play another round)
|
||||
// nolint: errcheck
|
||||
repo.WordCardsDeleteByRoomID(context.Background(), room.ID)
|
||||
// store it somewhere
|
||||
wordMap := map[string]string{
|
||||
"en": "assets/words/en_nouns.txt",
|
||||
|
Reference in New Issue
Block a user