Safe Haskell | None |
---|---|
Language | Haskell2010 |
Game.LambdaHack.Common.State
Description
The common, for server and clients, main game state type and its operations.
Synopsis
- data State
- sdungeon :: State -> Dungeon
- stotalDepth :: State -> AbsDepth
- sactorD :: State -> ActorDict
- sitemD :: State -> ItemDict
- sitemIxMap :: State -> ItemIxMap
- sfactionD :: State -> FactionDict
- stime :: State -> Time
- scops :: State -> COps
- sgold :: State -> Int
- shigh :: State -> ScoreDict
- sgameModeId :: State -> ContentId ModeKind
- sdiscoKind :: State -> DiscoveryKind
- sdiscoAspect :: State -> DiscoveryAspect
- sactorMaxSkills :: State -> ActorMaxSkills
- defStateGlobal :: Dungeon -> AbsDepth -> FactionDict -> COps -> ScoreDict -> ContentId ModeKind -> DiscoveryKind -> State
- emptyState :: State
- localFromGlobal :: State -> State
- updateDungeon :: (Dungeon -> Dungeon) -> State -> State
- updateDepth :: (AbsDepth -> AbsDepth) -> State -> State
- updateActorD :: (ActorDict -> ActorDict) -> State -> State
- updateItemD :: (ItemDict -> ItemDict) -> State -> State
- updateItemIxMap :: (ItemIxMap -> ItemIxMap) -> State -> State
- updateFactionD :: (FactionDict -> FactionDict) -> State -> State
- updateTime :: (Time -> Time) -> State -> State
- updateCOpsAndCachedData :: (COps -> COps) -> State -> State
- updateGold :: (Int -> Int) -> State -> State
- updateDiscoKind :: (DiscoveryKind -> DiscoveryKind) -> State -> State
- updateDiscoAspect :: (DiscoveryAspect -> DiscoveryAspect) -> State -> State
- updateActorMaxSkills :: (ActorMaxSkills -> ActorMaxSkills) -> State -> State
- getItemBody :: ItemId -> State -> Item
- aspectRecordFromItem :: ItemId -> Item -> State -> AspectRecord
- aspectRecordFromIid :: ItemId -> State -> AspectRecord
- maxSkillsFromActor :: Actor -> State -> Skills
- maxSkillsInDungeon :: State -> ActorMaxSkills
- unknownLevel :: COps -> ContentId CaveKind -> AbsDepth -> Area -> ([Point], [Point]) -> [Point] -> Int -> Bool -> Level
- unknownTileMap :: Area -> ContentId TileKind -> X -> Y -> TileMap
Basic game state, local or global
The main game state, the basic one, pertaining to a single game, not to a single playing session or an intersection of both. This state persists between playing sessions, until the particular game ends. Anything that persists between games is stored in server state, client state or client UI session state.
Another differentiating property of this state is that it's kept separately on the server and each of the clients (players, human or AI) and separately updated, according to what each player can observe. It's never updated directly, but always through atomic commands (CmdAtomic) that are filtered and interpreted differently on server and on each client. Therefore, the type is a view on the game state, not the real game state, except on the server that alone stores the full game information.
State components
stotalDepth :: State -> AbsDepth Source #
sitemIxMap :: State -> ItemIxMap Source #
sfactionD :: State -> FactionDict Source #
sdiscoKind :: State -> DiscoveryKind Source #
sdiscoAspect :: State -> DiscoveryAspect Source #
State construction
defStateGlobal :: Dungeon -> AbsDepth -> FactionDict -> COps -> ScoreDict -> ContentId ModeKind -> DiscoveryKind -> State Source #
Initial complete global game state.
emptyState :: State Source #
Initial empty state.
localFromGlobal :: State -> State Source #
Local state created by removing secret information from global state components.
State update
updateItemIxMap :: (ItemIxMap -> ItemIxMap) -> State -> State Source #
Update the item kind index map.
updateFactionD :: (FactionDict -> FactionDict) -> State -> State Source #
Update faction data within state.
updateCOpsAndCachedData :: (COps -> COps) -> State -> State Source #
Update content data within state and recompute the cached data.
updateDiscoKind :: (DiscoveryKind -> DiscoveryKind) -> State -> State Source #
updateDiscoAspect :: (DiscoveryAspect -> DiscoveryAspect) -> State -> State Source #
updateActorMaxSkills :: (ActorMaxSkills -> ActorMaxSkills) -> State -> State Source #
State operations
aspectRecordFromItem :: ItemId -> Item -> State -> AspectRecord Source #
aspectRecordFromIid :: ItemId -> State -> AspectRecord Source #
Internal operations
unknownLevel :: COps -> ContentId CaveKind -> AbsDepth -> Area -> ([Point], [Point]) -> [Point] -> Int -> Bool -> Level Source #