{- Annotating tree structures with desired properties for rooms. -} module Dodge.Layout.Tree.Annotate where import Dodge.RandomHelp import Dodge.Layout.Tree.Polymorphic import Dodge.Room.Procedural import Dodge.Room.Link import Dodge.Room.Data import Dodge.Room import Data.Tree import Control.Monad.State import System.Random data Annotation = Lock Int | Key Int | Corridor addLock :: RandomGen g => Int -> Tree [Annotation] -> State g (Tree [Annotation]) addLock i t = do (beforeLock, afterLock) <- splitTrunk t newBefore <- applyToRandomNode (Key i :) beforeLock return $ addToTrunk newBefore [Node [Lock i] afterLock] padCorridors :: Tree [Annotation] -> Tree [Annotation] padCorridors (Node x xs) = Node [Corridor] [Node x (map padCorridors xs)] annoToRoom :: RandomGen g => [Annotation] -> State g Room annoToRoom [Corridor] = takeOne [corridor] annoToRoom _ = randLinks $ roomRectAutoLinks 200 200