Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module deals with game actions (nicknamed moves). It's a spinoff of
Update
, to reduce the length of the latter.
Synopsis
- data Actor
- data Kernel a
- mkSimKernel :: Difficulty -> Model -> T -> T Core -> Kernel ()
-
data Move
- = MouseEnter Box
- | MouseLeave Box
- | ExecuteCmd
- | Sched Sched
- | Selection Box
- | UpdateCmd MisoString
- nextify :: Maybe Sched -> NextSched
- type NextSched = Maybe (Nat, Sched)
- simRunAllMaybe :: MonadError Text m => a ~ Kernel () => NextSched -> a -> m a
- prodRunOneModel :: MonadError Text m => a ~ Game => Sched -> a -> m (a, NextSched)
-
data Sched
- = Play Event
- | DrawCards DrawSource
- | IncrTurn
- | EndTurnPressed
- | Sequence (NonEmpty Sched)
- startTurn :: MonadError Text m => a ~ Kernel b => Actor -> Player -> a -> m (a, NextSched)
- mkPreEndTurnEvents :: Model -> T -> Player -> T Core -> [Event]
Documentation
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 ()) # | |
With Game (Kernel Player) # | |
Contains Game (Kernel ()) # | |
Contains Game (Kernel Player) # | |
With (Kernel a) (Model, T Core, T UI) # | |
Contains (Kernel a) (Model, T Core, T UI) # | |
With (Kernel a) (Model, T Core, T UI, Animation) # | |
Contains (Kernel a) (Model, T Core, T UI, Animation) # | |
mkSimKernel :: Difficulty -> Model -> T -> T Core -> Kernel () #
Creates a minimal kernel, suited for simulation
Actions that are raised by GameView
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) |
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.
Actions that can be scheduled by the main loop.
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 | All actions have been resolved, time to update the turn widget
and to schedule |
EndTurnPressed | End Turn button pressed in turn widget. For player, schedule
attacks then |
Sequence (NonEmpty Sched) |