Safe Haskell | None |
---|
Game action monads and basic building blocks for human and computer
player actions. Has no access to the the main action type.
Does not export the liftIO
operation nor a few other implementation
details.
- class MonadActionRO m => MonadClient m where
- getClient :: m StateClient
- getsClient :: (StateClient -> a) -> m a
- modifyClient :: (StateClient -> StateClient) -> m ()
- putClient :: StateClient -> m ()
- saveClient :: m ()
- class MonadClient m => MonadClientUI m
- class MonadClient m => MonadClientReadServer c m | m -> c where
- readServer :: m c
- class MonadClient m => MonadClientWriteServer d m | m -> d where
- writeServer :: d -> m ()
- data SessionUI = SessionUI {
- sfconn :: !ConnFrontend
- sbinding :: !Binding
- data ConnFrontend = ConnFrontend {
- readConnFrontend :: MonadClientUI m => m KM
- writeConnFrontend :: MonadClientUI m => FrontReq -> m ()
- connFrontend :: FactionId -> ChanFrontend -> ConnFrontend
- mkConfigUI :: Ops RuleKind -> IO ConfigUI
- askBinding :: MonadClientUI m => m Binding
- getPerFid :: MonadClient m => LevelId -> m Perception
- msgAdd :: MonadClientUI m => Msg -> m ()
- msgReset :: MonadClient m => Msg -> m ()
- recordHistory :: MonadClient m => m ()
- getKeyOverlayCommand :: MonadClientUI m => Bool -> Overlay -> m KM
- getInitConfirms :: MonadClientUI m => ColorMode -> [KM] -> Slideshow -> m Bool
- stopPlayBack :: MonadClientUI m => m ()
- stopRunning :: MonadClientUI m => m ()
- displayFrames :: MonadClientUI m => Frames -> m ()
- displayMore :: MonadClientUI m => ColorMode -> Msg -> m Bool
- displayYesNo :: MonadClientUI m => ColorMode -> Msg -> m Bool
- displayChoiceUI :: MonadClientUI m => Msg -> Overlay -> [KM] -> m (Either Slideshow KM)
- promptToSlideshow :: MonadClientUI m => Msg -> m Slideshow
- overlayToSlideshow :: MonadClientUI m => Msg -> Overlay -> m Slideshow
- overlayToBlankSlideshow :: MonadClientUI m => Msg -> Overlay -> m Slideshow
- drawOverlay :: MonadClientUI m => Bool -> ColorMode -> Overlay -> m SingleFrame
- animate :: MonadClientUI m => LevelId -> Animation -> m Frames
- restoreGame :: MonadClient m => m (Maybe (State, StateClient))
- removeServerSave :: MonadClient m => m ()
- displayPush :: MonadClientUI m => m ()
- scoreToSlideshow :: MonadClientUI m => Int -> Status -> m Slideshow
- rndToAction :: MonadClient m => Rnd a -> m a
- getArenaUI :: MonadClientUI m => m LevelId
- getLeaderUI :: MonadClientUI m => m ActorId
- targetDescLeader :: MonadClientUI m => ActorId -> m Text
- viewedLevel :: MonadClientUI m => m LevelId
- aidTgtToPos :: MonadClient m => ActorId -> LevelId -> Maybe Target -> m (Maybe Point)
- aidTgtAims :: MonadClient m => ActorId -> LevelId -> Maybe Target -> m (Maybe Text)
- leaderTgtToPos :: MonadClientUI m => m (Maybe Point)
- leaderTgtAims :: MonadClientUI m => m (Maybe Text)
- cursorToPos :: MonadClientUI m => m (Maybe Point)
- partAidLeader :: MonadClient m => ActorId -> m Part
- partActorLeader :: MonadClient m => ActorId -> Actor -> m Part
- unexploredDepth :: MonadClient m => m (Int -> LevelId -> Bool)
- getCacheBfsAndPath :: forall m. MonadClient m => ActorId -> Point -> m (Array BfsDistance, Maybe [Point])
- getCacheBfs :: MonadClient m => ActorId -> m (Array BfsDistance)
- accessCacheBfs :: MonadClient m => ActorId -> Point -> m (Maybe Int)
- actorAimsPos :: MonadClient m => ActorId -> Point -> m Bool
- closestUnknown :: MonadClient m => ActorId -> m (Maybe Point)
- closestSmell :: MonadClient m => ActorId -> m [(Int, (Point, SmellTime))]
- furthestKnown :: MonadClient m => ActorId -> m (Maybe Point)
- closestTriggers :: MonadClient m => Maybe Bool -> Bool -> ActorId -> m [Point]
- closestItems :: MonadClient m => ActorId -> m [(Int, (Point, ItemBag))]
- closestFoes :: MonadClient m => ActorId -> m [(Int, (ActorId, Actor))]
- actorAbilities :: MonadClient m => ActorId -> Maybe ActorId -> m [Ability]
- debugPrint :: MonadClient m => Text -> m ()
Action monads
class MonadActionRO m => MonadClient m whereSource
getClient :: m StateClientSource
getsClient :: (StateClient -> a) -> m aSource
modifyClient :: (StateClient -> StateClient) -> m ()Source
putClient :: StateClient -> m ()Source
saveClient :: m ()Source
MonadClient (ActionCli c d) |
class MonadClient m => MonadClientUI m Source
MonadClientUI (ActionCli c d) |
class MonadClient m => MonadClientReadServer c m | m -> c whereSource
readServer :: m cSource
MonadClientReadServer c (ActionCli c d) |
class MonadClient m => MonadClientWriteServer d m | m -> d whereSource
writeServer :: d -> m ()Source
MonadClientWriteServer d (ActionCli c d) |
The information that is constant across a client playing session,
including many consecutive games in a single session,
but is completely disregarded and reset when a new playing session starts.
Auxiliary AI and computer player clients have no sfs
nor sbinding
.
SessionUI | |
|
data ConnFrontend Source
Connection method between a client and a frontend.
ConnFrontend | |
|
Executing actions
Accessors to the game session Reader and the Perception Reader(-like)
askBinding :: MonadClientUI m => m BindingSource
Get the key binding.
getPerFid :: MonadClient m => LevelId -> m PerceptionSource
Get the current perception of a client.
History and report
msgAdd :: MonadClientUI m => Msg -> m ()Source
Add a message to the current report.
msgReset :: MonadClient m => Msg -> m ()Source
Wipe out and set a new value for the current report.
recordHistory :: MonadClient m => m ()Source
Store current report in the history and reset report.
Key input
getKeyOverlayCommand :: MonadClientUI m => Bool -> Overlay -> m KMSource
Display an overlay and wait for a human player command.
getInitConfirms :: MonadClientUI m => ColorMode -> [KM] -> Slideshow -> m BoolSource
Display a slideshow, awaiting confirmation for each slide except the last.
stopPlayBack :: MonadClientUI m => m ()Source
stopRunning :: MonadClientUI m => m ()Source
Display and key input
displayFrames :: MonadClientUI m => Frames -> m ()Source
Push frames or delays to the frame queue.
displayMore :: MonadClientUI m => ColorMode -> Msg -> m BoolSource
Display a msg with a more
prompt. Return value indicates if the player
tried to cancel/escape.
displayYesNo :: MonadClientUI m => ColorMode -> Msg -> m 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.
displayChoiceUI :: MonadClientUI m => Msg -> Overlay -> [KM] -> m (Either Slideshow KM)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).
Generate slideshows
promptToSlideshow :: MonadClientUI m => Msg -> m SlideshowSource
The prompt is shown after the current message, but not added to history. This is useful, e.g., in targeting mode, not to spam history.
overlayToSlideshow :: MonadClientUI m => Msg -> Overlay -> m SlideshowSource
The prompt is shown after the current message at the top of each slide. Together they may take more than one line. The prompt is not added to history. The portions of overlay that fit on the the rest of the screen are displayed below. As many slides as needed are shown.
overlayToBlankSlideshow :: MonadClientUI m => Msg -> Overlay -> m SlideshowSource
Draw frames
drawOverlay :: MonadClientUI m => Bool -> ColorMode -> Overlay -> m SingleFrameSource
Draw the current level with the overlay on top.
animate :: MonadClientUI m => LevelId -> Animation -> m FramesSource
Render animations on top of the current screen frame.
Assorted primitives
restoreGame :: MonadClient m => m (Maybe (State, StateClient))Source
removeServerSave :: MonadClient m => m ()Source
Assuming the client runs on the same machine and for the same user as the server, move the server savegame out of the way.
displayPush :: MonadClientUI m => m ()Source
Push the frame depicting the current level to the frame queue. Only one screenful of the report is shown, the rest is ignored.
scoreToSlideshow :: MonadClientUI m => Int -> Status -> m SlideshowSource
rndToAction :: MonadClient m => Rnd a -> m aSource
Invoke pseudo-random computation with the generator kept in the state.
getArenaUI :: MonadClientUI m => m LevelIdSource
getLeaderUI :: MonadClientUI m => m ActorIdSource
targetDescLeader :: MonadClientUI m => ActorId -> m TextSource
viewedLevel :: MonadClientUI m => m LevelIdSource
aidTgtToPos :: MonadClient m => ActorId -> LevelId -> Maybe Target -> m (Maybe Point)Source
Calculate the position of an actor's target.
aidTgtAims :: MonadClient m => ActorId -> LevelId -> Maybe Target -> m (Maybe Text)Source
Check whether one is permitted to aim at a target
(this is only checked for actors; positions let player
shoot at obstacles, e.g., to destroy them).
This assumes aidTgtToPos
does not return Nothing
.
Note: Perception is not enough for the check, because the target actor can be obscured by a glass wall or be out of sight range, but in weapon range.
leaderTgtToPos :: MonadClientUI m => m (Maybe Point)Source
leaderTgtAims :: MonadClientUI m => m (Maybe Text)Source
cursorToPos :: MonadClientUI m => m (Maybe Point)Source
partAidLeader :: MonadClient m => ActorId -> m PartSource
The part of speech describing the actor (designated by actor id and present in the dungeon) or a special name if a leader of the observer's faction.
partActorLeader :: MonadClient m => ActorId -> Actor -> m PartSource
The part of speech describing the actor or a special name if a leader of the observer's faction. The actor may not be present in the dungeon.
unexploredDepth :: MonadClient m => m (Int -> LevelId -> Bool)Source
getCacheBfsAndPath :: forall m. MonadClient m => ActorId -> Point -> m (Array BfsDistance, Maybe [Point])Source
Get cached BFS data and path or, if not stored, generate, store and return. Due to laziness, they are not calculated until needed.
getCacheBfs :: MonadClient m => ActorId -> m (Array BfsDistance)Source
accessCacheBfs :: MonadClient m => ActorId -> Point -> m (Maybe Int)Source
actorAimsPos :: MonadClient m => ActorId -> Point -> m BoolSource
closestUnknown :: MonadClient m => ActorId -> m (Maybe Point)Source
Closest reachable unknown tile position, if any.
closestSmell :: MonadClient m => ActorId -> m [(Int, (Point, SmellTime))]Source
Finds smells closest to the actor, except under the actor.
furthestKnown :: MonadClient m => ActorId -> m (Maybe Point)Source
Furthest (wrt paths) known position, except under the actor.
closestTriggers :: MonadClient m => Maybe Bool -> Bool -> ActorId -> m [Point]Source
Closest (wrt paths) triggerable open tiles. The second argument can ever be true only if there's no escape from the dungeon.
closestItems :: MonadClient m => ActorId -> m [(Int, (Point, ItemBag))]Source
Closest (wrt paths) items.
closestFoes :: MonadClient m => ActorId -> m [(Int, (ActorId, Actor))]Source
Closest (wrt paths) enemy actors.
actorAbilities :: MonadClient m => ActorId -> Maybe ActorId -> m [Ability]Source
debugPrint :: MonadClient m => Text -> m ()Source