Safe Haskell | None |
---|
Game action monad and basic building blocks for player and monster
actions. Uses liftIO
of the Action
monad, but does not export it.
Has no direct access to the Action monad implementation.
- data Action a
- getPerception :: Action Perception
- getCOps :: Action COps
- getBinding :: Action (Binding (ActionFrame ()))
- getConfigUI :: Action ConfigUI
- type ActionFrame a = Action (a, [Maybe SingleFrame])
- returnNoFrame :: a -> ActionFrame a
- returnFrame :: SingleFrame -> ActionFrame ()
- whenFrame :: Bool -> ActionFrame () -> ActionFrame ()
- inFrame :: Action () -> ActionFrame ()
- tryWithFrame :: Action a -> ActionFrame a -> ActionFrame a
- abort :: Action a
- abortWith :: Msg -> Action a
- abortIfWith :: Bool -> Msg -> Action a
- neverMind :: Bool -> Action a
- tryWith :: (Msg -> Action a) -> Action a -> Action a
- tryRepeatedlyWith :: (Msg -> Action ()) -> Action () -> Action ()
- tryIgnore :: Action () -> Action ()
- getDiary :: Action Diary
- msgAdd :: Msg -> Action ()
- recordHistory :: Action ()
- getKeyCommand :: Maybe Bool -> Action (Key, Modifier)
- getKeyFrameCommand :: SingleFrame -> Action (Key, Modifier)
- getOverConfirm :: [SingleFrame] -> Action Bool
- displayMore :: ColorMode -> Msg -> Action Bool
- displayYesNo :: Msg -> Action Bool
- displayOverAbort :: Msg -> [Overlay] -> Action ()
- displayOverlays :: Msg -> Msg -> [Overlay] -> ActionFrame ()
- displayChoiceUI :: Msg -> [Overlay] -> [(Key, Modifier)] -> Action (Key, Modifier)
- displayFramePush :: Maybe SingleFrame -> Action ()
- drawPrompt :: ColorMode -> Msg -> Action SingleFrame
- startClip :: Action () -> Action ()
- remember :: Action ()
- rememberList :: [Point] -> Action ()
- saveGameBkp :: Action ()
- dumpCfg :: FilePath -> Action ()
- endOrLoop :: Action () -> Action ()
- frontendName :: String
- startFrontend :: COps -> (ConfigUI -> Binding (ActionFrame ())) -> Action () -> IO ()
- debug :: Text -> Action ()
Actions and accessors
Actions of player-controlled characters and of any other actors.
getPerception :: Action PerceptionSource
Get the current perception.
getBinding :: Action (Binding (ActionFrame ()))Source
Get the key binding.
getConfigUI :: Action ConfigUISource
Get the config from the config file.
Actions returning frames
type ActionFrame a = Action (a, [Maybe SingleFrame])Source
Actions and screen frames, including delays, resulting from performing the actions.
returnNoFrame :: a -> ActionFrame aSource
Return the value with an empty set of screen frames.
returnFrame :: SingleFrame -> ActionFrame ()Source
Return the trivial value with a single frame to show.
whenFrame :: Bool -> ActionFrame () -> ActionFrame ()Source
As the when
monad operation, but on type ActionFrame ()
.
inFrame :: Action () -> ActionFrame ()Source
Inject action into actions with screen frames.
tryWithFrame :: Action a -> ActionFrame a -> ActionFrame aSource
Set the current exception handler. Apart of executing it, draw and pass along a frame with the abort message, if any.
Various ways to abort action
Reset the state and resume from the last backup point, i.e., invoke the failure continuation.
abortIfWith :: Bool -> Msg -> Action aSource
Abort and print the given msg if the condition is true.
Abort exception handlers
tryWith :: (Msg -> Action a) -> Action a -> Action aSource
Set the current exception handler. First argument is the handler, second is the computation the handler scopes over.
tryRepeatedlyWith :: (Msg -> Action ()) -> Action () -> Action ()Source
Take a handler and a computation. If the computation fails, the handler is invoked and then the computation is retried.
Diary and report
recordHistory :: Action ()Source
Store current report in the history and reset report.
Key input
getKeyFrameCommand :: SingleFrame -> Action (Key, Modifier)Source
Display frame and wait for a player command.
getOverConfirm :: [SingleFrame] -> Action BoolSource
A series of confirmations for all overlays.
Display each frame and confirm
displayMore :: ColorMode -> Msg -> Action BoolSource
Display a msg with a more
prompt. Return value indicates if the player
tried to cancel/escape.
displayYesNo :: Msg -> Action BoolSource
Print a yes/no question and return the player's answer. Use black and white colours to turn player's attention to the choice.
displayOverAbort :: Msg -> [Overlay] -> Action ()Source
Print a msg and several overlays, one per page.
All frames require confirmations. Raise abort
if the player presses ESC.
Assorted frame operations
displayOverlays :: Msg -> Msg -> [Overlay] -> ActionFrame ()Source
Print a msg and several overlays, one per page. The last frame does not expect a confirmation and so does not show the invitation to press some keys.
displayChoiceUI :: Msg -> [Overlay] -> [(Key, Modifier)] -> Action (Key, Modifier)Source
Print a prompt and an overlay and wait for a player keypress.
If many overlays, scroll screenfuls with SPACE. Do not wrap screenfuls
(in some menus ?
cycles views, so the user can restart from the top).
displayFramePush :: Maybe SingleFrame -> Action ()Source
Push a frame or a single frame's worth of delay to the frame queue.
drawPrompt :: ColorMode -> Msg -> Action SingleFrameSource
Draw the current level. The prompt is displayed, but not added to history. The prompt is appended to the current message and only the first screenful of the resulting overlay is displayed.
Clip init operations
startClip :: Action () -> Action ()Source
Initialize perception, etc., display level and run the action.
rememberList :: [Point] -> Action ()Source
Update heroes memory at the given list of locations.
Assorted primitives
saveGameBkp :: Action ()Source
Save the diary and a backup of the save game file, in case of crashes.
See saveGameBkp
.
The name of the frontend.
startFrontend :: COps -> (ConfigUI -> Binding (ActionFrame ())) -> Action () -> IO ()Source
Wire together content, the definitions of game commands, config and a high-level startup function to form the starting game session. Evaluate to check for errors, in particular verify content consistency. Then create the starting game config from the default config file and initialize the engine with the starting session.