LambdaHack- A game engine library for tactical squad ASCII roguelike dungeon crawlers
Safe HaskellNone



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



loopSer Source #


:: (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

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

loopUpd :: forall m. (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 :: forall m. 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.

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.

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