LambdaHack-0.11.0.1: A game engine library for tactical squad ASCII roguelike dungeon crawlers

Safe Haskell | None
Language | Haskell2010

Game.LambdaHack.Server.LoopM

Contents

- Internal operations

Description

The main loop of the server, processing human and computer player moves turn by turn.

Synopsis

- loopSer :: (MonadServerAtomic m, MonadServerComm m) => ServerOptions -> (Bool -> FactionId -> ChanServer -> IO ()) -> m ()
- factionArena :: MonadStateRead m => Faction -> m (Maybe LevelId)
- arenasForLoop :: MonadStateRead m => m (EnumSet LevelId)
- handleFidUpd :: (MonadServerAtomic m, MonadServerComm m) => (FactionId -> m ()) -> FactionId -> Faction -> m ()
- loopUpd :: (MonadServerAtomic m, MonadServerComm m) => m () -> m ()
- endClip :: MonadServerAtomic m => (FactionId -> m ()) -> m ()
- manageCalmAndDomination :: MonadServerAtomic m => ActorId -> Actor -> m ()
- applyPeriodicLevel :: MonadServerAtomic m => m ()
- handleTrajectories :: MonadServerAtomic m => LevelId -> FactionId -> m ()
- hTrajectories :: MonadServerAtomic m => ActorId -> m ()
- advanceTrajectory :: MonadServerAtomic m => ActorId -> Actor -> m ()
- handleActors :: (MonadServerAtomic m, MonadServerComm m) => LevelId -> FactionId -> m Bool
- hActors :: (MonadServerAtomic m, MonadServerComm m) => [ActorId] -> m Bool
- handleUIunderAI :: (MonadServerAtomic m, MonadServerComm m) => FactionId -> ActorId -> m ()
- dieSer :: MonadServerAtomic m => ActorId -> Actor -> m ()
- restartGame :: MonadServerAtomic m => m () -> m () -> Maybe (GroupName ModeKind) -> m ()

# Documentation

loopSer Source #

Arguments

:: (MonadServerAtomic m, MonadServerComm m) |
=> ServerOptions | player-supplied server options
-> (Bool -> FactionId -> ChanServer -> IO ()) | function that initializes a client and runs its main loop
-> m () |

Start a game session, including the clients, and then loop, communicating with the clients.

The loop is started in server state that is empty, see `emptyStateServer`.

# Internal operations

factionArena :: MonadStateRead m => Faction -> m (Maybe LevelId) Source #

arenasForLoop :: MonadStateRead m => m (EnumSet LevelId) Source #

handleFidUpd :: (MonadServerAtomic m, MonadServerComm m) => (FactionId -> m ()) -> FactionId -> Faction -> m () Source #

loopUpd :: (MonadServerAtomic m, MonadServerComm m) => m () -> m () Source #

Handle a clip (the smallest fraction of a game turn for which a frame may potentially be generated). Run the leader and other actors moves. Eventually advance the time and repeat.

endClip :: MonadServerAtomic m => (FactionId -> m ()) -> m () Source #

Handle the end of every clip. Do whatever has to be done every fixed number of clips, e.g., monster generation. Advance time. Perform periodic saves, if applicable.

This is never run if UI requested save or exit or restart and it's correct, because we know nobody moved and no time was or needs to be advanced and arenas are not changed. After game was saved and exited, on game resume the first clip is performed with empty arenas, so arena time is not updated and nobody moves, nor anything happens, but arenas are here correctly updated.

manageCalmAndDomination :: MonadServerAtomic m => ActorId -> Actor -> m () Source #

Check if the given actor is dominated and update his calm.

applyPeriodicLevel :: MonadServerAtomic m => m () Source #

Trigger periodic items for all actors on the given level.

handleTrajectories :: MonadServerAtomic m => LevelId -> FactionId -> m () Source #

hTrajectories :: MonadServerAtomic m => ActorId -> m () Source #

advanceTrajectory :: MonadServerAtomic m => ActorId -> Actor -> m () Source #

Manage trajectory of a projectile or a pushed other actor.

Colliding with a wall or actor doesn't take time, because the projectile does not move (the move is blocked). Not advancing time forces dead projectiles to be destroyed ASAP. Otherwise, with some timings, it can stay on the game map dead, blocking path of human-controlled actors and alarming the hapless human.

handleActors :: (MonadServerAtomic m, MonadServerComm m) => LevelId -> FactionId -> m Bool Source #

hActors :: (MonadServerAtomic m, MonadServerComm m) => [ActorId] -> m Bool Source #

handleUIunderAI :: (MonadServerAtomic m, MonadServerComm m) => FactionId -> ActorId -> m () Source #

dieSer :: MonadServerAtomic m => ActorId -> Actor -> m () Source #

restartGame :: MonadServerAtomic m => m () -> m () -> Maybe (GroupName ModeKind) -> m () Source #