Safe Haskell | None |
---|---|
Language | Haskell2010 |
Atomic game state transformations.
See https://github.com/LambdaHack/LambdaHack/wiki/Client-server-architecture.
- class MonadStateRead m => MonadAtomic m where
- data CmdAtomic
- data UpdAtomic
- = UpdCreateActor ActorId Actor [(ItemId, Item)]
- | UpdDestroyActor ActorId Actor [(ItemId, Item)]
- | UpdCreateItem ItemId Item ItemQuant Container
- | UpdDestroyItem ItemId Item ItemQuant Container
- | UpdSpotActor ActorId Actor [(ItemId, Item)]
- | UpdLoseActor ActorId Actor [(ItemId, Item)]
- | UpdSpotItem Bool ItemId Item ItemQuant Container
- | UpdLoseItem Bool ItemId Item ItemQuant Container
- | UpdMoveActor ActorId Point Point
- | UpdWaitActor ActorId Bool
- | UpdDisplaceActor ActorId ActorId
- | UpdMoveItem ItemId Int ActorId CStore CStore
- | UpdRefillHP ActorId Int64
- | UpdRefillCalm ActorId Int64
- | UpdTrajectory ActorId (Maybe ([Vector], Speed)) (Maybe ([Vector], Speed))
- | UpdQuitFaction FactionId (Maybe Status) (Maybe Status)
- | UpdLeadFaction FactionId (Maybe ActorId) (Maybe ActorId)
- | UpdDiplFaction FactionId FactionId Diplomacy Diplomacy
- | UpdTacticFaction FactionId Tactic Tactic
- | UpdAutoFaction FactionId Bool
- | UpdRecordKill ActorId (Id ItemKind) Int
- | UpdAlterTile LevelId Point (Id TileKind) (Id TileKind)
- | UpdAlterExplorable LevelId Int
- | UpdSearchTile ActorId Point (Id TileKind)
- | UpdHideTile ActorId Point (Id TileKind)
- | UpdSpotTile LevelId [(Point, Id TileKind)]
- | UpdLoseTile LevelId [(Point, Id TileKind)]
- | UpdAlterSmell LevelId Point Time Time
- | UpdSpotSmell LevelId [(Point, Time)]
- | UpdLoseSmell LevelId [(Point, Time)]
- | UpdTimeItem ItemId Container ItemTimer ItemTimer
- | UpdAgeGame [LevelId]
- | UpdUnAgeGame [LevelId]
- | UpdDiscover Container ItemId (Id ItemKind) ItemSeed
- | UpdCover Container ItemId (Id ItemKind) ItemSeed
- | UpdDiscoverKind Container ItemId (Id ItemKind)
- | UpdCoverKind Container ItemId (Id ItemKind)
- | UpdDiscoverSeed Container ItemId ItemSeed
- | UpdCoverSeed Container ItemId ItemSeed
- | UpdPerception LevelId Perception Perception
- | UpdRestart FactionId DiscoveryKind PerLid State Challenge DebugModeCli
- | UpdRestartServer State
- | UpdResume FactionId PerLid
- | UpdResumeServer State
- | UpdKillExit FactionId
- | UpdWriteSave
- | UpdMsgAll Text
- data SfxAtomic
- = SfxStrike ActorId ActorId ItemId CStore
- | SfxRecoil ActorId ActorId ItemId CStore
- | SfxSteal ActorId ActorId ItemId CStore
- | SfxRelease ActorId ActorId ItemId CStore
- | SfxProject ActorId ItemId CStore
- | SfxReceive ActorId ItemId CStore
- | SfxApply ActorId ItemId CStore
- | SfxCheck ActorId ItemId CStore
- | SfxTrigger ActorId Point
- | SfxShun ActorId Point
- | SfxEffect FactionId ActorId Effect Int64
- | SfxMsgFid FactionId SfxMsg
- data SfxMsg
- = SfxUnexpected ReqFailure
- | SfxLoudUpd Bool UpdAtomic
- | SfxLoudStrike Bool (Id ItemKind) Int
- | SfxLoudSummon Bool (GroupName ItemKind) Dice
- | SfxFizzles
- | SfxNothingHappens
- | SfxVoidDetection
- | SfxSummonLackCalm ActorId
- | SfxLevelNoMore
- | SfxLevelPushed
- | SfxBracedImmune ActorId
- | SfxEscapeImpossible
- | SfxTransImpossible
- | SfxIdentifyNothing CStore
- | SfxPurposeNothing CStore
- | SfxPurposeTooFew Int Int
- | SfxPurposeUnique
- | SfxColdFish
- | SfxTimerExtended ActorId ItemId CStore
- data PosAtomic
- posUpdAtomic :: MonadStateRead m => UpdAtomic -> m PosAtomic
- posSfxAtomic :: MonadStateRead m => SfxAtomic -> m PosAtomic
- breakUpdAtomic :: MonadStateRead m => UpdAtomic -> m [UpdAtomic]
- seenAtomicCli :: Bool -> FactionId -> Perception -> PosAtomic -> Bool
- seenAtomicSer :: PosAtomic -> Bool
- generalMoveItem :: MonadStateRead m => Bool -> ItemId -> Int -> Container -> Container -> m [UpdAtomic]
- posProjBody :: Actor -> PosAtomic
- class MonadStateRead m => MonadStateWrite m where
- handleUpdAtomic :: MonadStateWrite m => UpdAtomic -> m ()
Re-exported from Game.LambdaHack.Atomic.MonadAtomic
class MonadStateRead m => MonadAtomic m where Source #
The monad for executing atomic game state transformations.
execUpdAtomic :: UpdAtomic -> m () Source #
Execute an atomic command that really changes the state.
execSfxAtomic :: SfxAtomic -> m () Source #
Execute an atomic command that only displays special effects.
execSendPer :: FactionId -> LevelId -> Perception -> Perception -> Perception -> m () Source #
MonadAtomic CliImplementation Source # | The game-state semantics of atomic commands as computed on the client. |
MonadAtomic SerImplementation Source # | The game-state semantics of atomic commands as computed on the server. |
Re-exported from Game.LambdaHack.Atomic.CmdAtomic
Abstract syntax of atomic commands, that is, atomic game state transformations.
Abstract syntax of atomic updates, that is, atomic commands that really change the state. Most of them are an encoding of a game state diff, though they also carry some intentional hints that help clients determine whether and how to communicate them to players.
Abstract syntax of atomic special effects, that is, atomic commands that only display special effects and don't change the state.
Re-exported from Game.LambdaHack.Atomic.PosAtomicRead
The type representing visibility of atomic commands to factions, based on the position of the command, etc. Note that the server sees and smells all positions.
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 PosAtomic Source #
Produce the positions where the atomic update takes place.
The goal of the mechanics is to ensure the commands don't carry significantly more information than their corresponding state diffs would. In other words, the atomic commands involving the positions seen by a client should convey similar information as the client would get by directly observing the changes the commands enact on the visible portion of server game state. The client is then free to change its copy of game state accordingly or not --- it only partially reflects reality anyway.
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 assign 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 PosAtomic Source #
Produce the positions where the atomic special effect takes place.
breakUpdAtomic :: MonadStateRead m => UpdAtomic -> m [UpdAtomic] Source #
Decompose an atomic action. The decomposed actions give reduced
information that still modifies client's state to match the server state
wrt the current FOV and the subset of posUpdAtomic
that is visible.
The original actions give more information not only due to spanning
potentially more positions than those visible. E.g., UpdMoveActor
informs about the continued existence of the actor between
moves, v.s., popping out of existence and then back in.
seenAtomicCli :: Bool -> FactionId -> Perception -> PosAtomic -> Bool Source #
Given the client, it's perception and an atomic command, determine if the client notices the command.
seenAtomicSer :: PosAtomic -> Bool Source #
generalMoveItem :: MonadStateRead m => Bool -> ItemId -> Int -> Container -> Container -> m [UpdAtomic] Source #
Generate the atomic updates that jointly perform a given item move.
posProjBody :: Actor -> PosAtomic Source #
Re-exported from Game.LambdaHack.Atomic.MonadStateWrite
class MonadStateRead m => MonadStateWrite m where Source #
modifyState :: (State -> State) -> m () Source #
Re-exported from Game.LambdaHack.Atomic.HandleAtomicWrite
handleUpdAtomic :: MonadStateWrite m => UpdAtomic -> m () Source #
The game-state semantics of atomic game commands.
Special effects (SfxAtomic
) don't modify state.