diff options
author | Griffin Smith <grfn@gws.fyi> | 2021-11-13T15·44-0500 |
---|---|---|
committer | grfn <grfn@gws.fyi> | 2021-11-13T15·57+0000 |
commit | 1af67d9ca76e49198b8b8137e9fd24dfa4812203 (patch) | |
tree | 6abe4b3f80c894e317e7f35cff3d89adcc6c2d83 /users/grfn/xanthous/src/Xanthous/Generators/Level/LevelContents.hs | |
parent | e2f8939a9e5c1014bc8ffd415e5713b6f4f6ba47 (diff) |
feat(gs/xanthous): Add a Husk creature, with limited generation r/3061
Add a new "husk" creature raw, limited to only being generated on levels >= 1, including support for actually doing that limiting. These guys are gonna get daggers next! Change-Id: Ic4b58dc7ee36b50ced60fec6912cd1b46269d55c Reviewed-on: https://cl.tvl.fyi/c/depot/+/3868 Reviewed-by: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI
Diffstat (limited to 'users/grfn/xanthous/src/Xanthous/Generators/Level/LevelContents.hs')
-rw-r--r-- | users/grfn/xanthous/src/Xanthous/Generators/Level/LevelContents.hs | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/users/grfn/xanthous/src/Xanthous/Generators/Level/LevelContents.hs b/users/grfn/xanthous/src/Xanthous/Generators/Level/LevelContents.hs index 3cad569336e1..fcca118743e9 100644 --- a/users/grfn/xanthous/src/Xanthous/Generators/Level/LevelContents.hs +++ b/users/grfn/xanthous/src/Xanthous/Generators/Level/LevelContents.hs @@ -39,7 +39,7 @@ chooseCharacterPosition :: MonadRandom m => Cells -> m Position chooseCharacterPosition = randomPosition randomItems :: MonadRandom m => Cells -> m (EntityMap Item) -randomItems = randomEntities Item.newWithType (0.0004, 0.001) +randomItems = randomEntities (fmap Identity . Item.newWithType) (0.0004, 0.001) placeDownStaircase :: MonadRandom m => Cells -> m (EntityMap Staircase) placeDownStaircase cells = do @@ -76,8 +76,13 @@ randomDoors cells = do teeish (fmap not -> (Neighbors tl t tr l r _ b _ )) = and [tl, t, tr, b] && (and . fmap not) [l, r] -randomCreatures :: MonadRandom m => Cells -> m (EntityMap Creature) -randomCreatures = randomEntities Creature.newWithType (0.0007, 0.002) +randomCreatures + :: MonadRandom m + => Word -- ^ Level number, starting at 0 + -> Cells + -> m (EntityMap Creature) +randomCreatures levelNumber + = randomEntities (Creature.newOnLevelWithType levelNumber) (0.0007, 0.002) tutorialMessage :: MonadRandom m => Cells @@ -99,8 +104,8 @@ tutorialMessage cells characterPosition = do (circle (pos ^. _Position) dist) randomEntities - :: forall entity raw m. (MonadRandom m, RawType raw) - => (raw -> m entity) + :: forall entity raw m t. (MonadRandom m, RawType raw, Functor t, Foldable t) + => (raw -> m (t entity)) -> (Float, Float) -> Cells -> m (EntityMap entity) @@ -114,9 +119,9 @@ randomEntities newWithType sizeRange cells = entities <- for [0..numEntities] $ const $ do pos <- randomPosition cells raw <- choose raws - entity <- newWithType raw - pure (pos, entity) - pure $ _EntityMap # entities + entities <- newWithType raw + pure $ (pos, ) <$> entities + pure $ _EntityMap # (entities >>= toList) randomPosition :: MonadRandom m => Cells -> m Position randomPosition = fmap positionFromV2 . choose . impureNonNull . cellCandidates |