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

Safe HaskellNone

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.

type Dungeon = EnumMap LevelId Level

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

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

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

Item containers

data Container

Item container type.

The Level type and its components

type SmellMap = EnumMap Point SmellTime

Current smell on map tiles.

type ItemFloor = EnumMap Point ItemBag

Items located on map tiles.

type TileMap = Array Point TileKind

Tile kinds on the map.

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

ldepth :: !Int

depth of the level

lprio :: !ActorPrio

remembered actor times on the level

lfloor :: !ItemFloor

remembered items lying on the floor

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])

destinations 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

litemNum :: !Int

number of initial items, 0 for clients

lsecret :: !Int

secret tile seed

lhidden :: !Int

secret tile density

Instances

Eq Level 
Show Level 
Binary Level 

Level update

updatePrio :: (ActorPrio -> ActorPrio) -> Level -> Level

Update the actor time priority queue.

updateSmell :: (SmellMap -> SmellMap) -> Level -> Level

Update the smell map.

updateFloor :: (ItemFloor -> ItemFloor) -> Level -> Level

Update the items on the ground map.

updateTile :: (TileMap -> TileMap) -> Level -> Level

Update the tile map.

Level query

at :: Level -> Point -> Id TileKind

Query for tile kinds on the map.

atI :: Level -> Point -> ItemBag

Query for items on the ground.

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

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

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

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

Find a random position on the map satisfying a predicate.

findPosTry

Arguments

:: Int

the number of tries

-> TileMap

look up in this map

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

predicates to satisfy

-> 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 ()

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