Test of lock and key system

This commit is contained in:
2021-11-22 23:54:58 +00:00
parent 05e1307336
commit 5ab5be3087
11 changed files with 84 additions and 20 deletions
+14 -7
View File
@@ -11,7 +11,8 @@ import Dodge.Annotation.Data
import Data.Tree
import Control.Monad.State
import System.Random
import Control.Lens
--import Control.Lens
import Data.Maybe
addLock :: RandomGen g => Int -> Tree [Annotation g] -> State g (Tree [Annotation g])
addLock i t = do
@@ -43,15 +44,21 @@ roomThenCorridor theRoom = fmap (\r -> Node (PassDown theRoom) [(pure . UseAll)
anoToRoomTree :: RandomGen g => [Annotation g] -> State g (SubCompTree Room)
anoToRoomTree anos = case anos of
[AnoApplyInt i f] -> f i
[SetLabel i randrm] -> do
rm <- randrm
return . singleUseAll $ rm & rmLabel ?~ i
[UseLabel i randrm] -> do
rm <- randrm
return $ singleUseAll $ rm & rmTakeFrom ?~ i
-- [SetLabel i randrm] -> do
-- rm <- randrm
-- return . singleUseAll $ rm & rmLabel ?~ i
-- [UseLabel i randrm] -> do
-- rm <- randrm
-- return $ singleUseAll $ rm & rmTakeFrom ?~ i
[ChainAnos ass] -> do
rms <- mapM anoToRoomTree ass
return $ chainUses rms
[PassthroughLockKeyLists i ls ks] -> do
(functionlockroom,randomitemidentity) <- takeOne ls
lr <- functionlockroom i
ii <- randomitemidentity
keyroom <- fromJust $ lookup ii ks
return $ overwriteLabel 0 UseNone lr [keyroom]
[OrAno as] -> do
a <- takeOne as
anoToRoomTree a