app

Safe Haskell None
Language Haskell2010

Move

Description

This module deals with game actions (nicknamed moves). It's a spinoff of Update, to reduce the length of the latter.

Synopsis

Documentation

data Actor #

Constructors

AI  
Player  

data Kernel a #

The subset of Game required by run* functions /! If a field is added, extend the two Contains Model.Game (Kernel _)instances. When running in production, a is Player. When in tests, () should be used, as there is no playing player.

Instances
With Game (Kernel ()) #  
Instance details

Defined in Move

Methods

with :: Game -> Kernel () -> Game #

With Game (Kernel Player) #  
Instance details

Defined in Move

Methods

with :: Game -> Kernel Player -> Game #

Contains Game (Kernel ()) #  
Instance details

Defined in Move

Methods

to :: Game -> Kernel () #

Contains Game (Kernel Player) #  
Instance details

Defined in Move

Methods

to :: Game -> Kernel Player #

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

Defined in Move

Methods

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

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

Defined in Move

Methods

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

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) #

mkSimKernel :: Difficulty -> Model -> T -> T Core -> Kernel () #

Creates a minimal kernel, suited for simulation

data Move #

Actions that are raised by GameView

Constructors

MouseEnter Box

Starting hovering a box

MouseLeave Box

Ending hovering a box

ExecuteCmd

Execute a command (dev mode only)

Sched Sched

A schedulable event

Selection Box  
UpdateCmd MisoString

Update the command to execute soon (dev mode only)

Instances
Eq Move #  
Instance details

Defined in Move

Methods

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

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

Show Move #  
Instance details

Defined in Move

Methods

showsPrec :: Int -> Move -> ShowS #

show :: Move -> String #

showList :: [Move] -> ShowS #

nextify :: Maybe Sched -> NextSched #

Transform a Maybe Sched into a NextSched

type NextSched = Maybe (Nat, Sched) #

Event to fire after the given delay (in seconds). Delay should not be '0'.

simRunAllMaybe :: MonadError Text m => a ~ Kernel () => NextSched -> a -> m a #

simRunAllMaybe m s executes s (if it is Just _) and then continues executing the generated NextSched, if any. Returns immediately when s is Nothing, if s is Just _ execute it, as well as the generated Sched values, until it runs out of Sched values.

Only suited for simulation/testing because it doesn't keep track of the playing player and doesn't trigger the AI automatically. It is up to the caller to do it.

prodRunOneModel :: MonadError Text m => a ~ Game => Sched -> a -> m (a, NextSched) #

Run one event, suited for production, because it keeps track of the playing player under the hood; thanks to the Kernel Spots.Player instance.

data Sched #

Actions that can be scheduled by the main loop.

Constructors

Play Event

Play some game event. It can be an event scheduled by the AI or an event from the player.

DrawCards DrawSource

Turn was updated previously by IncrTurn, time to draw cards from the stack. Then the handler of this event will take care of giving the player control back. This event is translated to a list of events, iteratively consuming the list.

IncrTurn

All actions have been resolved, time to update the turn widget and to schedule DrawCard. This does NOT translate to a PlayEvent.

EndTurnPressed

End Turn button pressed in turn widget. For player, schedule attacks then IncrTurn; for AI, compute its actions, schedule them, and then schedule attack and IncrTurn.

Sequence (NonEmpty Sched)  
Instances
Eq Sched #  
Instance details

Defined in Move

Methods

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

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

Show Sched #  
Instance details

Defined in Move

Methods

showsPrec :: Int -> Sched -> ShowS #

show :: Sched -> String #

showList :: [Sched] -> ShowS #

startTurn :: MonadError Text m => a ~ Kernel b => Actor -> Player -> a -> m (a, NextSched) #

The layer above startAITurn and startPlayerTurn. It intentionally requires the Actor AND Player so that the AI can be used even when there are 1 or 2 players.

mkPreEndTurnEvents :: Model -> T -> Player -> T Core -> [Event] #

Use to avoid exposing EventsKind