about summary refs log tree commit diff
path: root/src/Xanthous/Generators.hs
diff options
context:
space:
mode:
authorGriffin Smith <root@gws.fyi>2019-09-21T16·43-0400
committerGriffin Smith <root@gws.fyi>2019-09-21T16·43-0400
commitd632a30d057f9a2775c4516570168b195c053879 (patch)
tree3bfebac7b14567edfb11d3917e9b2fd9114becb9 /src/Xanthous/Generators.hs
parentdd1616666593f65bab70f1363b5d040fe5edd054 (diff)
Implement combat
Put a bunch of gormlaks randomly on the level, and implement combat via
damaging those gormlaks by one point.
Diffstat (limited to 'src/Xanthous/Generators.hs')
-rw-r--r--src/Xanthous/Generators.hs15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/Xanthous/Generators.hs b/src/Xanthous/Generators.hs
index 832a3d8fdc1d..7bcf4da0515e 100644
--- a/src/Xanthous/Generators.hs
+++ b/src/Xanthous/Generators.hs
@@ -12,6 +12,7 @@ module Xanthous.Generators
   , Level(..)
   , levelWalls
   , levelItems
+  , levelCreatures
   , levelCharacterPosition
   , generateLevel
   ) where
@@ -29,7 +30,8 @@ import           Xanthous.Data (Dimensions, Position(Position))
 import           Xanthous.Data.EntityMap (EntityMap)
 import qualified Xanthous.Data.EntityMap as EntityMap
 import           Xanthous.Entities.Environment
-import           Xanthous.Entities.Item
+import           Xanthous.Entities.Item (Item)
+import           Xanthous.Entities.Creature (Creature)
 --------------------------------------------------------------------------------
 
 data Generator = CaveAutomata
@@ -38,9 +40,6 @@ data Generator = CaveAutomata
 data SGenerator (gen :: Generator) where
   SCaveAutomata :: SGenerator 'CaveAutomata
 
-data AGenerator where
-  AGenerator :: forall gen. SGenerator gen -> AGenerator
-
 type family Params (gen :: Generator) :: Type where
   Params 'CaveAutomata = CaveAutomata.Params
 
@@ -89,9 +88,10 @@ cellsToWalls cells = foldl' maybeInsertWall mempty . assocs $ cells
 --------------------------------------------------------------------------------
 
 data Level = Level
-  { _levelWalls :: EntityMap Wall
-  , _levelItems :: EntityMap Item
-  , _levelCharacterPosition :: Position
+  { _levelWalls             :: !(EntityMap Wall)
+  , _levelItems             :: !(EntityMap Item)
+  , _levelCreatures         :: !(EntityMap Creature)
+  , _levelCharacterPosition :: !Position
   }
 makeLenses ''Level
 
@@ -101,5 +101,6 @@ generateLevel gen ps dims = do
   let cells = generate gen ps dims rand
       _levelWalls = cellsToWalls cells
   _levelItems <- randomItems cells
+  _levelCreatures <- randomCreatures cells
   _levelCharacterPosition <- chooseCharacterPosition cells
   pure Level {..}