haverer-0.3.0.0: Implementation of the rules of Love Letter

Safe HaskellNone
LanguageHaskell2010

Haverer.Action

Synopsis

Documentation

data BadPlay target Source

Instances

Show target => Show (BadPlay target) Source 

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 

data Action target Source

A validated card + play combination. Only guarantees that such a thing makes sense according to the rules, rather than the current state of the round.

Instances

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

bustingHand :: Card -> Card -> Bool Source

If you're holding the Minister, there's a potential to "bust out" -- to have to immediately leave the round because you're holding another high card.

getTarget :: Play target -> Maybe target Source

getValidPlays Source

Arguments

:: player

The current player

-> [player]

All other active players in the round

-> Card

The card they were dealt

-> Card

The card that was in their hand

-> [(Card, Play player)]

All valid plays

Return all valid plays for a hand.

If the hand is one that would bust out (see bustingHand) then returns an empty list.

playToAction :: (Eq target, MonadError (BadPlay target) m) => target -> Card -> Play target -> m (Action target) Source

Given a player, a card, and a choice of play, decide whether it's a valid action.

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