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

Safe Haskell | None
Language | Haskell2010

Game.LambdaHack.Atomic.MonadStateWrite

Contents

- Internal operations

Description

The monad for writing to the main game state.

Synopsis

- class MonadStateRead m => MonadStateWrite (m :: Type -> Type) where
  - modifyState :: (State -> State) -> m ()
  - putState :: State -> m ()
- newtype AtomicFail = AtomicFail String
- atomicFail :: String -> a
- updateLevel :: MonadStateWrite m => LevelId -> (Level -> Level) -> m ()
- updateActor :: MonadStateWrite m => ActorId -> (Actor -> Actor) -> m ()
- updateFaction :: MonadStateWrite m => FactionId -> (Faction -> Faction) -> m ()
- moveActorMap :: MonadStateWrite m => ActorId -> Actor -> Actor -> m ()
- swapActorMap :: MonadStateWrite m => ActorId -> Actor -> ActorId -> Actor -> m ()
- insertBagContainer :: MonadStateWrite m => ItemBag -> Container -> m ()
- insertItemContainer :: MonadStateWrite m => ItemId -> ItemQuant -> Container -> m ()
- insertItemActor :: MonadStateWrite m => ItemId -> ItemQuant -> ActorId -> CStore -> m ()
- deleteBagContainer :: MonadStateWrite m => ItemBag -> Container -> m ()
- deleteItemContainer :: MonadStateWrite m => ItemId -> ItemQuant -> Container -> m ()
- deleteItemActor :: MonadStateWrite m => ItemId -> ItemQuant -> ActorId -> CStore -> m ()
- itemsMatch :: Item -> Item -> Bool
- addItemToActorMaxSkills :: MonadStateWrite m => ItemId -> Item -> Int -> ActorId -> m ()
- resetActorMaxSkills :: MonadStateWrite m => m ()
- insertItemFloor :: MonadStateWrite m => ItemId -> ItemQuant -> LevelId -> Point -> m ()
- insertItemEmbed :: MonadStateWrite m => ItemId -> ItemQuant -> LevelId -> Point -> m ()
- insertItemOrgan :: MonadStateWrite m => ItemId -> ItemQuant -> ActorId -> m ()
- insertItemEqp :: MonadStateWrite m => ItemId -> ItemQuant -> ActorId -> m ()
- insertItemStash :: MonadStateWrite m => ItemId -> ItemQuant -> FactionId -> m ()
- deleteItemFloor :: MonadStateWrite m => ItemId -> ItemQuant -> LevelId -> Point -> m ()
- deleteItemEmbed :: MonadStateWrite m => ItemId -> ItemQuant -> LevelId -> Point -> m ()
- deleteItemOrgan :: MonadStateWrite m => ItemId -> ItemQuant -> ActorId -> m ()
- deleteItemEqp :: MonadStateWrite m => ItemId -> ItemQuant -> ActorId -> m ()
- deleteItemStash :: MonadStateWrite m => ItemId -> ItemQuant -> FactionId -> m ()
- rmFromBag :: ItemQuant -> ItemId -> ItemBag -> ItemBag

# Documentation

class MonadStateRead m => MonadStateWrite (m :: Type -> Type) where Source #

The monad for writing to the main game state. Atomic updates (`UpdAtomic`) are given semantics in this monad.

Methods

modifyState :: (State -> State) -> m () Source #

putState :: State -> m () Source #

#### Instances

Instances details

MonadStateWrite CliImplementation Source # |
Instance details Defined in Implementation.MonadClientImplementation Methods modifyState :: (State -> State) -> CliImplementation () Source # putState :: State -> CliImplementation () Source #
MonadStateWrite SerImplementation Source # |
Instance details Defined in Implementation.MonadServerImplementation Methods modifyState :: (State -> State) -> SerImplementation () Source # putState :: State -> SerImplementation () Source #

newtype AtomicFail Source #

Exception signifying that atomic action failed because the information it carries is inconsistent with the client's state, (e.g., because the client knows too little to understand the command or already deduced the state change from earlier commands or is confused, amnesiac or sees illusory actors or tiles). Whenever we know the failure is logically impossible, we don't throw the `AtomicFail` exception, but insert a normal assertion or `error` call, which are never caught nor handled.

Constructors

AtomicFail String |

#### Instances

Instances details

Exception AtomicFail Source # |
Instance details Defined in Game.LambdaHack.Atomic.MonadStateWrite Methods toException :: AtomicFail -> SomeException Source # fromException :: SomeException -> Maybe AtomicFail Source # displayException :: AtomicFail -> String Source # backtraceDesired :: AtomicFail -> Bool Source #
Show AtomicFail Source # |
Instance details Defined in Game.LambdaHack.Atomic.MonadStateWrite Methods showsPrec :: Int -> AtomicFail -> ShowS Source # show :: AtomicFail -> String Source # showList :: [AtomicFail] -> ShowS Source #

atomicFail :: String -> a Source #

updateLevel :: MonadStateWrite m => LevelId -> (Level -> Level) -> m () Source #

updateActor :: MonadStateWrite m => ActorId -> (Actor -> Actor) -> m () Source #

updateFaction :: MonadStateWrite m => FactionId -> (Faction -> Faction) -> m () Source #

moveActorMap :: MonadStateWrite m => ActorId -> Actor -> Actor -> m () Source #

swapActorMap :: MonadStateWrite m => ActorId -> Actor -> ActorId -> Actor -> m () Source #

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

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

insertItemActor :: MonadStateWrite m => ItemId -> ItemQuant -> ActorId -> CStore -> m () Source #

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

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

deleteItemActor :: MonadStateWrite m => ItemId -> ItemQuant -> ActorId -> CStore -> m () Source #

itemsMatch :: Item -> Item -> Bool Source #

addItemToActorMaxSkills :: MonadStateWrite m => ItemId -> Item -> Int -> ActorId -> m () Source #

resetActorMaxSkills :: MonadStateWrite m => m () Source #

# Internal operations

insertItemFloor :: MonadStateWrite m => ItemId -> ItemQuant -> LevelId -> Point -> m () Source #

insertItemEmbed :: MonadStateWrite m => ItemId -> ItemQuant -> LevelId -> Point -> m () Source #

insertItemOrgan :: MonadStateWrite m => ItemId -> ItemQuant -> ActorId -> m () Source #

insertItemEqp :: MonadStateWrite m => ItemId -> ItemQuant -> ActorId -> m () Source #

insertItemStash :: MonadStateWrite m => ItemId -> ItemQuant -> FactionId -> m () Source #

deleteItemFloor :: MonadStateWrite m => ItemId -> ItemQuant -> LevelId -> Point -> m () Source #

deleteItemEmbed :: MonadStateWrite m => ItemId -> ItemQuant -> LevelId -> Point -> m () Source #

deleteItemOrgan :: MonadStateWrite m => ItemId -> ItemQuant -> ActorId -> m () Source #

deleteItemEqp :: MonadStateWrite m => ItemId -> ItemQuant -> ActorId -> m () Source #

deleteItemStash :: MonadStateWrite m => ItemId -> ItemQuant -> FactionId -> m () Source #

rmFromBag :: ItemQuant -> ItemId -> ItemBag -> ItemBag Source #