Safe Haskell | None |
---|
Atomic game state transformations. TODO: haddocks.
See https://github.com/LambdaHack/LambdaHack/wiki/Client-server-architecture.
- class MonadStateRead m => MonadAtomic m where
- execAtomic :: CmdAtomic -> m ()
- execUpdAtomic :: UpdAtomic -> m ()
- execSfxAtomic :: SfxAtomic -> m ()
- broadcastUpdAtomic :: MonadAtomic m => (FactionId -> UpdAtomic) -> m ()
- broadcastSfxAtomic :: MonadAtomic m => (FactionId -> SfxAtomic) -> m ()
- data CmdAtomic
- data UpdAtomic
- = UpdCreateActor !ActorId !Actor ![(ItemId, Item)]
- | UpdDestroyActor !ActorId !Actor ![(ItemId, Item)]
- | UpdCreateItem !ItemId !Item !Int !Container
- | UpdDestroyItem !ItemId !Item !Int !Container
- | UpdSpotActor !ActorId !Actor ![(ItemId, Item)]
- | UpdLoseActor !ActorId !Actor ![(ItemId, Item)]
- | UpdSpotItem !ItemId !Item !Int !Container
- | UpdLoseItem !ItemId !Item !Int !Container
- | UpdMoveActor !ActorId !Point !Point
- | UpdWaitActor !ActorId !Bool
- | UpdDisplaceActor !ActorId !ActorId
- | UpdMoveItem !ItemId !Int !ActorId !CStore !CStore
- | UpdAgeActor !ActorId !(Delta Time)
- | UpdRefillHP !ActorId !Int64
- | UpdRefillCalm !ActorId !Int64
- | UpdOldFidActor !ActorId !FactionId !FactionId
- | UpdTrajectory !ActorId !(Maybe ([Vector], Speed)) !(Maybe ([Vector], Speed))
- | UpdColorActor !ActorId !Color !Color
- | UpdQuitFaction !FactionId !(Maybe Actor) !(Maybe Status) !(Maybe Status)
- | UpdLeadFaction !FactionId !(Maybe (ActorId, Maybe Target)) !(Maybe (ActorId, Maybe Target))
- | UpdDiplFaction !FactionId !FactionId !Diplomacy !Diplomacy
- | UpdTacticFaction !FactionId !Tactic !Tactic
- | UpdAutoFaction !FactionId !Bool
- | UpdRecordKill !ActorId !(Id ItemKind) !Int
- | UpdAlterTile !LevelId !Point !(Id TileKind) !(Id TileKind)
- | UpdAlterClear !LevelId !Int
- | UpdSearchTile !ActorId !Point !(Id TileKind) !(Id TileKind)
- | UpdLearnSecrets !ActorId !Int !Int
- | UpdSpotTile !LevelId ![(Point, Id TileKind)]
- | UpdLoseTile !LevelId ![(Point, Id TileKind)]
- | UpdAlterSmell !LevelId !Point !(Maybe Time) !(Maybe Time)
- | UpdSpotSmell !LevelId ![(Point, Time)]
- | UpdLoseSmell !LevelId ![(Point, Time)]
- | UpdAgeGame !(Delta Time) ![LevelId]
- | UpdDiscover !LevelId !Point !ItemId !(Id ItemKind) !ItemSeed
- | UpdCover !LevelId !Point !ItemId !(Id ItemKind) !ItemSeed
- | UpdDiscoverKind !LevelId !Point !ItemId !(Id ItemKind)
- | UpdCoverKind !LevelId !Point !ItemId !(Id ItemKind)
- | UpdDiscoverSeed !LevelId !Point !ItemId !ItemSeed
- | UpdCoverSeed !LevelId !Point !ItemId !ItemSeed
- | UpdPerception !LevelId !Perception !Perception
- | UpdRestart !FactionId !DiscoveryKind !FactionPers !State !DebugModeCli !GroupName
- | UpdRestartServer !State
- | UpdResume !FactionId !FactionPers
- | UpdResumeServer !State
- | UpdKillExit !FactionId
- | UpdWriteSave
- | UpdMsgAll !Msg
- | UpdRecordHistory !FactionId
- data SfxAtomic
- = SfxStrike !ActorId !ActorId !ItemId !HitAtomic
- | SfxRecoil !ActorId !ActorId !ItemId !HitAtomic
- | SfxProject !ActorId !ItemId
- | SfxCatch !ActorId !ItemId
- | SfxActivate !ActorId !ItemId !Int
- | SfxCheck !ActorId !ItemId !Int
- | SfxTrigger !ActorId !Point !Feature
- | SfxShun !ActorId !Point !Feature
- | SfxEffect !FactionId !ActorId !(Effect Int)
- | SfxMsgFid !FactionId !Msg
- | SfxMsgAll !Msg
- | SfxActorStart !ActorId
- data HitAtomic
- data PosAtomic
- posUpdAtomic :: MonadStateRead m => UpdAtomic -> m PosAtomic
- posSfxAtomic :: MonadStateRead m => SfxAtomic -> m PosAtomic
- seenAtomicCli :: Bool -> FactionId -> Perception -> PosAtomic -> Bool
- generalMoveItem :: MonadStateRead m => ItemId -> Int -> Container -> Container -> m [UpdAtomic]
Re-exported from MonadAtomic
class MonadStateRead m => MonadAtomic m whereSource
execAtomic :: CmdAtomic -> m ()Source
execUpdAtomic :: UpdAtomic -> m ()Source
execSfxAtomic :: SfxAtomic -> m ()Source
MonadAtomic SerImplementation | The game-state semantics of atomic game commands as computed on the server. |
MonadAtomic (CliImplementation resp req) |
broadcastUpdAtomic :: MonadAtomic m => (FactionId -> UpdAtomic) -> m ()Source
broadcastSfxAtomic :: MonadAtomic m => (FactionId -> SfxAtomic) -> m ()Source
Re-exported from CmdAtomic
Abstract syntax of atomic commands.
Abstract syntax of atomic special effects.
Re-exported from PosAtomicRead
The type representing visibility of actions to factions, based on the position of the action, etc.
PosSight !LevelId ![Point] | whomever sees all the positions, notices |
PosFidAndSight ![FactionId] !LevelId ![Point] | observers and the faction notice |
PosSmell !LevelId ![Point] | whomever smells all the positions, notices |
PosFid !FactionId | only the faction notices |
PosFidAndSer !(Maybe LevelId) !FactionId | faction and server notices |
PosSer | only the server notices |
PosAll | everybody notices |
PosNone | never broadcasted, but sent manually |
posUpdAtomic :: MonadStateRead m => UpdAtomic -> m PosAtomicSource
Produce the positions where the action takes place.
The goal of the mechanics: client should not get significantly
more information by looking at the atomic commands he is able to see
than by looking at the state changes they enact. E.g., UpdDisplaceActor
in a black room, with one actor carrying a 0-radius light would not be
distinguishable by looking at the state (or the screen) from UpdMoveActor
of the illuminated actor, hence such UpdDisplaceActor
should not be
observable, but UpdMoveActor
should be (or the former should be perceived
as the latter). However, to simplify, we assing as strict visibility
requirements to UpdMoveActor
as to UpdDisplaceActor
and fall back
to UpdSpotActor
(which provides minimal information that does not
contradict state) if the visibility is lower.
posSfxAtomic :: MonadStateRead m => SfxAtomic -> m PosAtomicSource
Produce the positions where the atomic special effect takes place.
seenAtomicCli :: Bool -> FactionId -> Perception -> PosAtomic -> BoolSource
generalMoveItem :: MonadStateRead m => ItemId -> Int -> Container -> Container -> m [UpdAtomic]Source