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

Safe HaskellNone
LanguageHaskell98

Dominion.Types

Synopsis

Documentation

This module uses the Lens library. So you might notice that the fields for the constructors look strange: they all have underscores. Given a card, you can see the cost like this:

_cost card

But you can also use a lens:

card ^. cost

The lens library is very useful for modifying deeply nested data structures, and it's been very useful for this module.

data Card Source #

Constructors

Card 

Instances

Eq Card Source # 

Methods

(==) :: Card -> Card -> Bool #

(/=) :: Card -> Card -> Bool #

Ord Card Source # 

Methods

compare :: Card -> Card -> Ordering #

(<) :: Card -> Card -> Bool #

(<=) :: Card -> Card -> Bool #

(>) :: Card -> Card -> Bool #

(>=) :: Card -> Card -> Bool #

max :: Card -> Card -> Card #

min :: Card -> Card -> Card #

Show Card Source # 

Methods

showsPrec :: Int -> Card -> ShowS #

show :: Card -> String #

showList :: [Card] -> ShowS #

data ThiefTrashAction Source #

Used with the thief card.

data FollowupAction Source #

Some cards have a followup action associated with them. For example, when you play a workshop, you need to choose what card you're going to get. To use the followup action, you need to use the relevant data constructor. See the documentation for each card to find out how to use each type of FollowupAction.

Constructors

ThroneRoom Card 
Cellar [Card]

Takes a list of cards to discard.

Chancellor Bool

Boolean value representing whether you want to move your deck into the discard pile.

Chapel [Card]

Takes a list of cards to trash.

Feast Card

Takes the card you want to gain.

Mine Card

Takes the card you want to trash.

Remodel (Card, Card)

The first card is the card you are trashing, the second card is the card you are gaining.

Spy ([Card], [Card])

The first element is the list of cards you would discard for yourself, the second is the lsit of cards you want others to discard.

Thief ([Card] -> ThiefTrashAction)

The function gets a list of treasure cards. had. You return either TrashOnly to have the player trash a card, or GainTrashedCard to gain the trashed card. This function is called for every other player in the game.

Workshop Card

Takes the card you want to gain.

data Player Source #

Constructors

Player 

Fields

Instances

data GameState Source #

This is what keeps track of all the state in the whole game. Get the round number like this:

state <- get
let roundNum = state ^. round

Constructors

GameState 

Fields

type Strategy = PlayerId -> Dominion () Source #

Given a playerId, run some actions for this player. Example:

bigMoney playerId = playerId `buysByPreference` [province, gold, duchy, silver, copper]

type PlayResult a = Either String a Source #

When you use a card (either you play it or you buy something), you get a PlayResult. A PlayResult is either a Left with an error message, or a Right with a value.

type Followup = (PlayerId, CardEffect) Source #

When you play an action card that needs a decision on your part, plays will return a Followup.

data Option Source #

You can set these options if you use dominionWithOpts. Example:

main = dominionWithOpts [Iterations 1, Log True, Cards [smithy]] ...

Constructors

Iterations Int

Number of iterations to run.

Log Bool

Enable logging

Cards [Card]

A list of cards that you definitely want in the game. Useful if you are testing a strategy that relies on a particular card.

Instances

type PlayerResult = (Player, Int) Source #

Each PlayerResult is a tuple of a player and their final score.

data Result Source #

Players and their scores.

Constructors

Result 

Instances