LambdaHack-0.2.6: A roguelike game engine in early and active development

Safe HaskellNone

Game.LambdaHack.State

Contents

Description

Game state and persistent player diary types and operations.

Synopsis

Game state

data State Source

The state of a single game that can be saved and restored. It's completely disregarded and reset when a new game is started. In practice, we maintain some extra state (DungeonPerception), but it's only temporary, existing for a single turn and then invalidated.

Constructors

State 

Fields

splayer :: ActorId

represents the player-controlled actor

scursor :: Cursor

cursor location and level to return to

sflavour :: FlavourMap

association of flavour to items

sdisco :: Discoveries

items (kinds) that have been discovered

sdungeon :: Dungeon

all dungeon levels

slid :: LevelId

identifier of the current level

scounter :: Int

stores next actor index

srandom :: StdGen

current random generator

sconfig :: CP

this game's config (including initial RNG)

stakeTime :: Maybe Bool

last command unexpectedly took some time

squit :: Maybe (Bool, Status)

cause of game end/exit

sfaction :: Id FactionKind

our faction

sdebug :: DebugMode

debugging mode

data TgtMode Source

Current targeting mode of the player.

Constructors

TgtOff

not in targeting mode

TgtExplicit

the player requested targeting mode explicitly

TgtAuto

the mode was entered (and will be exited) automatically

data Cursor Source

Current targeting cursor parameters.

Constructors

Cursor 

Fields

ctargeting :: TgtMode

targeting mode

clocLn :: LevelId

cursor level

clocation :: Point

cursor coordinates

creturnLn :: LevelId

the level current player resides on

ceps :: Int

a parameter of the tgt digital line

Instances

data Status Source

Current result of the game.

Constructors

Killed !LevelId

the player lost the game on the given level

Camping

game is supended

Victor

the player won

Restart

the player quits and starts a new game

Accessor

slevel :: State -> LevelSource

Get current level from the dungeon data.

stime :: State -> TimeSource

Get current time from the dungeon data.

Constructor

defaultState :: CP -> Id FactionKind -> FlavourMap -> Dungeon -> LevelId -> Point -> StdGen -> StateSource

Initial game state.

State update

updateCursor :: (Cursor -> Cursor) -> State -> StateSource

Update cursor parameters within state.

updateTime :: (Time -> Time) -> State -> StateSource

Update time within state.

updateDiscoveries :: (Discoveries -> Discoveries) -> State -> StateSource

Update item discoveries within state.

updateLevel :: (Level -> Level) -> State -> StateSource

Update level data within state.

updateDungeon :: (Dungeon -> Dungeon) -> State -> StateSource

Update dungeon data within state.

Player diary

data Diary Source

The diary contains all the player data that carries over from game to game, even across playing sessions. That includes the last message, previous messages and otherwise recorded history of past games. This can be extended with other data and used for calculating player achievements, unlocking advanced game features and for general data mining, e.g., augmenting AI or procedural content generation.

Constructors

Diary 

Instances

defaultDiary :: IO DiarySource

Initial player diary.

Debug flags

data DebugMode Source

Constructors

DebugMode 

Instances