LambdaHack-0.2.6.5: A roguelike game engine in early and active development

Safe HaskellNone

Game.LambdaHack.Action

Contents

Description

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.

Synopsis

Actions and accessors

data Action a Source

Actions of player-controlled characters and of any other actors.

getPerception :: Action PerceptionSource

Get the current perception.

getCOps :: Action COpsSource

Get the content operations.

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

abort :: Action aSource

Reset the state and resume from the last backup point, i.e., invoke the failure continuation.

abortWith :: Msg -> Action aSource

Abort with the given message.

abortIfWith :: Bool -> Msg -> Action aSource

Abort and print the given msg if the condition is true.

neverMind :: Bool -> Action aSource

Abort and conditionally print the fixed message.

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.

tryIgnore :: Action () -> Action ()Source

Try the given computation and silently catch failure.

Diary and report

getDiary :: Action DiarySource

Get the current diary.

msgAdd :: Msg -> Action ()Source

Add a message to the current report.

recordHistory :: Action ()Source

Store current report in the history and reset report.

Key input

getKeyCommand :: Maybe Bool -> Action (Key, Modifier)Source

Wait for a player command.

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.

remember :: Action ()Source

Update heroes memory.

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.

dumpCfg :: FilePath -> Action ()Source

Dumps the current game rules configuration to a file.

endOrLoop :: Action () -> Action ()Source

Continue or restart or exit the game.

frontendName :: StringSource

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.

debug :: Text -> Action ()Source

Debugging.