Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data Round playerId
- makeRound :: (Ord playerId, Show playerId) => Deck Complete -> PlayerSet playerId -> Round playerId
- playTurn :: (Ord playerId, Show playerId) => Round playerId -> Either (ActionM playerId (Result playerId, Round playerId)) (Card -> Play playerId -> ActionM playerId (Result playerId, Round playerId))
- playTurn' :: (Ord playerId, Show playerId) => Round playerId -> Maybe (Card, Play playerId) -> ActionM playerId (Result playerId, Round playerId)
- data BadAction playerId
- data Result playerId
- data Event playerId
- = NoChange
- | Protected playerId
- | SwappedHands playerId playerId
- | Eliminated playerId
- | ForcedDiscard playerId
- | ForcedReveal playerId playerId Card
- currentPlayer :: Round playerId -> Maybe playerId
- currentTurn :: Ord playerId => Round playerId -> Maybe (playerId, (Card, Card))
- getActivePlayers :: Round playerId -> [playerId]
- getPlayer :: Ord playerId => Round playerId -> playerId -> Maybe Player
- getPlayerMap :: Round playerId -> Map playerId Player
- getPlayers :: Round playerId -> [playerId]
- getWinners :: Victory playerId -> [playerId]
- nextPlayer :: Round playerId -> Maybe playerId
- remainingCards :: Round playerId -> Int
- data Victory playerId
- = SoleSurvivor playerId Card
- | HighestCard Card [playerId] [(playerId, Card)]
- victory :: Round playerId -> Maybe (Victory playerId)
- prop_allCardsPresent :: Round playerId -> Bool
- prop_burnCardsSame :: [Round playerId] -> Bool
- prop_multipleActivePlayers :: Round playerId -> Bool
- prop_ringIsActivePlayers :: Eq playerId => Round playerId -> Bool
Documentation
makeRound :: (Ord playerId, Show playerId) => Deck Complete -> PlayerSet playerId -> Round playerId Source
Make a new round, given a complete Deck and a set of players.
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.
The result of a turn.
A change to the Round that comes as result of a player's actions.
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. |
currentPlayer :: Round playerId -> Maybe playerId Source
The ID of the current player. If the Round is over or not started, this will be Nothing.
getActivePlayers :: Round playerId -> [playerId] Source
The IDs of all of the active players.
getPlayer :: Ord playerId => Round playerId -> playerId -> Maybe Player Source
Get the player with the given ID. Nothing if there is no such player.
getPlayerMap :: Round playerId -> Map playerId Player Source
A map of player IDs to players.
getPlayers :: Round playerId -> [playerId] Source
The IDs of all of the players.
getWinners :: Victory playerId -> [playerId] Source
nextPlayer :: Round playerId -> Maybe playerId Source
remainingCards :: Round playerId -> Int Source
The number of cards remaining in the deck.
SoleSurvivor playerId Card | The given player is the only survivor. |
HighestCard Card [playerId] [(playerId, Card)] | These players have the highest card. |
victory :: Round playerId -> Maybe (Victory playerId) Source
If the Round is Over, return the Victory data. Otherwise, Nothing.
prop_allCardsPresent :: Round playerId -> Bool Source
Are all the cards in the Round?
prop_burnCardsSame :: [Round playerId] -> Bool Source
prop_multipleActivePlayers :: Round playerId -> Bool Source
prop_ringIsActivePlayers :: Eq playerId => Round playerId -> Bool Source