package game import ( "crypto/rand" "doudizhu-server/internal/models" "encoding/hex" "errors" "fmt" ) var ( ErrRoomNotFound = errors.New("room not found") ErrRoomFull = errors.New("room is full") ErrGameStarted = errors.New("game already started") ErrGameNotStarted = errors.New("game not started") ErrPlayerNotFound = errors.New("player not found") ErrNotEnoughPlayers = errors.New("not enough players") ErrPlayerNotReady = errors.New("player not ready") ErrNotYourTurn = errors.New("not your turn") ErrCardsNotInHand = errors.New("cards not in hand") ErrInvalidCardType = errors.New("invalid card type") ErrCannotBeat = errors.New("cannot beat last play") ErrCannotPass = errors.New("cannot pass") ) func generateID() string { b := make([]byte, 8) rand.Read(b) return hex.EncodeToString(b) } func cardKey(c models.Card) string { return fmt.Sprintf("%d_%d", c.Suit, c.Value) }