card

package
v0.0.0-...-f4aeec7 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2016 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NumSuit  = 4
	NumRanks = 13
	NumCards = 4 * 13
)

Go does not have variant types :(

View Source
const (
	// Nil is used to check for uninitialised ranks
	Nil = RANK("")
	// Two Rank constant
	Two = RANK("2")
	// Three Rank constant
	Three = RANK("3")
	// Four Rank constant
	Four = RANK("4")
	// Five Rank constant
	Five = RANK("5")
	// Six Rank constant
	Six = RANK("6")
	// Seven Rank constant
	Seven = RANK("7")
	// Eight Rank constant
	Eight = RANK("8")
	// Nine Rank constant
	Nine = RANK("9")
	// Ten Rank constant
	Ten = RANK("T")
	// Jack Rank constant
	Jack = RANK("J")
	// Queen Rank constant
	Queen = RANK("Q")
	// King Rank constant
	King = RANK("K")
	// Ace Rank constant
	Ace = RANK("A")
)
View Source
const (
	// Clubs Suit constant
	Clubs = SUIT("C")
	// Diamonds Suit constant
	Diamonds = SUIT("D")
	// Hearts Suit constant
	Hearts = SUIT("H")
	// Spades Suit constant
	Spades = SUIT("S")
)

Variables

View Source
var RankIndexes = map[RANK]int{
	Two:   0,
	Three: 1,
	Four:  2,
	Five:  3,
	Six:   4,
	Seven: 5,
	Eight: 6,
	Nine:  7,
	Ten:   8,
	Jack:  9,
	Queen: 10,
	King:  11,
	Ace:   12,
}

RankIndexes ...

View Source
var Ranks = []RANK{
	Two,
	Three,
	Four,
	Five,
	Six,
	Seven,
	Eight,
	Nine,
	Ten,
	Jack,
	Queen,
	King,
	Ace,
}

Ranks is a slice of all ranks

View Source
var SuitIndexes = map[SUIT]int{
	Clubs:    0,
	Diamonds: 1,
	Hearts:   2,
	Spades:   3,
}

SuitIndexes ...

View Source
var Suits = []SUIT{
	Clubs,
	Diamonds,
	Hearts,
	Spades,
}

Suits is a slice of all suits

Functions

This section is empty.

Types

type Card

type Card struct {
	Rank RANK
	Suit SUIT
}

Card is the type that represents a playing card

func FromString

func FromString(s string) *Card

FromString converts a string into a card struct representation

func New

func New(v RANK, s SUIT) *Card

New creates a new instance of the card object

func (*Card) Connected

func (c *Card) Connected(a *Card) bool

Connected returns true if the given card is adjacent (connected in a straight) to the current card, includes K <-> A, A <-> 2

func (*Card) String

func (c *Card) String() string

String representation of a card

type RANK

type RANK string

RANK represents a card rank "2" -> "A"

type SUIT

type SUIT string

SUIT represents one of the four suits

Jump to

Keyboard shortcuts

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