Documentation
¶
Index ¶
Constants ¶
Variables ¶
View Source
var ( ErrCardCodeValueInvalid = errors.New("card code value is invalid") ErrCardCodeSuitInvalid = errors.New("card code suit is invalid") )
View Source
var ( ErrNotEnoughCards = errors.New("there is not enough cards in the deck for the operation") ErrDeckOpened = errors.New("not permitted on opened deck") ErrNotFound = errors.New("resource not found") ErrUUIDRequired = errors.New("uuid is required") ErrUUIDInvalid = errors.New("uuid is not valid") )
Functions ¶
This section is empty.
Types ¶
type CardService ¶
type CardService interface {
CardStorage
ByCodesStr(codesStr string) ([]*Card, error)
}
func NewCardService ¶
func NewCardService() CardService
NewCardService returns new CardService instance
type CardStorage ¶
type CardStorage interface {
// ByCode is used to retrieve single card by code
ByCode(code string) (*Card, error)
// All is used to retrieve all cards
All() ([]*Card, error)
}
CardStorage is used to interact with cards storage
type Deck ¶
type Deck struct {
UUID string `json:"deck_id"`
Shuffled bool `json:"shuffled"`
Remaining int `json:"remaining"`
Cards []*Card `json:"cards"`
CardCodes string `json:"-"`
Opened bool `json:"-"`
}
Deck is the representation of deck of cards
type DeckService ¶
type DeckService interface {
DeckStorage
Draw(deck *Deck, count int) ([]*Card, error)
Open(deck *Deck) error
}
func NewDeckService ¶
func NewDeckService(cs CardService) DeckService
NewDeckService returns deckService instance by defaults
type DeckStorage ¶
Click to show internal directories.
Click to hide internal directories.