Implement first weapon into tree structure

This commit is contained in:
2021-04-21 13:00:11 +02:00
parent 7c0fbe0ce2
commit a1c344a342
9 changed files with 93 additions and 40 deletions
+15 -2
View File
@@ -18,6 +18,8 @@ data Annotation
= Lock Int
| Key Int
| Corridor
| FirstWeapon
| StartRoom
addLock :: RandomGen g => Int -> Tree [Annotation] -> State g (Tree [Annotation])
addLock i t = do
@@ -34,9 +36,20 @@ randomPadCorridors (Node x xs) = do
xs' <- mapM randomPadCorridors xs
return $ treeTrunk (replicate n [Corridor]) (Node x xs')
annoToRoomTree :: RandomGen g => [Annotation] -> State g (Tree (Either Room Room))
annoToRoomTree [Corridor] = fmap (pure . Right) $ randomiseOutLinks corridor
annoToRoomTree [FirstWeapon] = weaponRoom
annoToRoomTree _ = do
w <- state $ randomR (100,400)
h <- state $ randomR (200,400)
fmap (pure . Right) $ return (roomRectAutoLinks w h) >>= randomiseOutLinks
annoToRoom :: RandomGen g => [Annotation] -> State g Room
annoToRoom [Corridor] = takeOne [corridor]
annoToRoom _ = randLinks $ roomRectAutoLinks 200 200
annoToRoom [Corridor] = randomiseOutLinks corridor
annoToRoom _ = do
w <- state $ randomR (100,400)
h <- state $ randomR (200,400)
return (roomRectAutoLinks w h) >>= randomiseOutLinks
annoToRoom' :: [Annotation] -> Room
annoToRoom' [Corridor] = corridor