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

Game.LambdaHack.Atomic.HandleAtomicWrite

Description

Semantics of atomic commands shared by client and server.

See https://github.com/LambdaHack/LambdaHack/wiki/Client-server-architecture.

Synopsis

Documentation

handleUpdAtomic :: MonadStateWrite m => UpdAtomic -> m () Source #

The game-state semantics of atomic game commands. There is no corresponding definition for special effects (SfxAtomic), because they don't modify State.

For each of the commands, we are guaranteed that the client, the command is addressed to, perceives all the positions the command affects (as computed by posUpdAtomic). In the code for each semantic function we additonally verify the client is aware of any relevant items and/or actors and we throw the AtomicFail exception if it's not. The server keeps copies of all clients' states and, before sending a command to a client, applies it to the client's state copy. If AtomicFail is signalled, the command is ignored for that client. This enables simpler server code that addresses commands to all clients that can see it, even though not all are able to process it.

Internal operations