app

Safe Haskell None
Language Haskell2010

Game

Synopsis

Documentation

allEnemySpots #

Arguments

:: Card

The attacker's position

-> [Card]

Spots that can be attacked

Spots that can be attacked from a spot. Spot as argument is in one player part while spots returned are in the other player part. The order in the result matters, the first element is the first spot attacked, then the second element is attacked if the first spot is empty or if the creature can attack multiple spots for some reasons.

allTargets :: [Target] #

All possible targets

data Animation #

An animation that makes sense at the Game level. If you consider extending this variant, consider whether it would be be better in Board.T 'UI

Constructors

Application Player Target (Card Core)

Player plays the given card played on a target. This is used for example to display Plague when played or when adding an item to a creature.

NoAnimation  
Fadeout

Game view should fadeout

Message [MessageText] Nat

Message to show centered. The Nat is the duration during which to show the message. Then it fades out during one second.

Instances
Eq Animation #  
Instance details

Defined in Game

Methods

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

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

Generic Animation #  
Instance details

Defined in Game

Associated Types

type Rep Animation :: Type -> Type #

Methods

from :: Animation -> Rep Animation x #

to :: Rep Animation x -> Animation #

With (Kernel a) (Model, T Core, T UI, Animation) #  
Instance details

Defined in Move

Methods

with :: Kernel a -> (Model, T Core, T UI, Animation) -> Kernel a #

Contains (Kernel a) (Model, T Core, T UI, Animation) #  
Instance details

Defined in Move

Methods

to :: Kernel a -> (Model, T Core, T UI, Animation) #

type Rep Animation #  
Instance details

Defined in Game

appliesTo :: T Core -> ID -> Player -> Target -> Bool #

board id pSpot target holds iff player at pSpot can play card id on target

applyFearNTerror #

Arguments

:: T Core

The input board

-> Player

The part causing fear

-> (T Core, T UI)  

applyPlagueM #

Arguments

:: MonadWriter (T UI) m  
=> T Core

The input board

-> Player

The part applying plague

-> Player

The part on which to apply plague

-> m (T Core)  

attackOrder :: Player -> [Card] #

The order in which cards attack

cardsToDraw :: T Core -> Player -> Bool -> [DrawSource] #

The cards to draw, the Boolean indicates whether to bound by the stack's length or not

drawCard #

Arguments

:: Model  
-> T Core  
-> Player

The player drawing cards

-> DrawSource

The reason for drawing a card

-> (Model, T Core, T UI)  

drawCards #

Arguments

:: Model  
-> T Core  
-> Player

The player drawing cards

-> [DrawSource]

The sources from which to draw the cards

-> (Model, T Core, T UI)  

enemySpots #

Arguments

:: Creature Core

The attacker

-> Card

Where the attack is

-> EnemySpots [Card]  

Spots that can be attacked by a creature. Spot as argument is in one player part while spots returned are in the other player part. The order in the result matters, the first element is the first spot attacked, then the second element is attacked if the first spot is empty or if the creature can attack multiple spots for some reasons.

idToHandIndex :: T Core -> Player -> ID -> Maybe HandIndex #

The index of the card with this ID, in the hand of the player at the given spot

data DrawSource #

The reason for drawing a card

Constructors

Native

Drawing one of the [nbDrawCards] cards allowed

CardDrawer Player Card

Drawing a card because of a creature with the [DrawCard] skill at the given position

Instances
Eq DrawSource #  
Instance details

Defined in Game

Ord DrawSource #  
Instance details

Defined in Game

Show DrawSource #  
Instance details

Defined in Game

eventToAnim :: MonadError Text m => Model -> T Core -> Event -> m Animation #

Translates an Event into an animation displayed in the middle of the Board.

data EnemySpots a #

Type to handle various custom skills when resolving attacks

Constructors

Ace

Creature has Ace

Imprecise

Creature has Imprecise, enemy spots don't make sense

Spots a

A creature without Imprecise

Instances
Functor EnemySpots #  
Instance details

Defined in Game

Methods

fmap :: (a -> b) -> EnemySpots a -> EnemySpots b #

(<$) :: a -> EnemySpots b -> EnemySpots a #

data Event #

If you add an event that triggers automatically, you should likely extend mkEvents

Constructors

