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

Safe Haskell | None
Language | Haskell2010

Game.LambdaHack.Atomic.HandleAtomicWrite

Contents

- Internal operations

Description

Semantics of atomic commands shared by client and server.

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

Synopsis

- handleUpdAtomic :: MonadStateWrite m => UpdAtomic -> m ()
- updRegisterItems :: MonadStateWrite m => [(ItemId, Item)] -> m ()
- updCreateActor :: MonadStateWrite m => ActorId -> Actor -> [(ItemId, Item)] -> m ()
- updDestroyActor :: MonadStateWrite m => ActorId -> Actor -> [(ItemId, Item)] -> m ()
- updCreateItem :: MonadStateWrite m => ItemId -> Item -> ItemQuant -> Container -> m ()
- updDestroyItem :: MonadStateWrite m => ItemId -> Item -> ItemQuant -> Container -> m ()
- updSpotItemBag :: MonadStateWrite m => Container -> ItemBag -> m ()
- updLoseItemBag :: MonadStateWrite m => Container -> ItemBag -> m ()
- updMoveActor :: MonadStateWrite m => ActorId -> Point -> Point -> m ()
- updWaitActor :: MonadStateWrite m => ActorId -> Watchfulness -> Watchfulness -> m ()
- updDisplaceActor :: MonadStateWrite m => ActorId -> ActorId -> m ()
- updMoveItem :: MonadStateWrite m => ItemId -> Int -> ActorId -> CStore -> CStore -> m ()
- updRefillHP :: MonadStateWrite m => ActorId -> Int64 -> m ()
- updRefillCalm :: MonadStateWrite m => ActorId -> Int64 -> m ()
- updTrajectory :: MonadStateWrite m => ActorId -> Maybe ([Vector], Speed) -> Maybe ([Vector], Speed) -> m ()
- updQuitFaction :: MonadStateWrite m => FactionId -> Maybe Status -> Maybe Status -> m ()
- updSpotStashFaction :: MonadStateWrite m => FactionId -> LevelId -> Point -> m ()
- updLoseStashFaction :: MonadStateWrite m => FactionId -> LevelId -> Point -> m ()
- updLeadFaction :: MonadStateWrite m => FactionId -> Maybe ActorId -> Maybe ActorId -> m ()
- updDiplFaction :: MonadStateWrite m => FactionId -> FactionId -> Diplomacy -> Diplomacy -> m ()
- updDoctrineFaction :: MonadStateWrite m => FactionId -> Doctrine -> Doctrine -> m ()
- updAutoFaction :: MonadStateWrite m => FactionId -> Bool -> m ()
- updRecordKill :: MonadStateWrite m => ActorId -> ContentId ItemKind -> Int -> m ()
- updAlterTile :: MonadStateWrite m => LevelId -> Point -> ContentId TileKind -> ContentId TileKind -> m ()
- updAlterExplorable :: MonadStateWrite m => LevelId -> Int -> m ()
- updSearchTile :: MonadStateWrite m => ActorId -> Point -> ContentId TileKind -> m ()
- updSpotTile :: MonadStateWrite m => LevelId -> [(Point, ContentId TileKind)] -> m ()
- updLoseTile :: MonadStateWrite m => LevelId -> [(Point, ContentId TileKind)] -> m ()
- updAlterSmell :: MonadStateWrite m => LevelId -> Point -> Time -> Time -> m ()
- updSpotSmell :: MonadStateWrite m => LevelId -> [(Point, Time)] -> m ()
- updLoseSmell :: MonadStateWrite m => LevelId -> [(Point, Time)] -> m ()
- updTimeItem :: MonadStateWrite m => ItemId -> Container -> ItemTimers -> ItemTimers -> m ()
- updAgeGame :: MonadStateWrite m => EnumSet LevelId -> m ()
- updUnAgeGame :: MonadStateWrite m => EnumSet LevelId -> m ()
- ageLevel :: MonadStateWrite m => Delta Time -> LevelId -> m ()
- updDiscover :: MonadStateWrite m => Container -> ItemId -> ContentId ItemKind -> AspectRecord -> m ()
- updCover :: Container -> ItemId -> ContentId ItemKind -> AspectRecord -> m ()
- updDiscoverKind :: MonadStateWrite m => Container -> ItemKindIx -> ContentId ItemKind -> m ()
- discoverKind :: MonadStateWrite m => ItemKindIx -> ContentId ItemKind -> m ()
- updCoverKind :: Container -> ItemKindIx -> ContentId ItemKind -> m ()
- updDiscoverAspect :: MonadStateWrite m => Container -> ItemId -> AspectRecord -> m ()
- discoverAspect :: MonadStateWrite m => ItemId -> AspectRecord -> m ()
- updCoverAspect :: Container -> ItemId -> AspectRecord -> m ()
- updDiscoverServer :: MonadStateWrite m => ItemId -> AspectRecord -> m ()
- updCoverServer :: MonadStateWrite m => ItemId -> AspectRecord -> m ()
- updRestart :: MonadStateWrite m => State -> m ()
- updRestartServer :: MonadStateWrite m => State -> m ()
- updResumeServer :: MonadStateWrite m => State -> m ()

