Continue link cleanup

This commit is contained in:
2022-03-05 01:29:24 +00:00
parent 0c580e63a4
commit f82bd3f788
5 changed files with 22 additions and 24 deletions
-9
View File
@@ -15,7 +15,6 @@ module Dodge.Room.Link
, shuffleLinks
, filterLinks
, changeLinkTo
, changeLinkFrom
, randomiseOutLinks
, chooseOneInLink
, restrictRMInLinksPD
@@ -93,14 +92,6 @@ filterLinks :: RandomGen g => ((Point2,Float) -> Bool) -> Room -> State g Room
filterLinks cond r = do
newLinks <- shuffle $ filter (cond . lnkPosDir) $ _rmLinks r
return $ r {_rmLinks = newLinks}
{- | Swaps the first link in the list with one that satisfies a given property.
- Does not change the last link in the list -}
-- TODO replace all instances of this with something more sensible
changeLinkFrom :: RandomGen g => ((Point2,Float) -> Bool) -> Room -> State g Room
changeLinkFrom cond r = do
let (possibleLnks,otherLnks) = partition (cond . lnkPosDir) $ _rmLinks r
newLnks <- shuffle possibleLnks
return $ r {_rmLinks = newLnks ++ otherLnks}
{- | Swaps the last link in the list with one that satisfies a given
- property (it might swap with itself). Unsafe.
- Be careful about calling this after changeLinkFrom. -}