LambdaHack-0.4.101.1: A game engine library for 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 Source

Abstract level identifiers.

data AbsDepth Source

Absolute depth in the dungeon. When used for the maximum depth of the whole dungeon, this can be different than dungeon size, e.g., when the dungeon is branched, and it can even be different than the length of the longest branch, if levels at some depths are missing.

type Dungeon = EnumMap LevelId Level Source

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

ascendInBranch :: Dungeon -> Int -> LevelId -> [LevelId] Source

Levels in the current branch, k levels shallower than the current.

The Level type and its components

data Level Source

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

Constructors

Level 

Fields

ldepth :: !AbsDepth

absolute depth of the level

lprio :: !ActorPrio

remembered actor times on the level

lfloor :: !ItemFloor

remembered items lying on the floor

lembed :: !ItemFloor

items embedded in the tile

ltile :: !TileMap

remembered level map

lxsize :: !X

width of the level

lysize :: !Y

height of the level

lsmell :: !SmellMap

remembered smells on the level

ldesc :: !Text

level description

lstair :: !([Point], [Point])

positions of (up, down) stairs

lseen :: !Int

currently remembered clear tiles

lclear :: !Int

total number of initially clear tiles

ltime :: !Time

date of the last activity on the level

lactorCoeff :: !Int

the lower, the more monsters spawn

lactorFreq :: !(Freqs ItemKind)

frequency of spawned actors; [] for clients

litemNum :: !Int

number of initial items, 0 for clients

litemFreq :: !(Freqs ItemKind)

frequency of initial items; [] for clients

lsecret :: !Int

secret tile seed

lhidden :: !Int

secret tile density

lescape :: ![Point]

positions of IK.Escape tiles

Instances

type ActorPrio = EnumMap Time [ActorId] Source

Actor time priority queue.

type ItemFloor = EnumMap Point ItemBag Source

Items located on map tiles.

type TileMap = Array (Id TileKind) Source

Tile kinds on the map.

type SmellMap = EnumMap Point SmellTime Source

Current smell on map tiles.

Level query

at :: Level -> Point -> Id TileKind Source

Query for tile kinds on the map.

accessible :: COps -> Level -> Point -> Point -> Bool Source

Check whether one position is accessible from another, using the formula from the standard ruleset. Precondition: the two positions are next to each other.

accessibleUnknown :: COps -> Level -> Point -> Point -> Bool Source

Check whether one position is accessible from another, using the formula from the standard ruleset, but additionally treating unknown tiles as walkable. Precondition: the two positions are next to each other.

accessibleDir :: COps -> Level -> Point -> Vector -> Bool Source

Check whether actors can move from a position along a unit vector, using the formula from the standard ruleset.

findPos :: TileMap -> (Point -> Id TileKind -> Bool) -> Rnd Point Source

Find a random position on the map satisfying a predicate.

findPosTry Source

Arguments

:: Int

the number of tries

-> TileMap

look up in this map

-> (Point -> Id TileKind -> Bool)

mandatory predicate

-> [Point -> Id TileKind -> Bool]

optional predicates

-> Rnd Point 

Try to find a random position on the map satisfying the conjunction of the list of predicates. If the permitted number of attempts is not enough, try again the same number of times without the first predicate, then without the first two, etc., until only one predicate remains, at which point try as many times, as needed.

mapLevelActors_ :: Monad m => (ActorId -> m a) -> Level -> m () Source

mapDungeonActors_ :: Monad m => (ActorId -> m a) -> Dungeon -> m () Source