general-games-0.4.0: Library supporting simulation of a number of games

Copyright(c) 2017 Christopher A. Gorski
LicenseMIT
MaintainerChristopher A. Gorski <cgorski@cgorski.org>
Safe HaskellSafe
LanguageHaskell2010

Game.Implement.Card

Description

The Game.Implement.Card module provides fundamental operations for a deck of cards.

Synopsis

Documentation

class (Enum c, Eq c, Ord c, Bounded c) => Card c where Source #

Represents a physical card with no order and no value. Inherited Enum, Eq, Ord and Bounded typeclasses are used to distingish cards for the purposes of manipulation within lists. Game value functions are provided by other typeclasses.

Methods

fullDeck :: [c] Source #

Return all cards in a list. Cards will appear at most once. Order is not guaranteed.

>>> fullDeck :: [PlayingCard]
[Ace of Clubs,Two of Clubs,Three of Clubs,Four of Clubs,Five of Clubs,Six of Clubs,Seven of Clubs,Eight of Clubs,Nine of Clubs,Ten of Clubs,Jack of Clubs,Queen of Clubs,King of Clubs,Ace of Diamonds,Two of Diamonds,Three of Diamonds,Four of Diamonds,Five of Diamonds,Six of Diamonds,Seven of Diamonds,Eight of Diamonds,Nine of Diamonds,Ten of Diamonds,Jack of Diamonds,Queen of Diamonds,King of Diamonds,Ace of Hearts,Two of Hearts,Three of Hearts,Four of Hearts,Five of Hearts,Six of Hearts,Seven of Hearts,Eight of Hearts,Nine of Hearts,Ten of Hearts,Jack of Hearts,Queen of Hearts,King of Hearts,Ace of Spades,Two of Spades,Three of Spades,Four of Spades,Five of Spades,Six of Spades,Seven of Spades,Eight of Spades,Nine of Spades,Ten of Spades,Jack of Spades,Queen of Spades,King of Spades]

dedupe :: [c] -> [c] Source #

draw :: [Int] -> [c] -> Maybe ([[c]], [c]) Source #

shuffle :: RandomGen m => [c] -> Rand m [c] Source #

randomCard :: RandomGen m => Rand m c Source #

class Card c => ValuedCard c v where Source #

Represents a playing card with a game value. For instance, a standard playing card with a type representing rank and suit.

Minimal complete definition

toValue

Methods

toValue :: c -> v Source #

toValueLst :: [c] -> [v] Source #

class Card c => OrderedCard c o where Source #

Orderings independent of a specific value type of a Card.

Minimal complete definition

compareCardBy

Methods

highestCardBy :: o -> [c] -> c Source #

lowestCardBy :: o -> [c] -> c Source #

compareCardBy :: o -> c -> c -> Ordering Source #

sortCardsBy :: o -> [c] -> [c] Source #

class OrderedCard c o => OrderedValuedCard c o vt where Source #

Minimal complete definition

toOrderedValue

Methods

toOrderedValue :: o -> vt -> c -> Int Source #

Return an Int based on a card, an ordering and a value type.