Allow for more complex placement positioning

This commit is contained in:
2021-11-24 20:51:50 +00:00
parent c4614866e6
commit e44c5e7120
16 changed files with 178 additions and 173 deletions
+12
View File
@@ -16,6 +16,7 @@ module Dodge.Room.Link
, changeLinkTo
, changeLinkFrom
, randomiseOutLinks
, chooseOneInLink
) where
import Dodge.Placement.PlaceSpot
import Dodge.LevelGen.Data
@@ -29,6 +30,17 @@ import Control.Monad.State
import Control.Lens
import Data.List
import qualified Data.Set as S
--import System.Random
chooseOneInLink :: RandomGen g => Room -> State g Room
chooseOneInLink r = restrictToFstInLink <$> shuffleLinks r
restrictToFstInLink :: Room -> Room
restrictToFstInLink = rmLinks %~ f
where
f (rl:xs) | S.member InLink (_rlType rl) = rl : restrictLinkType InLink (const False) xs
| otherwise = rl : f xs
f [] = []
{- Shuffle the initial links of a room randomly. -}
randomiseOutLinks :: RandomGen g => Room -> State g Room