From d8bd8e7eea5dcef4901bee14b8fe3027fd8605ac Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Sat, 19 Jun 2021 11:49:20 -0400 Subject: feat(xanthous) Generate random volume+density for items Generate random volumes and densities for items based on the ranges for those two quantities in the raw when building instances of items. Since this is the first time creating an item is impure, this also lifts entity generation into a (random) monadic context Change-Id: I2de4880e8144f7ff9e1304eb32806ed1d7affa18 Reviewed-on: https://cl.tvl.fyi/c/depot/+/3226 Reviewed-by: grfn Tested-by: BuildkiteCI --- users/grfn/xanthous/src/Xanthous/Generators/Level/LevelContents.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'users/grfn/xanthous/src/Xanthous/Generators/Level/LevelContents.hs') diff --git a/users/grfn/xanthous/src/Xanthous/Generators/Level/LevelContents.hs b/users/grfn/xanthous/src/Xanthous/Generators/Level/LevelContents.hs index 7582ae275892..3cad569336e1 100644 --- a/users/grfn/xanthous/src/Xanthous/Generators/Level/LevelContents.hs +++ b/users/grfn/xanthous/src/Xanthous/Generators/Level/LevelContents.hs @@ -100,7 +100,7 @@ tutorialMessage cells characterPosition = do randomEntities :: forall entity raw m. (MonadRandom m, RawType raw) - => (raw -> entity) + => (raw -> m entity) -> (Float, Float) -> Cells -> m (EntityMap entity) @@ -114,7 +114,7 @@ randomEntities newWithType sizeRange cells = entities <- for [0..numEntities] $ const $ do pos <- randomPosition cells raw <- choose raws - let entity = newWithType raw + entity <- newWithType raw pure (pos, entity) pure $ _EntityMap # entities -- cgit 1.4.1