# 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

updRegisterItems :: MonadStateWrite m => [(ItemId, Item)] -> m () Source #

updCreateActor :: MonadStateWrite m => ActorId -> Actor -> [(ItemId, Item)] -> m () Source #

updDestroyActor :: MonadStateWrite m => ActorId -> Actor -> [(ItemId, Item)] -> m () Source #

updCreateItem :: MonadStateWrite m => ItemId -> Item -> ItemQuant -> Container -> m () Source #

updDestroyItem :: MonadStateWrite m => ItemId -> Item -> ItemQuant -> Container -> m () Source #

updSpotItemBag :: MonadStateWrite m => Container -> ItemBag -> m () Source #

updLoseItemBag :: MonadStateWrite m => Container -> ItemBag -> m () Source #

updMoveActor :: MonadStateWrite m => ActorId -> Point -> Point -> m () Source #

updWaitActor :: MonadStateWrite m => ActorId -> Watchfulness -> Watchfulness -> m () Source #

updDisplaceActor :: MonadStateWrite m => ActorId -> ActorId -> m () Source #

updMoveItem :: MonadStateWrite m => ItemId -> Int -> ActorId -> CStore -> CStore -> m () Source #

updRefillHP :: MonadStateWrite m => ActorId -> Int64 -> m () Source #

updRefillCalm :: MonadStateWrite m => ActorId -> Int64 -> m () Source #

updTrajectory :: MonadStateWrite m => ActorId -> Maybe ([Vector], Speed) -> Maybe ([Vector], Speed) -> m () Source #

updQuitFaction :: MonadStateWrite m => FactionId -> Maybe Status -> Maybe Status -> m () Source #

updSpotStashFaction :: MonadStateWrite m => FactionId -> LevelId -> Point -> m () Source #

updLoseStashFaction :: MonadStateWrite m => FactionId -> LevelId -> Point -> m () Source #

updLeadFaction :: MonadStateWrite m => FactionId -> Maybe ActorId -> Maybe ActorId -> m () Source #

updDiplFaction :: MonadStateWrite m => FactionId -> FactionId -> Diplomacy -> Diplomacy -> m () Source #

updDoctrineFaction :: MonadStateWrite m => FactionId -> Doctrine -> Doctrine -> m () Source #

updAutoFaction :: MonadStateWrite m => FactionId -> Bool -> m () Source #

updRecordKill :: MonadStateWrite m => ActorId -> ContentId ItemKind -> Int -> m () Source #

updAlterTile :: MonadStateWrite m => LevelId -> Point -> ContentId TileKind -> ContentId TileKind -> m () Source #

updAlterExplorable :: MonadStateWrite m => LevelId -> Int -> m () Source #

updSearchTile :: MonadStateWrite m => ActorId -> Point -> ContentId TileKind -> m () Source #

updSpotTile :: MonadStateWrite m => LevelId -> [(Point, ContentId TileKind)] -> m () Source #

updLoseTile :: MonadStateWrite m => LevelId -> [(Point, ContentId TileKind)] -> m () Source #

updAlterSmell :: MonadStateWrite m => LevelId -> Point -> Time -> Time -> m () Source #

updSpotSmell :: MonadStateWrite m => LevelId -> [(Point, Time)] -> m () Source #

updLoseSmell :: MonadStateWrite m => LevelId -> [(Point, Time)] -> m () Source #

updTimeItem :: MonadStateWrite m => ItemId -> Container -> ItemTimers -> ItemTimers -> m () Source #

updAgeGame :: MonadStateWrite m => EnumSet LevelId -> m () Source #

updUnAgeGame :: MonadStateWrite m => EnumSet LevelId -> m () Source #

ageLevel :: MonadStateWrite m => Delta Time -> LevelId -> m () Source #

updDiscover :: MonadStateWrite m => Container -> ItemId -> ContentId ItemKind -> AspectRecord -> m () Source #

updCover :: Container -> ItemId -> ContentId ItemKind -> AspectRecord -> m () Source #

updDiscoverKind :: MonadStateWrite m => Container -> ItemKindIx -> ContentId ItemKind -> m () Source #

discoverKind :: MonadStateWrite m => ItemKindIx -> ContentId ItemKind -> m () Source #

updCoverKind :: Container -> ItemKindIx -> ContentId ItemKind -> m () Source #

updDiscoverAspect :: MonadStateWrite m => Container -> ItemId -> AspectRecord -> m () Source #

discoverAspect :: MonadStateWrite m => ItemId -> AspectRecord -> m () Source #

updCoverAspect :: Container -> ItemId -> AspectRecord -> m () Source #

updDiscoverServer :: MonadStateWrite m => ItemId -> AspectRecord -> m () Source #

updCoverServer :: MonadStateWrite m => ItemId -> AspectRecord -> m () Source #

updRestart :: MonadStateWrite m => State -> m () Source #

updRestartServer :: MonadStateWrite m => State -> m () Source #

updResumeServer :: MonadStateWrite m => State -> m () Source #