ApplyAssassins Player

Apply assassins of the creatures at the given Player

ApplyBleed Player

Apply bleed on the creatures at the given Player

ApplyBrainless Player

Apply brainless of the creatures at the given Player

ApplyChurch Player

Apply church of the creatures at the given Player

ApplyCreateForest Player

Apply the create forest spell of the creatures at the given Player

ApplyFearNTerror Player

Apply fear caused by the creatures at the given Player

ApplyGrowth Player

Apply growth of the creatures at the given Player

ApplyKing Player

Apply king of the creatures at the given Player

Attack Player Card Bool Bool

A card attacks at the given spot. The first Boolean indicates whether the next spot (as defined by nextAttackSpot) should be enqueued after solving this attack. The second Boolean indicates whether GameIncrTurn (change player turn) should be performed after solving this stream of attacks.

FillTheFrontline Player

Ranged creatures with the Ranged skill, that: 1/ are in the back line and 2/ have no creature in from of them; move frontward

NoPlayEvent

A Nothing case, for convenience

PEvent Place

A Place event

Instances
Eq Event #  
Instance details

Defined in Game

Methods

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

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

Show Event #  
Instance details

Defined in Game

Methods

showsPrec :: Int -> Event -> ShowS #

show :: Event -> String #

showList :: [Event] -> ShowS #

Generic Event #  
Instance details

Defined in Game

Associated Types

type Rep Event :: Type -> Type #

Methods

from :: Event -> Rep Event x #

to :: Rep Event x -> Event #

type Rep Event #  
Instance details

Defined in Game

type Rep Event = D1 (MetaData "Event" "Game" "main" False) (((C1 (MetaCons "ApplyAssassins" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Player)) :+: (C1 (MetaCons "ApplyBleed" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Player)) :+: C1 (MetaCons "ApplyBrainless" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Player)))) :+: (C1 (MetaCons "ApplyChurch" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Player)) :+: (C1 (MetaCons "ApplyCreateForest" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Player)) :+: C1 (MetaCons "ApplyFearNTerror" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Player))))) :+: ((C1 (MetaCons "ApplyGrowth" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Player)) :+: (C1 (MetaCons "ApplyKing" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Player)) :+: C1 (MetaCons "Attack" PrefixI False) ((S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Player) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Card)) :*: (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Bool) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Bool))))) :+: (C1 (MetaCons "FillTheFrontline" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Player)) :+: (C1 (MetaCons "NoPlayEvent" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "PEvent" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Place))))))

keepEffectfull :: Model -> Playable [Event] -> [Event] #

'keepEffectfull board es' returns the elements of es that have an effect. Elements of es are played in sequence.

maybePlay :: Model -> Playable Event -> Maybe (Model, T Core, Maybe Event) #

Try to play an event. If the event cannot be played or a hard error occurs (MonadError Text _ in other functions of this API), simply return Nothing.

data MessageText #

Constructors

Text Text

Simple text to display

Image Filepath

Constructor to display an image. The image should be fine for passing to assetsPath

Instances
Eq MessageText #  
Instance details

Defined in Game

Generic MessageText #  
Instance details

Defined in Game

Associated Types

type Rep MessageText :: Type -> Type #

type Rep MessageText #  
Instance details

Defined in Game

mkPlayable :: T Core -> e -> T -> Playable e #

To allow callers to hide the implementation of Playable, to avoid fields names conflicts.

nextAttackSpot :: T Core -> Player -> Maybe Card -> Maybe Card #

nextAttackSpot b pSpot cSpot returns the spots to attack after cSpot. If cSpot is Nothing, the first spot in the order is considered; if cSpot is Just _, then spots after cSpot are considered.

If pre End Turn events are changed in Move, this function may have to be adapted to play the events beforehand. This should be discovered automatically, as this property is checked with a PBT.

data Place #

Placing events. These events are the ones that the AI generates (as opposed to the more general Event type).

Constructors

Place Player Target HandIndex

Player puts a card from his hand on its part of the board. First argument is the player, second argument is the target, third argument is the card being played.

Place' Player Target ID

AI puts a card from his hand. This constructor has better testing behavior than Place: it makes the generated events commute.

data Playable e #

The input type to most play* functions

Constructors

Playable  

Fields

Instances
With (Playable a) a #  
Instance details

