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

Safe HaskellNone
LanguageHaskell98

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.

currentHand :: PlayerId -> Dominion [Card] Source #

see all of the cards in a player's hand.

cards <- currentHand playerId

has :: PlayerId -> Card -> Dominion Bool Source #

see if a player has a card in his hand.

hasCard <- playerId `has` chapel

countNum :: PlayerId -> Card -> Dominion Int Source #

see how many of this card a player has.

numMarkets <- countNum playerId market

coinValue :: Card -> Int Source #

What this card is worth in money.

getRound :: Dominion Int Source #

Get the current round number.

handValue :: PlayerId -> Dominion Int Source #

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 Bool Source #

Check if this card's pile is empty. Returns True is the card is not in play.

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.

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 Player Source #

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

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 -> Player Source #

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 -> Player Source #

Given a name, creates a player with that name.