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

Safe HaskellNone

Game.LambdaHack.Action

Description

Game action monad and basic building blocks for player and monster actions.

Synopsis

Documentation

data Session Source

The constant session information, not saved to the game save file.

Constructors

Session 

Fields

sfs :: FrontendSession

frontend session information

scops :: COps

game content

skeyb :: Binding (Action ())

binding of keys to commands

type ActionFun r aSource

Arguments

 = Session

session setup data

-> (State -> Diary -> IO r)

shutdown continuation

-> Perception

cached perception

-> (State -> Diary -> a -> IO r)

continuation

-> IO r

failure/reset continuation

-> State

current state

-> Diary

current diary

-> IO r 

The type of the function inside any action. (Separated from the Action type to document each argument with haddock.)

newtype Action a Source

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

Constructors

Action 

Fields

runAction :: forall r. ActionFun r a
 

returnAction :: a -> Action aSource

Invokes the action continuation on the provided argument.

bindAction :: Action a -> (a -> Action b) -> Action bSource

Distributes the session and shutdown continuation, threads the state and diary.

handlerToIO :: Session -> State -> Diary -> Action () -> IO ()Source

Run an action, with a given session, state and diary, in the IO monad.

rndToAction :: Rnd a -> Action aSource

Invoke pseudo-random computation with the generator kept in the state.

session :: (Session -> Action a) -> Action aSource

Invoke a session command.

sessionIO :: (Session -> IO a) -> Action aSource

Invoke a session IO command.

displayGeneric :: ColorMode -> (Msg -> Msg) -> Action BoolSource

Display the current level with modified current msg.

displayAll :: Action BoolSource

Display the current level, with the current msg and color.

overlay :: String -> Action BoolSource

Display an overlay on top of the current screen.

currentDiary :: Action DiarySource

Get the current diary.

diaryReset :: Diary -> Action ()Source

Wipe out and set a new value for the current diary.

currentMsg :: Action MsgSource

Get the current msg.

msgReset :: Msg -> Action ()Source

Wipe out and set a new value for the current msg.

msgAdd :: Msg -> Action ()Source

Add to the current msg.

msgClear :: Action ()Source

Clear the current msg.

contentOps :: Action COpsSource

Get the content operations.

contentf :: (COps -> a) -> Action aSource

Get the content operations modified by a function (usually a selector).

end :: Action ()Source

End the game, i.e., invoke the shutdown continuation.

abort :: Action aSource

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

tryWith :: Action () -> Action () -> Action ()Source

Set the current exception handler. First argument is the handler, second is the computation the handler scopes over.

tryRepeatedlyWith :: Action () -> Action () -> Action ()Source

Take a handler and a computation. If the computation fails, the handler is invoked and then the computation is retried.

try :: Action () -> Action ()Source

Try the given computation and silently catch failure.

tryRepeatedly :: Action () -> Action ()Source

Try the given computation until it succeeds without failure.

debug :: String -> Action ()Source

Debugging.

abortWith :: Msg -> Action aSource

Print the given msg, then abort.

abortIfWith :: Bool -> Msg -> Action aSource

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

neverMind :: Bool -> Action aSource

Abort conditionally, with a fixed message.

nextCommand :: Session -> Action KeySource

Wait for a player keypress.

getYesNo :: Session -> Action BoolSource

A yes-no confirmation.

getOptionalConfirm :: (Bool -> Action a) -> (Key -> Action a) -> Session -> Action aSource

Waits for a SPACE or ESC. Passes along any other key, including RET, to an argument function.

getConfirm :: Session -> Action BoolSource

Ignore unexpected kestrokes until a SPACE or ESC is pressed.

msgMoreConfirm :: ColorMode -> Msg -> Action BoolSource

Print msg, await confirmation. Return value indicates if the player tried to abort/escape.

msgMore :: Msg -> Action ()Source

Print msg, await confirmation, ignore confirmation.

msgYesNo :: Msg -> Action BoolSource

Print a yes/no question and return the player's answer.

clearDisplay :: Action BoolSource

Clear message and overlay.

msgOverlaysConfirm :: Msg -> [String] -> Action BoolSource

Print a msg and several overlays, one per page, and await confirmation. The return value indicates if the player tried to abort/escape.

withPerception :: Action () -> Action ()Source

Update the cached perception for the given computation.

currentPerception :: Action PerceptionSource

Get the current perception.

updateAnyActor :: ActorId -> (Actor -> Actor) -> Action ()Source

Update actor stats. Works for actors on other levels, too.

updatePlayerBody :: (Actor -> Actor) -> Action ()Source

Update player-controlled actor stats.

advanceTime :: ActorId -> Action ()Source

Advance the move time for the given actor.

playerAdvanceTime :: Action ()Source

Add a turn to the player time counter.

displayHelp :: Action ()Source

Display command help.