about summary refs log tree commit diff
path: root/src/Xanthous/App.hs
diff options
context:
space:
mode:
authorGriffin Smith <root@gws.fyi>2020-05-11T00·26-0400
committerGriffin Smith <root@gws.fyi>2020-05-11T00·26-0400
commitce3730ba3a5831e590dd9cc037649eb49e2f0804 (patch)
tree80af1801baedcc8543521ddfed048fb0fc304ee8 /src/Xanthous/App.hs
parentb64dd08c6ec5f68539c6b4159b10d960e8e96bc3 (diff)
Small chance of hurting self when punching
When attacking monsters with bare fists, there is a small chance (8%,
right now) of causing 1 point of self-damage
Diffstat (limited to 'src/Xanthous/App.hs')
-rw-r--r--src/Xanthous/App.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Xanthous/App.hs b/src/Xanthous/App.hs
index 24073c51097a..ea1405e463fe 100644
--- a/src/Xanthous/App.hs
+++ b/src/Xanthous/App.hs
@@ -548,9 +548,16 @@ attackAt pos =
         msg <- uses character getAttackMessage
         message msg msgParams
         entities . ix creatureID . positioned .= SomeEntity creature'
+
+    whenM (uses character $ isNothing . weapon)
+      $ whenM (chance (0.08 :: Float)) $ do
+        say_ ["combat", "fistSelfDamage"]
+        character %= Character.damage 1
+
     stepGame -- TODO
+  weapon chr = chr ^? inventory . wielded . wieldedItems . wieldableItem
   getAttackMessage chr =
-    case chr ^? inventory . wielded . wieldedItems . wieldableItem of
+    case weapon chr of
       Just wi ->
         fromMaybe (Messages.lookup ["combat", "hit", "generic"])
         $ wi ^. attackMessage