Safe Haskell | None |
---|---|
Language | Haskell2010 |
Inhabited dungeon levels and the operations to query and change them as the game progresses.
Synopsis
- data LevelId
- type Dungeon = EnumMap LevelId Level
- ascendInBranch :: Dungeon -> Bool -> LevelId -> [LevelId]
- whereTo :: LevelId -> Point -> Maybe Bool -> Dungeon -> (LevelId, Point)
- type ItemFloor = EnumMap Point ItemBag
- type ActorMap = EnumMap Point [ActorId]
- type TileMap = Array (ContentId TileKind)
- type SmellMap = EnumMap Point Time
- data Level = Level {}
- updateFloor :: (ItemFloor -> ItemFloor) -> Level -> Level
- updateEmbed :: (ItemFloor -> ItemFloor) -> Level -> Level
- updateActorMap :: (ActorMap -> ActorMap) -> Level -> Level
- updateTile :: (TileMap -> TileMap) -> Level -> Level
- updateSmell :: (SmellMap -> SmellMap) -> Level -> Level
- at :: Level -> Point -> ContentId TileKind
- findPoint :: X -> Y -> (Point -> Maybe Point) -> Rnd Point
- findPos :: TileMap -> (Point -> ContentId TileKind -> Bool) -> Rnd Point
- findPosTry :: Int -> TileMap -> (Point -> ContentId TileKind -> Bool) -> [Point -> ContentId TileKind -> Bool] -> Rnd Point
- findPosTry2 :: Int -> TileMap -> (Point -> ContentId TileKind -> Bool) -> [Point -> ContentId TileKind -> Bool] -> (Point -> ContentId TileKind -> Bool) -> [Point -> ContentId TileKind -> Bool] -> Rnd Point
- assertSparseItems :: ItemFloor -> ItemFloor
- assertSparseActors :: ActorMap -> ActorMap
Dungeon
Abstract level identifiers.
Instances
Enum LevelId Source # | |
Eq LevelId Source # | |
Ord LevelId Source # | |
Defined in Game.LambdaHack.Common.Misc | |
Show LevelId Source # | |
Binary LevelId Source # | |
Hashable LevelId Source # | |
Defined in Game.LambdaHack.Common.Misc |
type Dungeon = EnumMap LevelId Level Source #
The complete dungeon is a map from level identifiers to levels.
ascendInBranch :: Dungeon -> Bool -> LevelId -> [LevelId] Source #
Levels in the current branch, one level up (or down) from the current.
:: 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
A view on single, inhabited dungeon level. Remembered fields carry a subset of the info in the client copies of levels.
Level | |
|
Component updates
Level query
findPoint :: X -> Y -> (Point -> Maybe Point) -> Rnd Point Source #
Find a random position on the map satisfying a predicate.
findPos :: TileMap -> (Point -> ContentId TileKind -> Bool) -> Rnd Point Source #
Find a random position on the map satisfying a predicate.
:: 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.
:: 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 |