Safe Haskell | None |
---|
Game action monad and basic building blocks for player and monster actions.
- data Session = Session {}
- type ActionFun r a = Session -> (State -> Diary -> IO r) -> Perception -> (State -> Diary -> a -> IO r) -> IO r -> State -> Diary -> IO r
- newtype Action a = Action {}
- returnAction :: a -> Action a
- bindAction :: Action a -> (a -> Action b) -> Action b
- handlerToIO :: Session -> State -> Diary -> Action () -> IO ()
- rndToAction :: Rnd a -> Action a
- session :: (Session -> Action a) -> Action a
- sessionIO :: (Session -> IO a) -> Action a
- displayGeneric :: ColorMode -> (Msg -> Msg) -> Action Bool
- displayAll :: Action Bool
- overlay :: String -> Action Bool
- currentDiary :: Action Diary
- diaryReset :: Diary -> Action ()
- currentMsg :: Action Msg
- msgReset :: Msg -> Action ()
- msgAdd :: Msg -> Action ()
- msgClear :: Action ()
- contentOps :: Action COps
- contentf :: (COps -> a) -> Action a
- end :: Action ()
- abort :: Action a
- tryWith :: Action () -> Action () -> Action ()
- tryRepeatedlyWith :: Action () -> Action () -> Action ()
- try :: Action () -> Action ()
- tryRepeatedly :: Action () -> Action ()
- debug :: String -> Action ()
- abortWith :: Msg -> Action a
- abortIfWith :: Bool -> Msg -> Action a
- neverMind :: Bool -> Action a
- nextCommand :: Session -> Action Key
- getYesNo :: Session -> Action Bool
- getOptionalConfirm :: (Bool -> Action a) -> (Key -> Action a) -> Session -> Action a
- getConfirm :: Session -> Action Bool
- msgMoreConfirm :: ColorMode -> Msg -> Action Bool
- msgMore :: Msg -> Action ()
- msgYesNo :: Msg -> Action Bool
- clearDisplay :: Action Bool
- msgOverlaysConfirm :: Msg -> [String] -> Action Bool
- withPerception :: Action () -> Action ()
- currentPerception :: Action Perception
- updateAnyActor :: ActorId -> (Actor -> Actor) -> Action ()
- updatePlayerBody :: (Actor -> Actor) -> Action ()
- advanceTime :: ActorId -> Action ()
- playerAdvanceTime :: Action ()
- displayHelp :: Action ()
Documentation
The constant session information, not saved to the game save file.
= 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.)
Actions of player-controlled characters and of any other actors.
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.
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.
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.
contentOps :: Action COpsSource
Get the content operations.
contentf :: (COps -> a) -> Action aSource
Get the content operations modified by a function (usually a selector).
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.
tryRepeatedly :: Action () -> Action ()Source
Try the given computation until it succeeds without failure.
abortIfWith :: Bool -> Msg -> Action aSource
Abort, and print the given msg if the condition is true.
nextCommand :: Session -> Action KeySource
Wait for a player keypress.
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.
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.