Safe Haskell | None |
---|---|
Language | Haskell2010 |
Inhabited dungeon levels and the operations to query and change them as the game progresses.
Synopsis
- type Dungeon = EnumMap LevelId Level
- dungeonBounds :: Dungeon -> (LevelId, LevelId)
- ascendInBranch :: Dungeon -> Bool -> LevelId -> [LevelId]
- whereTo :: LevelId -> Point -> Bool -> Dungeon -> [(LevelId, Point)]
- type ItemFloor = EnumMap Point ItemBag
- type BigActorMap = EnumMap Point ActorId
- type ProjectileMap = 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
- updateBigMap :: (BigActorMap -> BigActorMap) -> Level -> Level
- updateProjMap :: (ProjectileMap -> ProjectileMap) -> Level -> Level
- updateTile :: (TileMap -> TileMap) -> Level -> Level
- updateEntry :: (EntryMap -> EntryMap) -> Level -> Level
- updateSmell :: (SmellMap -> SmellMap) -> Level -> Level
- at :: Level -> Point -> ContentId TileKind
- posToBigLvl :: Point -> Level -> Maybe ActorId
- occupiedBigLvl :: Point -> Level -> Bool
- posToProjsLvl :: Point -> Level -> [ActorId]
- occupiedProjLvl :: Point -> Level -> Bool
- posToAidsLvl :: Point -> Level -> [ActorId]
- findPosTry :: Int -> Level -> (Point -> ContentId TileKind -> Bool) -> [Point -> ContentId TileKind -> Bool] -> Rnd (Maybe Point)
- findPosTry2 :: Int -> Level -> (Point -> ContentId TileKind -> Bool) -> [Point -> ContentId TileKind -> Bool] -> (Point -> ContentId TileKind -> Bool) -> [Point -> ContentId TileKind -> Bool] -> Rnd (Maybe Point)
- nearbyPassablePoints :: COps -> Level -> Point -> [Point]
- nearbyFreePoints :: COps -> Level -> (ContentId TileKind -> Bool) -> Point -> [Point]
- sortEmbeds :: COps -> ContentId TileKind -> [(ItemKind, (ItemId, ItemQuant))] -> [(ItemId, ItemQuant)]
- type EntryMap = EnumMap Point PlaceEntry
- assertSparseItems :: ItemFloor -> ItemFloor
- assertSparseProjectiles :: ProjectileMap -> ProjectileMap
Dungeon
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 |
-> Bool | optional forced direction |
-> Dungeon | current game dungeon |
-> [(LevelId, Point)] | possible destinations |
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 ProjectileMap = EnumMap Point [ActorId] Source #
Collections of projectiles located on map tiles.
A view on single, inhabited dungeon level. Remembered fields carry a subset of the info in the client copies of levels.
Level | |
|
Component updates
updateBigMap :: (BigActorMap -> BigActorMap) -> Level -> Level Source #
updateProjMap :: (ProjectileMap -> ProjectileMap) -> Level -> Level Source #
Level query
:: Int | the number of tries |
-> Level | look up in this level |
-> (Point -> ContentId TileKind -> Bool) | mandatory predicate |
-> [Point -> ContentId TileKind -> Bool] | optional predicates |
-> Rnd (Maybe 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 with only the mandatory predicate.
:: Int | the number of tries |
-> Level | look up in this level |
-> (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 (Maybe Point) |
nearbyPassablePoints :: COps -> Level -> Point -> [Point] Source #
Generate a list of all passable points on (connected component of) the level in the order of path distance from the starting position (BFS). The starting position needn't be passable and is always included.
Misc
sortEmbeds :: COps -> ContentId TileKind -> [(ItemKind, (ItemId, ItemQuant))] -> [(ItemId, ItemQuant)] Source #