LambdaHack-0.10.3.0: A game engine library for tactical squad ASCII roguelike dungeon crawlers
Safe HaskellNone
LanguageHaskell2010

Game.LambdaHack.Common.State

Description

The common, for server and clients, main game state type and its operations.

Synopsis

Basic game state, local or global

data State Source #

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.

Instances

Instances details
Eq State Source # 
Instance details

Defined in Game.LambdaHack.Common.State

Methods

(==) :: State -> State -> Bool #

(/=) :: State -> State -> Bool #

Show State Source # 
Instance details

Defined in Game.LambdaHack.Common.State

Methods

showsPrec :: Int -> State -> ShowS #

show :: State -> String #

showList :: [State] -> ShowS #

Binary State Source # 
Instance details

Defined in Game.LambdaHack.Common.State

Methods

put :: State -> Put #

get :: Get State #

putList :: [State] -> Put #

State components

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

updateDungeon :: (Dungeon -> Dungeon) -> State -> State Source #

Update dungeon data within state.

updateDepth :: (AbsDepth -> AbsDepth) -> State -> State Source #

Update dungeon depth.

updateActorD :: (ActorDict -> ActorDict) -> State -> State Source #

Update the actor dictionary.

updateItemD :: (ItemDict -> ItemDict) -> State -> State Source #

Update the item dictionary.

updateItemIxMap :: (ItemIxMap -> ItemIxMap) -> State -> State Source #

Update the item kind index map.

updateFactionD :: (FactionDict -> FactionDict) -> State -> State Source #

Update faction data within state.

updateTime :: (Time -> Time) -> State -> State Source #

Update global time within state.

updateCOpsAndCachedData :: (COps -> COps) -> State -> State Source #

Update content data within state and recompute the cached data.

updateGold :: (Int -> Int) -> State -> State Source #

Update total gold value in the dungeon.

State operations

Internal operations