card

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Card

type Card struct {
	// contains filtered or unexported fields
}

Card represents a card in a deck.

func NewCard

func NewCard(r Rank, s Suit, c Code) *Card

NewCard returns a new card given a rank and suit.

func NewCards

func NewCards(comp Composition, codes ...Code) ([]Card, error)

NewCards returns a collection of cards using the given ranks, suits and codes.

func (*Card) Code

func (c *Card) Code() Code

Code returns the code of the card.

func (*Card) Rank

func (c *Card) Rank() Rank

Rank returns the rank of the card.

func (*Card) Suit

func (c *Card) Suit() Suit

Suit returns the suit of the card.

type Code

type Code struct {
	// contains filtered or unexported fields
}

Code represents a card code.

func NewCode

func NewCode(c string) (*Code, error)

NewCode returns a new card code given a string. The string must be 2 characters long. The first character must be a valid rank. The second character must be a valid suit.

func NewCodeFromRankSuit

func NewCodeFromRankSuit(r Rank, s Suit) (*Code, error)

NewCodeFromRankSuit returns a new code given a rank and suit.

func NewCodes

func NewCodes(cc ...string) ([]Code, error)

NewCodes returns a collection of codes given a collection of string.

func (Code) MarshalJSON

func (c Code) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (Code) Rank

func (c Code) Rank() string

Rank returns the rank.

func (Code) String

func (c Code) String() string

String implements the Stringer interface.

func (Code) Suit

func (c Code) Suit() string

Suit returns the suit.

func (*Code) UnmarshalJSON

func (c *Code) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type Composition

type Composition struct {
	// contains filtered or unexported fields
}

Composition represents a collection of ranks and suits. (e.g french)

func NewComposition

func NewComposition(r Ranks, s Suits) Composition

NewComposition returns a new card composition given a collection of ranks and suits.

func (Composition) Ranks

func (c Composition) Ranks() Ranks

Ranks returns a collection of ranks.

func (Composition) Suits

func (c Composition) Suits() Suits

Suits returns a collection of suits.

type Rank

type Rank struct {
	// contains filtered or unexported fields
}

Rank represents the rank of a card.

func NewRank

func NewRank(name, code string) Rank

NewRank returns a new rank given a name and code.

func (Rank) Code

func (r Rank) Code() string

Code returns the code of the rank.

func (Rank) String

func (r Rank) String() string

String implements the Stringer interface.

type Ranks

type Ranks []Rank

Ranks is a collection of Rank.

func (Ranks) RankFromCode

func (rs Ranks) RankFromCode(c Code) (*Rank, bool)

RankFromCode returns the rank from the given code.

func (Ranks) Ranks

func (rs Ranks) Ranks() []Rank

Ranks returns the french ranks.

type Suit

type Suit struct {
	// contains filtered or unexported fields
}

Suit represents the suit of a card.

func NewSuit

func NewSuit(name, code string) Suit

NewSuit returns a new suit given a name and code.

func (Suit) Code

func (s Suit) Code() string

Code returns the code of the suit.

func (Suit) String

func (s Suit) String() string

String implements the Stringer interface.

type Suits

type Suits []Suit

Suits is a collection of Suit.

func (Suits) SuitFromCode

func (ss Suits) SuitFromCode(c Code) (*Suit, bool)

SuitFromCode returns the suit from the given code.

func (Suits) Suits

func (ss Suits) Suits() []Suit

Suits returns the french suits.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL