dominion-0.1.0.4: A simulator for the board game Dominion.

Safe HaskellNone

Dominion.Internal

Synopsis

Documentation

Note: You shouldn't need to import this module...the interesting functions are re-exported by the Dominion module.

Use any other functions in here at your own risk.

has :: PlayerId -> Card -> Dominion BoolSource

see if a player has a card in his hand.

 hasCard <- playerId `has` chapel

coinValue :: Card -> IntSource

What this card is worth in money.

getRound :: Dominion IntSource

Get the current round number.

handValue :: PlayerId -> Dominion IntSource

How much money this player's hand is worth (also counts any money you get from action cards, like +1 from market).

pileEmpty :: Card -> Dominion BoolSource

Check if this card's pile is empty.

getCard :: Card -> Dominion (Maybe Card)Source

Returns the card, or Nothing if that pile is empty. Useful because it automatically checks whether the pile is empty, and modifies state to subtract a card from the pile correctly.

log :: PlayerId -> String -> Dominion ()Source

Convenience function. Prints out a line if verbose, AND prints out info about the related player...name, money, of actions.

log_ :: String -> Dominion ()Source

Like log but doesn't print out info about a player

drawFromDeck :: PlayerId -> Int -> Dominion [Card]Source

Given a player id and a number of cards to draw, draws that many cards from the deck, shuffling if necessary. TODO if the deck doesn't have enough cards, we should draw the cards in the deck before shuffling and drawing the rest.

modifyPlayer :: PlayerId -> (Player -> Player) -> Dominion ()Source

Like modify for the State monad, but works on players. Takes a player id and a function that modifies the player.

modifyOtherPlayers :: PlayerId -> (Player -> Player) -> Dominion ()Source

Like modifyPlayer, but modifies every player *except* the one specified with the player id.

getPlayer :: PlayerId -> Dominion PlayerSource

Get player from game state specified by this id. This is useful sometimes:

 import qualified Dominion.Types as T
 import Control.Lens

 player <- getPlayer playerId

 -- How many buys does this player have?
 player ^. T.buys

 -- How many actions does this player have?
 player ^. T.actions

cardsOf :: Int -> a -> [a]Source

Convenience function. 4 `cardsOf` estate is the same as take 4 . repeat $ estate

pileOf :: a -> [a]Source

shuffleDeck :: PlayerId -> Dominion ()Source

Move this players discards + hand into his deck and shuffle the deck.

validateBuy :: PlayerId -> Card -> Dominion (PlayResult ())Source

Check that this player is able to purchase this card. Returns a Right if they can purchase the card, otherwise returns a Left with the reason why they can't purchase it.

validatePlay :: PlayerId -> Card -> Dominion (PlayResult ())Source

Check that this player is able to play this card. Returns a Right if they can play the card, otherwise returns a Left with the reason why they can't play it.

drawsUntil :: PlayerId -> ([Card] -> Dominion Bool) -> Dominion [Card]Source

Keep drawing a card until the provided function returns true. The function gets a list of the cards drawn so far, most recent first. Returns a list of all the cards drawn (these cards are also placed into the player's hand)

trashesCard :: PlayerId -> Card -> Dominion ()Source

Player trashes the given card.

discardsCard :: PlayerId -> Card -> Dominion ()Source

Player discards the given card.

discardsTo :: Player -> Int -> PlayerSource

Player discards down to x cards.

usesEffect :: PlayerId -> CardEffect -> Dominion (Maybe Followup)Source

Used internally by the plays function. Each card has a list of effects (like smithy has `PlusCard 3`). This function applies the given effect. It returns Nothing if the effect doesn't need a Followup, or it returns a `Just Followup`.

makePlayer :: String -> PlayerSource

Given a name, creates a player with that name.