Defined in Game

Methods

with :: Playable a -> a -> Playable a #

Contains (Playable a) a #  
Instance details

Defined in Game

Methods

to :: Playable a -> a #

With (Playable a) (T Core) #  
Instance details

Defined in Game

Methods

with :: Playable a -> T Core -> Playable a #

Contains (Playable a) (T Core) #  
Instance details

Defined in Game

Methods

to :: Playable a -> T Core #

(With (Playable a) (T Core), With (Playable a) a) => With (Playable a) (T Core, a) #  
Instance details

Defined in Game

Methods

with :: Playable a -> (T Core, a) -> Playable a #

(Contains (Playable a) (T Core), Contains (Playable a) a) => Contains (Playable a) (T Core, a) #  
Instance details

Defined in Game

Methods

to :: Playable a -> (T Core, a) #

data Result e #

The result of playing game events. If you add a field, extend the Eq instance below. TODO @smelc find a better name.

Constructors

Result  

Fields

Instances
Eq a => Eq (Result a) #  
Instance details

Defined in Game

Methods

(==) :: Result a -> Result a -> Bool #

(/=) :: Result a -> Result a -> Bool #

Show e => Show (Result e) #  
Instance details

Defined in Game

Methods

showsPrec :: Int -> Result e -> ShowS #

show :: Result e -> String #

showList :: [Result e] -> ShowS #

play :: Model -> Playable Event -> Either Text (Result (Maybe Event)) #

Play a single Event on the given Board. Monad version is playM below. If the event cannot be played, the input board is returned as is. Use tryPlayM for the version distinguishing the error and success cases.

playE :: MonadError Text m => Model -> Playable Event -> m (Model, T Core, T UI, Maybe Event) #

A variant of play and playE that is only in the error monad. This function returns the input board if the event is unapplicable. That is why this function doesn't have Impossible in its return type.

playAll :: Model -> Playable [Event] -> Either Text (Result ()) #

Play a list of events, playing newly produced events as they are being produced. That is why, contrary to play, this function doesn't return events: it consumes them all eagerly. See playAllM for the monad version

playAllE :: MonadError Text m => Model -> Playable [Event] -> m (Model, T Core, T UI) #

Like playAll, but in the error monad. This function skips unapplicable events. That is why its return type doesn't have Impossible.

toSpot :: Place -> Player #

The Player in a Place, i.e. the player playing an event

data StatChange #

A change in stats of a creature. Using Nat for now because it suffices for the use cases. But really it could be a Int, it just makes apply harder.

Constructors

StatChange  

Fields

Instances
Eq StatChange #  
Instance details

Defined in Game

Show StatChange #  
Instance details

Defined in Game

Generic StatChange #  
Instance details

Defined in Game

Associated Types

type Rep StatChange :: Type -> Type #

Semigroup StatChange #  
Instance details

Defined in Game

Monoid StatChange #  
Instance details

Defined in Game

type Rep StatChange #  
Instance details

Defined in Game

data Target #

On what a card can be applied

Constructors

PlayerTarget Player

Neutral card applies to all in place cards of a player

CardTarget Player Card

Creature card placed at given spot or Neutral card applies to a given in place card of a player

Instances
Eq Target #  
Instance details

Defined in Game

Methods

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

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

Ord Target #  
Instance details

Defined in Game

Methods

compare :: Target -> Target -> Ordering #

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

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

(>) :: Target -> Target -> Bool #

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

max :: Target -> Target -> Target #

min :: Target -> Target -> Target #

Show Target #  
Instance details

Defined in Game

Methods

showsPrec :: Int -> Target -> ShowS #

show :: Target -> String #

showList :: [Target] -> ShowS #

Generic Target #  
Instance details

Defined in Game

Associated Types

type Rep Target :: Type -> Type #

Methods

from :: Target -> Rep Target x #

to :: Rep Target x -> Target #

type Rep Target #  
Instance details

Defined in Game

whichPlayerTarget :: ID -> WhichPlayerTarget #

To which part to apply a card. Beneficial card apply to Playing while cards giving maluses, curses, etc. apply to Opponent.

data WhichPlayerTarget #

Whether a card makes sense on the playing player or the opponent. We could even try both, but we don't do that for now

Constructors

Playing  
Opponent