Safe Haskell | None |
---|
- data CardType
- data CardEffect
- = CoinValue Int
- | VPValue Int
- | PlusCard Int
- | PlusCoin Int
- | PlusBuy Int
- | PlusAction Int
- | DurationDraw Int
- | DurationAction Int
- | DurationCoin Int
- | DurationBuy Int
- | TrashCards Int
- | TrashThisCard
- | GainCardUpto Int
- | PlayActionCard Int
- | AdventurerEffect
- | BureaucratEffect
- | CellarEffect
- | ChancellorEffect
- | GardensEffect
- | LibraryEffect
- | MineEffect
- | MoneylenderEffect
- | RemodelEffect
- | SpyEffect
- | ThiefEffect
- | OthersPlusCard Int
- | OthersDiscardTo Int
- | OthersGainCurse Int
- data Card = Card {}
- name :: Lens' Card String
- effects :: Lens' Card [CardEffect]
- cost :: Lens' Card Int
- cardType :: Lens' Card [CardType]
- data ThiefTrashAction
- data FollowupAction
- data Player = Player {}
- playerName :: Lens' Player String
- hand :: Lens' Player [Card]
- extraMoney :: Lens' Player Int
- discard :: Lens' Player [Card]
- deck :: Lens' Player [Card]
- buys :: Lens' Player Int
- actions :: Lens' Player Int
- type PlayerId = Int
- data GameState = GameState {}
- verbose :: Lens' GameState Bool
- round :: Lens' GameState Int
- players :: Lens' GameState [Player]
- cards :: Lens' GameState [Card]
- type Dominion a = StateT GameState IO a
- type Strategy = PlayerId -> Dominion ()
- type PlayResult a = Either String a
- type Followup = (PlayerId, CardEffect)
- data Option
- type PlayerResult = (Player, Int)
- data Result = Result {
- playerResults :: [PlayerResult]
- winner :: String
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 CardEffect Source
effects :: Lens' Card [CardEffect]Source
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
.
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 |
Workshop Card | Takes the card you want to gain. |
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
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 aSource
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.
You can set these options if you use dominionWithOpts
. Example:
main = dominionWithOpts [Iterations 1, Log True, Cards [smithy]] ...
type PlayerResult = (Player, Int)Source
Each PlayerResult
is a tuple of a player and their final score.
Players and their scores.
Result | |
|