haverer-0.3.0.0: Implementation of the rules of Love Letter

Safe HaskellNone
LanguageHaskell2010

Haverer

Description

Implementation of the rules of Love Letter.

Synopsis

Documentation

data Game playerId Source

Instances

Show playerId => Show (Game playerId) Source 

makeGame :: Ord playerId => PlayerSet playerId -> Game playerId Source

Create a new game for the given set of players.

newRound :: (Functor m, MonadRandom m, Ord playerId, Show playerId) => Game playerId -> m (Round playerId) Source

Start a new round of the game, shuffling the deck cards ourselves.

newRound' :: (Ord playerId, Show playerId) => Game playerId -> FullDeck -> Round playerId Source

Start a new round of the game with an already-shuffled deck of cards.

players :: Game playerId -> PlayerSet playerId Source

Return the set of all players

roundsPlayed :: Game playerId -> Int Source

Return the number of rounds played.

finalScores :: Ord playerId => Outcome playerId -> [(playerId, Int)] Source

Get the final scores at the end of the game.

scores :: Ord playerId => Game playerId -> [(playerId, Int)] Source

Return the current scores of all the players.

winners :: Ord playerId => Outcome playerId -> [playerId] Source

Get the winners of the game.

data Round playerId Source

Instances

Show playerId => Show (Round playerId) Source 

data BadAction playerId Source

Instances

Show playerId => Show (BadAction playerId) Source 

data Result playerId Source

The result of a turn.

Constructors

BustedOut playerId Card Card

The player whose turn it was "busted out", they held the Minister and another high card, and thus didn't get to play.

Played (Action playerId) (Event playerId)

The player performed an Action resulting in Event.

Instances

Eq playerId => Eq (Result playerId) Source 
Show playerId => Show (Result playerId) Source 

data Event playerId Source

A change to the Round that comes as result of a player's actions.

Constructors

NoChange

Nothing happened. What the player did had no effect.

Protected playerId

The player is now protected.

SwappedHands playerId playerId

The first player has been forced to swap hands with the second.

Eliminated playerId

The player has been eliminated from the round.

ForcedDiscard playerId

The player has been forced to discard their hand.

ForcedReveal playerId playerId Card

The second player has been forced to show their hand to the first.

Instances

Eq playerId => Eq (Event playerId) Source 
Show playerId => Show (Event playerId) Source 

playTurn :: (Ord playerId, Show playerId) => Round playerId -> Either (ActionM playerId (Result playerId, Round playerId)) (Card -> Play playerId -> ActionM playerId (Result playerId, Round playerId)) Source

Play a turn in a Round.

This is the main function in this module.

A turn has two steps. First, the player draws a card. If their hand "busts out" (due to holding the Minister and another high card), then they are eliminated and play proceeds to the next player. This is the Left return value, which returns the new Round and a Result indicating the player bust out.

Second, the player plays one of these two cards. This is the Right return value, a function that takes the players chosen card and play, and returns either a BadAction or a new Round together with the Result of the play.

playTurn' :: (Ord playerId, Show playerId) => Round playerId -> Maybe (Card, Play playerId) -> ActionM playerId (Result playerId, Round playerId) Source

Play a turn in a Round

Similar to playTurn, except that instead of splitting the turn into two phases, there is a single, optional play. If the hand is a busting hand, then the play must be Nothing; if not, the play must be specified.

getPlayers :: Round playerId -> [playerId] Source

The IDs of all of the players.

getPlayerMap :: Round playerId -> Map playerId Player Source

A map of player IDs to players.

currentPlayer :: Round playerId -> Maybe playerId Source

The ID of the current player. If the Round is over or not started, this will be Nothing.

currentTurn :: Ord playerId => Round playerId -> Maybe (playerId, (Card, Card)) Source

data Deck a Source

Instances

data DeckSize Source

Constructors

Incomplete 
Complete 

data Play target Source

A thing that can be done with a card.

Constructors

NoEffect 
Attack target 
Guess target Card 

Instances

Eq target => Eq (Play target) Source 
Show target => Show (Play target) Source 

viewAction :: Action target -> (target, Card, Play target) Source