Chore: solved some todos

This commit is contained in:
Grail Finder
2025-06-12 07:04:20 +03:00
parent 6934b724ae
commit 74b10b8395
10 changed files with 50 additions and 82 deletions

View File

@ -1,6 +1,7 @@
package models
import (
"errors"
"fmt"
"golias/utils"
"time"
@ -83,6 +84,25 @@ type Room struct {
TeamWon UserTeam // blue | red
}
func (r *Room) CanStart() error {
if r.IsRunning {
return errors.New("cannot start; game is already running")
}
if r.RedTeam.Mime == "" {
return errors.New("cannot start; red team has no mime")
}
if r.BlueTeam.Mime == "" {
return errors.New("cannot start; blue team has no mime")
}
if len(r.RedTeam.Guessers) == 0 {
return errors.New("cannot start; red team has no guessers")
}
if len(r.BlueTeam.Guessers) == 0 {
return errors.New("cannot start; blue team has no guessers")
}
return nil
}
// WhichBotToMove returns bot name that have to move or empty string
func (r *Room) WhichBotToMove() string {
fmt.Println("looking for bot to move", "team-turn", r.TeamTurn, "mime-done", r.MimeDone, "bot-map", r.BotMap, "is_running", r.IsRunning)
@ -141,46 +161,6 @@ func (r *Room) UpdateCounter() {
r.BlueCounter = blueCounter
}
// func (r *Room) LoadTestCards() {
// // TODO: pass room settings
// // TODO: map language to path
// 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)
// }
// r.Cards = cards
// // cards := []WordCard{
// // {Word: "hamster", Color: "blue"},
// // {Word: "child", Color: "red"},
// // {Word: "wheel", Color: "white"},
// // {Word: "condition", Color: "black"},
// // {Word: "test", Color: "white"},
// // {Word: "ball", Color: "blue"},
// // {Word: "violin", Color: "red"},
// // {Word: "rat", Color: "white"},
// // {Word: "perplexity", Color: "blue"},
// // {Word: "notion", Color: "red"},
// // {Word: "guitar", Color: "blue"},
// // {Word: "ocean", Color: "blue"},
// // {Word: "moon", Color: "blue"},
// // {Word: "coffee", Color: "blue"},
// // {Word: "mountain", Color: "blue"},
// // {Word: "book", Color: "blue"},
// // {Word: "camera", Color: "blue"},
// // {Word: "apple", Color: "red"},
// // {Word: "fire", Color: "red"},
// // {Word: "rose", Color: "red"},
// // {Word: "sun", Color: "red"},
// // {Word: "cherry", Color: "red"},
// // {Word: "heart", Color: "red"},
// // {Word: "tomato", Color: "red"},
// // {Word: "cloud", Color: "white"},
// // }
// // r.Cards = cards
// }
func (r *Room) ChangeTurn() {
switch r.TeamTurn {
case "blue":