Add or annotations

This commit is contained in:
jgk
2021-04-22 13:34:53 +02:00
parent 0e88544de2
commit 1ab793180c
2 changed files with 7 additions and 1 deletions
+1 -1
View File
@@ -33,7 +33,7 @@ roomTreex = do
struct' <- aTreeStrut
let struct = Node [EndRoom] []
let t' = padCorridors struct
t = treeTrunk [[StartRoom],[Corridor],[FirstWeapon],[Corridor]] t'
t = treeTrunk [[StartRoom],[OrAno [[DoorAno],[Corridor]] ],[FirstWeapon],[Corridor]] t'
fmap (shiftExpandTree . expandTreeBy id) $ mapM annoToRoomTree t
levx :: RandomGen g => State g [Room]
+6
View File
@@ -21,9 +21,11 @@ data Annotation
= Lock Int
| Key Int
| Corridor
| DoorAno
| FirstWeapon
| StartRoom
| EndRoom
| OrAno [[Annotation]]
addLock :: RandomGen g => Int -> Tree [Annotation] -> State g (Tree [Annotation])
addLock i t = do
@@ -41,7 +43,11 @@ randomPadCorridors (Node x xs) = do
return $ treeTrunk (replicate n [Corridor]) (Node x xs')
annoToRoomTree :: RandomGen g => [Annotation] -> State g (Tree (Either Room Room))
annoToRoomTree [OrAno as] = do
a <- takeOne as
annoToRoomTree a
annoToRoomTree [Corridor] = fmap (pure . Right) $ randomiseOutLinks corridor
annoToRoomTree [DoorAno] = fmap (\r -> Node (Left door) [(pure . Right) r]) (randomiseOutLinks corridor)
annoToRoomTree [FirstWeapon] = do
branchWP <- branchRectWith weaponRoom
blockedC <- blockedCorridor