deck

package
v0.0.0-...-bad9105 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2017 License: GPL-2.0 Imports: 3 Imported by: 1

Documentation

Overview

Package deck provides api for creating and using a deck of 24 cards.

Index

Constants

View Source
const Size = 24

Size is the number of cards in a deck.

Variables

View Source
var (
	OrderedDeck []string
	Points      map[byte]int
)

OrderedDeck is the initial full ordered deck. Points is a map connecting each card with its points.

Functions

func AreTheSameSuit

func AreTheSameSuit(card1, card2 string) bool

AreTheSameSuit returns true if card1 and card2 are from the same suit.

func HasHigherRank

func HasHigherRank(card1, card2 string) bool

HasHigherRank returns true if the rank of card1 is higher than the rank of card2.

Types

type Deck

type Deck struct {
	Initial []string
	Current []string
}

Deck contains the original deck and the current one (after drawing cards).

func New

func New() *Deck

New creates and returns an ordered deck of cards.

func (*Deck) DrawCard

func (d *Deck) DrawCard() (string, error)

DrawCard returns the top card of the deck if it has any.

func (*Deck) DrawNcards

func (d *Deck) DrawNcards(n int) ([]string, error)

DrawNcards returns the top n cards if n <= the size of the current deck.

func (*Deck) Shuffle

func (d *Deck) Shuffle()

Shuffle shuffles the Initial deck and makes a copy of it in Current.

Jump to

Keyboard shortcuts

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