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

Safe HaskellNone




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



data LevelId Source

Abstract level identifiers.

type Dungeon = EnumMap LevelId LevelSource

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

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

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

Item containers

The Level type and its components

type SmellMap = EnumMap Point SmellTimeSource

Current smell on map tiles.

type ItemFloor = EnumMap Point ItemBagSource

Items located on map tiles.

type TileMap = Array Point TileKindSource

Tile kinds on the map.

data Level Source

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




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)

destination 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 level seed, unknown by clients

lhidden :: !Int

secret tile density, unknown by clients


Level update

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

Update the actor time priority queue.

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

Update the smell map.

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

Update the items on the ground map.

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

Update the tile map.

Level query

at :: Level -> Point -> Id TileKindSource

Query for tile kinds on the map.

atI :: Level -> Point -> ItemBagSource

Query for items on the ground.

accessible :: COps -> Level -> Point -> Point -> BoolSource

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 -> BoolSource

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 PointSource

Find a random position on the map satisfying a predicate.



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

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