about summary refs log tree commit diff
path: root/src/Xanthous/App.hs
diff options
context:
space:
mode:
authorGriffin Smith <root@gws.fyi>2019-09-02T18·45-0400
committerGriffin Smith <root@gws.fyi>2019-09-02T18·45-0400
commit73a52e531d940858f0ac334d8b2ccda479ea7b5e (patch)
treefc7a953ddcb69691e2f734fa69f4585aff553e17 /src/Xanthous/App.hs
parent4d270712aecf1b61249086718852b96968de2bd8 (diff)
Put a test gormlak on the screen
Implement a concrete "Creature" entity, and place one on the screen at
the game startup for testing.

This revealed a bug with drawing when getting the maximum entity
position, but that appears to be fixed now (yay)
Diffstat (limited to 'src/Xanthous/App.hs')
-rw-r--r--src/Xanthous/App.hs38
1 files changed, 26 insertions, 12 deletions
diff --git a/src/Xanthous/App.hs b/src/Xanthous/App.hs
index 3561d35a3b..6cf22135a7 100644
--- a/src/Xanthous/App.hs
+++ b/src/Xanthous/App.hs
@@ -1,18 +1,25 @@
 module Xanthous.App (makeApp) where
 
-import Xanthous.Prelude
-import Brick hiding (App, halt, continue)
+import           Xanthous.Prelude
+import           Brick hiding (App, halt, continue, raw)
 import qualified Brick
-import Graphics.Vty.Attributes (defAttr)
-import Graphics.Vty.Input.Events (Event(EvKey))
-import Control.Monad.State (get)
+import           Graphics.Vty.Attributes (defAttr)
+import           Graphics.Vty.Input.Events (Event(EvKey))
+import           Control.Monad.State (get)
 
-import Xanthous.Game
-import Xanthous.Game.Draw (drawGame)
-import Xanthous.Resource (Name)
-import Xanthous.Command
-import Xanthous.Data (move)
-import Xanthous.Monad
+import           Xanthous.Command
+import           Xanthous.Data (move, Position(..))
+import qualified Xanthous.Data.EntityMap as EntityMap
+import           Xanthous.Game
+import           Xanthous.Game.Draw (drawGame)
+import           Xanthous.Monad
+import           Xanthous.Resource (Name)
+
+import           Xanthous.Entities.Creature (Creature)
+import qualified Xanthous.Entities.Creature as Creature
+import           Xanthous.Entities.RawTypes (EntityRaw(..))
+import           Xanthous.Entities.Raws (raw)
+import           Xanthous.Entities.SomeEntity
 
 type App = Brick.App GameState () Name
 type AppM a = AppT (EventM Name) a
@@ -29,8 +36,15 @@ makeApp = pure $ Brick.App
 runAppM :: AppM a -> GameState -> EventM Name a
 runAppM appm = fmap fst . runAppT appm
 
+testGormlak :: Creature
+testGormlak =
+  let Just (Creature gormlak) = raw "gormlak"
+  in Creature.newWithType gormlak
+
 startEvent :: AppM ()
-startEvent = say ["welcome"]
+startEvent = do
+  () <- say ["welcome"]
+  entities %= EntityMap.insertAt (Position 10 10) (SomeEntity testGormlak)
 
 handleEvent :: BrickEvent Name () -> AppM (Next GameState)
 handleEvent (VtyEvent (EvKey k mods))