Allow arbitrary changes to a room when using a link slot

This commit is contained in:
2021-11-14 01:47:33 +00:00
parent 4a089ff0cc
commit 52946f33a7
10 changed files with 55 additions and 18 deletions
+6 -2
View File
@@ -48,19 +48,23 @@ placeSpot (w,rm) plmnt = case plmnt of
where
shift = _rmShift rm
-- this should be tidied up
placeSpotUsingLink :: World -> Room -> Placement -> ((World, Room), [Placement])
placeSpotUsingLink w rm plmnt = case lnks of
((lnki,lnk):_) -> placeSpot (w & randGen .~ g,uselnk lnki) (updatePS (f lnk) plmnt)
((lnki,lnk):_) -> placeSpot (w & randGen .~ g,uselnk lnki lnk) (updatePS (f lnk) plmnt)
[] -> case fallback of
Nothing -> ((w,rm),[plmnt])
Just plmnt' -> placeSpot (w,rm) plmnt'
where
uselnk lnki = rm & rmLinks %~ deletei lnki
uselnk lnki lnk = _psLnkRoomEff rps (f' lnk rps) rm & rmLinks %~ deletei lnki
rps = _plSpot plmnt
fallback = _psLnkFallback rps
test = _psLnkTest rps
(lnks,g) = runState (shuffle $ filter (test . snd) $ zip [0..]
$ map (invShiftLinkBy $ _rmShift rm) $ _rmLinks rm) $ _randGen w
f' x (PSLnk t s _ _)
| t x = s x
f' _ _ = error "wrong type of link: something is wrong"
f x (PSLnk t s _ _)
| t x = uncurry PS $ s x
f _ ps = ps