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-29T14·54-0400
committerGriffin Smith <root@gws.fyi>2019-09-29T14·54-0400
commit05da490185e970b2cfdf6c61f69932fa373993f6 (patch)
tree0fa9be2182e1359ce39d600089f6937bfdccd3aa /src/Xanthous/App.hs
parentec39dc0a5bed58e0b0b48eeac98e0fd0ceaa65db (diff)
Gormlaks attack back
When gormlaks see the character, they step towards them and attack
dealing 1 damage when adjacent. Characters have hitpoints now, displayed
at the bottom of the game screen, and when the game is over they die.
Diffstat (limited to 'src/Xanthous/App.hs')
-rw-r--r--src/Xanthous/App.hs11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/Xanthous/App.hs b/src/Xanthous/App.hs
index 1632c39e586d..02f6f0987d7c 100644
--- a/src/Xanthous/App.hs
+++ b/src/Xanthous/App.hs
@@ -13,6 +13,7 @@ import           Control.Monad.Random (MonadRandom)
 import           Control.Monad.State.Class (modify)
 import           Data.Aeson (object, ToJSON)
 import qualified Data.Aeson as A
+import           System.Exit
 --------------------------------------------------------------------------------
 import           Xanthous.Command
 import           Xanthous.Data
@@ -32,13 +33,12 @@ import           Xanthous.Messages (message)
 import           Xanthous.Util.Inflection (toSentence)
 --------------------------------------------------------------------------------
 import qualified Xanthous.Entities.Character as Character
-import           Xanthous.Entities.Character (characterName)
+import           Xanthous.Entities.Character
 import           Xanthous.Entities
 import           Xanthous.Entities.Item (Item)
 import           Xanthous.Entities.Creature (Creature)
 import qualified Xanthous.Entities.Creature as Creature
 import           Xanthous.Entities.Environment (Door, open, locked)
-import           Xanthous.Entities.Character
 import           Xanthous.Generators
 import qualified Xanthous.Generators.CaveAutomata as CaveAutomata
 --------------------------------------------------------------------------------
@@ -87,6 +87,11 @@ stepGame = do
     pEntity' <- step pEntity
     entities . ix eid .= pEntity'
 
+  whenM (uses (character . characterHitpoints) (== 0))
+    . prompt_ @'Continue ["dead"] Uncancellable
+    . const . lift . liftIO
+    $ exitSuccess
+
 --------------------------------------------------------------------------------
 
 handleEvent :: BrickEvent Name () -> AppM (Next GameState)
@@ -189,6 +194,8 @@ handlePromptEvent _ (Prompt _ SDirectionPrompt _ cb)
     continue
 handlePromptEvent _ (Prompt _ SDirectionPrompt _ _) _ = continue
 
+handlePromptEvent _ (Prompt _ SContinue _ _) _ = continue
+
 handlePromptEvent _ _ _ = undefined
 
 prompt