Safe Haskell | None |
---|---|
Language | Haskell2010 |
V2 makes the following changes from V1:
- withLocation now only takes a Location, using the current actor for player.
- Flips argument order for
validate
functions to be consistent with rest of API. activate
andtrigger
use the stack.- Fork has a saner API and reports properly.
formatter
now takes aStep
rather than anInt
.view
is re-exported since it will virtually always be required for normal formatters.
Synopsis
- module Dovin.Runner
- module Dovin.Actions
- module Dovin.Attributes
- addCard :: CardName -> GameMonad ()
- addAura :: CardName -> GameMonad ()
- addArtifact :: CardName -> GameMonad ()
- addCreature :: (Int, Int) -> CardName -> GameMonad ()
- addPlaneswalker :: Int -> CardName -> GameMonad ()
- addEnchantment :: CardName -> GameMonad ()
- addInstant :: CardName -> GameMonad ()
- addLand :: CardName -> GameMonad ()
- addLands :: Int -> CardName -> GameMonad ()
- addSorcery :: CardName -> GameMonad ()
- as :: Player -> GameMonad () -> GameMonad ()
- withAttribute :: String -> GameMonad () -> GameMonad ()
- withAttributes :: [String] -> GameMonad () -> GameMonad ()
- withEffectWhen :: EffectMonad Bool -> EffectMonad CardMatcher -> [LayeredEffectPart] -> EffectName -> GameMonad () -> GameMonad ()
- withCMC :: Int -> GameMonad () -> GameMonad ()
- withLocation :: Location -> GameMonad () -> GameMonad ()
- withOwner :: Player -> GameMonad () -> GameMonad ()
- withPlusOneCounters :: Int -> GameMonad () -> GameMonad ()
- withMinusOneCounters :: Int -> GameMonad () -> GameMonad ()
- module Dovin.Formatting
- module Dovin.Helpers
- type Formatter = Board -> String
- type GameMonad a = ExceptT String (ReaderT Env (StateT Board (WriterT [Step] Identity))) a
- data Step = Step {}
- type StepIdentifier = (Maybe String, Int)
- data Env = Env {}
- data Board = Board {}
- type EffectName = String
- data CardMatcher = CardMatcher String (Card -> Bool)
- newtype BaseCard = BaseCard Card
- data Card = Card {
- _cardName :: CardName
- _location :: (Player, Location)
- _cardOwner :: Player
- _cardDefaultAttributes :: CardAttributes
- _cardAttributes :: CardAttributes
- _cardStrength :: CardStrength
- _cardStrengthModifier :: CardStrength
- _cardDamage :: Int
- _cardLoyalty :: Int
- _cardEffects :: [CardEffect]
- _cardCmc :: Int
- _cardColors :: Colors
- _cardTargets :: [Target]
- _cardTimestamp :: Timestamp
- _cardPassiveEffects :: [LayeredEffectDefinition]
- _cardAbilityEffects :: [AbilityEffect]
- _cardPlusOneCounters :: Int
- _cardMinusOneCounters :: Int
- data AbilityEffect = AbilityEffect Timestamp EffectDuration [LayeredEffectPart]
- data EffectDuration = EndOfTurn
- type Timestamp = Integer
- data Phase
- data CardStrength = CardStrength Int Int
- type CardAttributes = Set CardAttribute
- type CardLocation = (Player, Location)
- data Target
- data LayeredEffectDefinition = LayeredEffectDefinition {}
- type LayeredEffect = [LayeredEffectPart]
- data LayeredEffectPart = LayeredEffectPart Layer (Card -> EffectMonad Card)
- data Layer
- type EffectMonad a = Reader EffectMonadEnv a
- type EffectMonadEnv = (Board, Card)
- data CardEffect = CardEffect {
- _effectEnabled :: CardMatcher
- _effectFilter :: Card -> CardMatcher
- _effectAction :: Card -> GameMonad Card
- data Location
- type ManaString = String
- type ManaPool = String
- data Player
- type CardAttribute = String
- type CardName = String
- type Colors = Set Color
- data Color
- allLayers :: [Layer]
- mkEffect :: CardMatcher -> (Card -> CardMatcher) -> (Card -> Identity Card) -> CardEffect
- mkLayeredEffectPart :: EffectMonad CardMatcher -> LayeredEffect -> EffectName -> LayeredEffectDefinition
- targetPlayer :: Player -> Target
- targetCard :: CardName -> Target
- incrementStep :: StepIdentifier -> StepIdentifier
- counters :: Lens' Board (HashMap String Int)
- currentTime :: Lens' Board Timestamp
- cardAbilityEffects :: Lens' Card [AbilityEffect]
- cardAttributes :: Lens' Card CardAttributes
- cardCmc :: Lens' Card Int
- cardColors :: Lens' Card Colors
- cardDamage :: Lens' Card Int
- cardDefaultAttributes :: Lens' Card CardAttributes
- cardEffects :: Lens' Card [CardEffect]
- cardLoyalty :: Lens' Card Int
- cardMinusOneCounters :: Lens' Card Int
- cardName :: Lens' Card CardName
- cardOwner :: Lens' Card Player
- cardPassiveEffects :: Lens' Card [LayeredEffectDefinition]
- cardPlusOneCounters :: Lens' Card Int
- cardStrength :: Lens' Card CardStrength
- cardStrengthModifier :: Lens' Card CardStrength
- cardTargets :: Lens' Card [Target]
- cardTimestamp :: Lens' Card Timestamp
- location :: Lens' Card (Player, Location)
- effectAction :: Lens' CardEffect (Card -> GameMonad Card)
- effectEnabled :: Lens' CardEffect CardMatcher
- effectFilter :: Lens' CardEffect (Card -> CardMatcher)
- envActor :: Lens' Env Player
- envOwner :: Lens' Env (Maybe Player)
- envSBAEnabled :: Lens' Env Bool
- envTemplate :: Lens' Env Card
- stepId :: Lens' Step StepIdentifier
- stepLabel :: Lens' Step String
- stepState :: Lens' Step Board
- leAppliesTo :: Lens' LayeredEffectDefinition (EffectMonad CardMatcher)
- leEffect :: Lens' LayeredEffectDefinition LayeredEffect
- leName :: Lens' LayeredEffectDefinition EffectName
- stepFork :: Lens' Step (Maybe String)
- stepNumber :: Lens' Step Int
- mkStep :: StepIdentifier -> String -> Board -> Step
- cardLocation :: Lens' Card (Player, Location)
- cardPower :: Lens' Card Int
- cardToughness :: Lens' Card Int
- cardController :: Lens' Card Player
- manaPoolFor :: Functor f => Player -> ([Char] -> f [Char]) -> Board -> f Board
- _manaPoolForTyping :: Board -> ManaPool
- emptyEnv :: Env
- mkStrength :: (Int, Int) -> CardStrength
- emptyCard :: Card
- mkCard :: CardName -> (Player, Location) -> Card
- opposing :: Player -> Player
- emptyBoard :: Board
- module Dovin.Matchers
- view :: MonadReader s m => Getting a s a -> m a
- withEffect :: CardMatcher -> (Card -> CardMatcher) -> (Card -> Identity Card) -> GameMonad () -> GameMonad ()
Documentation
module Dovin.Runner
module Dovin.Actions
module Dovin.Attributes
addArtifact :: CardName -> GameMonad () Source #
addEnchantment :: CardName -> GameMonad () Source #
addInstant :: CardName -> GameMonad () Source #
addSorcery :: CardName -> GameMonad () Source #
withAttribute :: String -> GameMonad () -> GameMonad () Source #
Add an attribute to the created card, as identified by a string. Attributes with that special meaning to Dovin built-ins (such as flying) are defined in Dovin.Attributes.
withAttributes :: [String] -> GameMonad () -> GameMonad () Source #
Helper version of withAttribute
for adding multiple attributes at a
time.
:: EffectMonad Bool | Effect only applies when this returns true |
-> EffectMonad CardMatcher | The set of cards to apply the effect to |
-> [LayeredEffectPart] | The effect to apply |
-> EffectName | Human-readable description, cosmetic only. |
-> GameMonad () | |
-> GameMonad () |
A more flexible version of withEffect
that allows customization of then
the effect should apply.
withCMC :: Int -> GameMonad () -> GameMonad () Source #
Set the converted mana cost of the created card.
withLocation :: Location -> GameMonad () -> GameMonad () Source #
Place the created card into a specific location.
withOwner :: Player -> GameMonad () -> GameMonad () Source #
Set the owner for the created card. If not specified, defaults to the owner of the card location.
withPlusOneCounters :: Int -> GameMonad () -> GameMonad () Source #
Set the number of +1/+1 counters of the created card.
withMinusOneCounters :: Int -> GameMonad () -> GameMonad () Source #
Set the number of -1/-1 counters of the created card.
module Dovin.Formatting
module Dovin.Helpers
Step | |
|
Env | |
|
Board | |
|
type EffectName = String Source #
data CardMatcher Source #
CardMatcher String (Card -> Bool) |
Instances
Show CardMatcher Source # | |
Defined in Dovin.Types showsPrec :: Int -> CardMatcher -> ShowS # show :: CardMatcher -> String # showList :: [CardMatcher] -> ShowS # | |
Semigroup CardMatcher Source # | |
Defined in Dovin.Types (<>) :: CardMatcher -> CardMatcher -> CardMatcher # sconcat :: NonEmpty CardMatcher -> CardMatcher # stimes :: Integral b => b -> CardMatcher -> CardMatcher # | |
Monoid CardMatcher Source # | |
Defined in Dovin.Types mempty :: CardMatcher # mappend :: CardMatcher -> CardMatcher -> CardMatcher # mconcat :: [CardMatcher] -> CardMatcher # |
A phase or step in a turn. Phases and steps are not distinguished between because haven't seen a need to.
Untap | |
Upkeep | |
DrawStep | |
FirstMain | |
BeginCombat | |
DeclareAttackers | |
DeclareBlockers | |
FirstStrikeDamage | |
CombatDamage | |
EndCombat | |
SecondMain | |
EndStep | |
Won Player |
data CardStrength Source #
Instances
Eq CardStrength Source # | |
Defined in Dovin.Types (==) :: CardStrength -> CardStrength -> Bool # (/=) :: CardStrength -> CardStrength -> Bool # | |
Show CardStrength Source # | |
Defined in Dovin.Types showsPrec :: Int -> CardStrength -> ShowS # show :: CardStrength -> String # showList :: [CardStrength] -> ShowS # | |
Semigroup CardStrength Source # | |
Defined in Dovin.Types (<>) :: CardStrength -> CardStrength -> CardStrength # sconcat :: NonEmpty CardStrength -> CardStrength # stimes :: Integral b => b -> CardStrength -> CardStrength # | |
Monoid CardStrength Source # | |
Defined in Dovin.Types mempty :: CardStrength # mappend :: CardStrength -> CardStrength -> CardStrength # mconcat :: [CardStrength] -> CardStrength # |
type CardAttributes = Set CardAttribute Source #
type CardLocation = (Player, Location) Source #
TargetPlayer Player | Target a player, use |
TargetCard CardName | Target a card, use |
data LayeredEffectDefinition Source #
LayeredEffectDefinition | |
|
type LayeredEffect = [LayeredEffectPart] Source #
Layer1A | Copiable effects |
Layer1B | Face down spells and permanents |
Layer2 | Control-changing effects |
Layer3 | Text changing effects |
Layer4 | Type changing effects |
Layer5 | Color changing effects |
Layer6 | Ability changing effects |
Layer7A | P/T from CDAs |
Layer7B | P/T from setting |
Layer7C | P/T adjustments (inc. counters) |
Layer7D | P/T Switching |
LayerOther | Other game rule affecting effects |
type EffectMonad a = Reader EffectMonadEnv a Source #
type EffectMonadEnv = (Board, Card) Source #
data CardEffect Source #
CardEffect | |
|
type ManaString = String Source #
type CardAttribute = String Source #
mkEffect :: CardMatcher -> (Card -> CardMatcher) -> (Card -> Identity Card) -> CardEffect Source #
mkLayeredEffectPart :: EffectMonad CardMatcher -> LayeredEffect -> EffectName -> LayeredEffectDefinition Source #
targetPlayer :: Player -> Target Source #
targetCard :: CardName -> Target Source #
cardEffects :: Lens' Card [CardEffect] Source #
effectAction :: Lens' CardEffect (Card -> GameMonad Card) Source #
effectFilter :: Lens' CardEffect (Card -> CardMatcher) Source #
_manaPoolForTyping :: Board -> ManaPool Source #
mkStrength :: (Int, Int) -> CardStrength Source #
emptyBoard :: Board Source #
module Dovin.Matchers
view :: MonadReader s m => Getting a s a -> m a #
View the value pointed to by a Getter
, Iso
or
Lens
or the result of folding over all the results of a
Fold
or Traversal
that points
at a monoidal value.
view
.
to
≡id
>>>
view (to f) a
f a
>>>
view _2 (1,"hello")
"hello"
>>>
view (to succ) 5
6
>>>
view (_2._1) ("hello",("world","!!!"))
"world"
As view
is commonly used to access the target of a Getter
or obtain a monoidal summary of the targets of a Fold
,
It may be useful to think of it as having one of these more restricted signatures:
view
::Getter
s a -> s -> aview
::Monoid
m =>Fold
s m -> s -> mview
::Iso'
s a -> s -> aview
::Lens'
s a -> s -> aview
::Monoid
m =>Traversal'
s m -> s -> m
In a more general setting, such as when working with a Monad
transformer stack you can use:
view
::MonadReader
s m =>Getter
s a -> m aview
:: (MonadReader
s m,Monoid
a) =>Fold
s a -> m aview
::MonadReader
s m =>Iso'
s a -> m aview
::MonadReader
s m =>Lens'
s a -> m aview
:: (MonadReader
s m,Monoid
a) =>Traversal'
s a -> m a
:: CardMatcher | A matcher that must apply to this card for this affect to
apply. |
-> (Card -> CardMatcher) | Given the current card, return a matcher that matches cards that this affect applies to. |
-> (Card -> Identity Card) | Apply an effect to the given card. |
-> GameMonad () | |
-> GameMonad () |
Add an effect to the created card.