Chore: remove unused WCMap
This commit is contained in:
		| @@ -205,10 +205,10 @@ func loadCards(room *models.Room) { | ||||
| 		fmt.Println("failed to load cards", "error", err) | ||||
| 	} | ||||
| 	room.Cards = cards | ||||
| 	room.WCMap = make(map[string]models.WordColor) | ||||
| 	for _, card := range room.Cards { | ||||
| 		room.WCMap[card.Word] = card.Color | ||||
| 	} | ||||
| 	// room.WCMap = make(map[string]models.WordColor) | ||||
| 	// for _, card := range room.Cards { | ||||
| 	// 	room.WCMap[card.Word] = card.Color | ||||
| 	// } | ||||
| } | ||||
|  | ||||
| func recoverBots() { | ||||
|   | ||||
| @@ -50,7 +50,8 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) { | ||||
| 		abortWithError(w, err.Error()) | ||||
| 		return | ||||
| 	} | ||||
| 	color, exists := fi.Room.WCMap[word] | ||||
| 	// color, exists := fi.Room.WCMap[word] | ||||
| 	color, exists := fi.Room.FindColor(word) | ||||
| 	if !exists { | ||||
| 		abortWithError(w, "word is not found") | ||||
| 		return | ||||
| @@ -191,8 +192,9 @@ func HandleMarkCard(w http.ResponseWriter, r *http.Request) { | ||||
| 		abortWithError(w, err.Error()) | ||||
| 		return | ||||
| 	} | ||||
| 	color, exists := fi.Room.WCMap[word] | ||||
| 	log.Debug("got show-color request", "word", word, "color", color) | ||||
| 	// color, exists := fi.Room.WCMap[word] | ||||
| 	color, exists := fi.Room.FindColor(word) | ||||
| 	log.Debug("got mark-card request", "word", word, "color", color) | ||||
| 	if !exists { | ||||
| 		abortWithError(w, "word is not found") | ||||
| 		return | ||||
|   | ||||
| @@ -2,7 +2,6 @@ package handlers | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
| 	"gralias/models" | ||||
| 	"log/slog" | ||||
| 	"strconv" | ||||
| @@ -55,7 +54,7 @@ func StartTurnTimer(roomID string, timeLeft uint32) { | ||||
| 					return | ||||
| 				} | ||||
| 				timeLeft-- | ||||
| 				notify(models.NotifyTurnTimerPrefix+roomID, fmt.Sprintf("%d", timeLeft)) | ||||
| 				notify(models.NotifyTurnTimerPrefix+roomID, strconv.FormatUint(uint64(timeLeft), 10)) | ||||
| 			} | ||||
| 		} | ||||
| 	}() | ||||
|   | ||||
| @@ -68,7 +68,8 @@ func (b *Bot) checkGuesses(tempMap map[string]any, room *models.Room) error { | ||||
| } | ||||
|  | ||||
| func (b *Bot) checkGuess(word string, room *models.Room) error { | ||||
| 	color, exists := room.WCMap[word] | ||||
| 	// color, exists := room.WCMap[word] | ||||
| 	color, exists := room.FindColor(word) | ||||
| 	b.log.Debug("bot trying to open card", "word", word, "color", | ||||
| 		color, "exists", exists, "limit", room.ThisTurnLimit, | ||||
| 		"opened", room.OpenedThisTurn) | ||||
|   | ||||
| @@ -4,6 +4,7 @@ import ( | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
| 	"gralias/utils" | ||||
| 	"strings" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/rs/xid" | ||||
| @@ -150,13 +151,22 @@ type Room struct { | ||||
| 	RedTeam       Team       `db:"-"` | ||||
| 	BlueTeam      Team       `db:"-"` | ||||
| 	Cards         []WordCard `db:"-"` | ||||
| 	WCMap         map[string]WordColor `db:"-"` | ||||
| 	// WCMap         map[string]WordColor `db:"-"` | ||||
| 	BotMap     map[string]BotPlayer `db:"-"` | ||||
| 	Mark       CardMark             `db:"-"` | ||||
| 	LogJournal []string             `db:"-"` | ||||
| 	Settings   GameSettings         `db:"-"` | ||||
| } | ||||
|  | ||||
| func (r *Room) FindColor(word string) (WordColor, bool) { | ||||
| 	for _, card := range r.Cards { | ||||
| 		if strings.EqualFold(card.Word, word) { | ||||
| 			return card.Color, true | ||||
| 		} | ||||
| 	} | ||||
| 	return "", false | ||||
| } | ||||
|  | ||||
| func (r *Room) ClearMarks() { | ||||
| 	for i, _ := range r.Cards { | ||||
| 		r.Cards[i].Mark = []CardMark{} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Grail Finder
					Grail Finder