LambdaHack-0.8.3.0: A game engine library for tactical squad ASCII roguelike dungeon crawlers

Safe HaskellNone
LanguageHaskell2010

Game.LambdaHack.Common.Level

Contents

Description

Inhabited dungeon levels and the operations to query and change them as the game progresses.

Synopsis

Dungeon

data LevelId #

Abstract level identifiers.

Instances
Enum LevelId # 
Instance details

Defined in Game.LambdaHack.Common.Misc

Eq LevelId # 
Instance details

Defined in Game.LambdaHack.Common.Misc

Methods

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

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

Ord LevelId # 
Instance details

Defined in Game.LambdaHack.Common.Misc

Show LevelId # 
Instance details

Defined in Game.LambdaHack.Common.Misc

Binary LevelId # 
Instance details

Defined in Game.LambdaHack.Common.Misc

Methods

put :: LevelId -> Put #

get :: Get LevelId #

putList :: [LevelId] -> Put #

Hashable LevelId # 
Instance details

Defined in Game.LambdaHack.Common.Misc

Methods

hashWithSalt :: Int -> LevelId -> Int #

hash :: LevelId -> Int #

type Dungeon = EnumMap LevelId Level #

The complete dungeon is a map from level identifiers to levels.

ascendInBranch :: Dungeon -> Bool -> LevelId -> [LevelId] #

Levels in the current branch, one level up (or down) from the current.

whereTo #

Arguments

:: LevelId

level of the stairs

-> Point

position of the stairs

-> Maybe Bool

optional forced direction

-> Dungeon

current game dungeon

-> (LevelId, Point)

destination level and the pos of its receiving stairs

Compute the level identifier and stair position on the new level, after a level change.

We assume there is never a staircase up and down at the same position.

The Level type and its components

type ItemFloor = EnumMap Point ItemBag #

Items located on map tiles.

type ActorMap = EnumMap Point [ActorId] #

Items located on map tiles.

type TileMap = Array (ContentId TileKind) #

Tile kinds on the map.

type SmellMap = EnumMap Point Time #

Current smell on map tiles.

data Level #

A view on single, inhabited dungeon level. Remembered fields carry a subset of the info in the client copies of levels.

Constructors

Level 

Fields

Instances
Eq Level # 
Instance details

Defined in Game.LambdaHack.Common.Level

Methods

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

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

Show Level # 
Instance details

Defined in Game.LambdaHack.Common.Level

Methods

showsPrec :: Int -> Level -> ShowS #

show :: Level -> String #

showList :: [Level] -> ShowS #

Binary Level # 
Instance details

Defined in Game.LambdaHack.Common.Level

Methods

put :: Level -> Put #

get :: Get Level #

putList :: [Level] -> Put #

Component updates

Level query

at :: Level -> Point -> ContentId TileKind #

Query for tile kinds on the map.

findPoint :: X -> Y -> (Point -> Maybe Point) -> Rnd Point #

Find a random position on the map satisfying a predicate.

findPos :: TileMap -> (Point -> ContentId TileKind -> Bool) -> Rnd Point #

Find a random position on the map satisfying a predicate.

findPosTry #

Arguments

:: Int

the number of tries

-> TileMap

look up in this map

-> (Point -> ContentId TileKind -> Bool)

mandatory predicate

-> [Point -> ContentId TileKind -> Bool]

optional predicates

-> Rnd Point 

Try to find a random position on the map satisfying conjunction of the mandatory and an optional predicate. If the permitted number of attempts is not enough, try again the same number of times without the next optional predicate, and fall back to trying as many times, as needed, with only the mandatory predicate.

findPosTry2 #

Arguments

:: Int

the number of tries

-> TileMap

look up in this map

-> (Point -> ContentId TileKind -> Bool)

mandatory predicate

-> [Point -> ContentId TileKind -> Bool]

optional predicates

-> (Point -> ContentId TileKind -> Bool)

good to have pred.

-> [Point -> ContentId TileKind -> Bool]

worst case predicates

-> Rnd Point 

Internal operations