From 4d2402a64ec3ca28e87ebc264f2064f310ca68f5 Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Fri, 18 Jun 2021 13:04:43 -0400 Subject: feat(xanthous): Add an auto-rest command Add a command that automatically rests (essentially just stepping the game forwards) until the character's hitpoints are back to full. Currently due to the time it takes for the character to heal this takes a bit too long - my thought there is to make the per-step delay for autocommands different depending on the specific autocommand. Change-Id: I40378c29d3d9d19e9787af1f015bde65fd08868c Reviewed-on: https://cl.tvl.fyi/c/depot/+/3221 Reviewed-by: grfn Tested-by: BuildkiteCI --- users/grfn/xanthous/src/Xanthous/Entities/Character.hs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'users/grfn/xanthous/src/Xanthous/Entities/Character.hs') diff --git a/users/grfn/xanthous/src/Xanthous/Entities/Character.hs b/users/grfn/xanthous/src/Xanthous/Entities/Character.hs index c18d726a4bfd..f27ed1e475d6 100644 --- a/users/grfn/xanthous/src/Xanthous/Entities/Character.hs +++ b/users/grfn/xanthous/src/Xanthous/Entities/Character.hs @@ -32,6 +32,7 @@ module Xanthous.Entities.Character , mkCharacter , pickUpItem , isDead + , isFullyHealed , damage ) where -------------------------------------------------------------------------------- @@ -264,6 +265,11 @@ characterDamage = fromMaybe defaultCharacterDamage . preview (inventory . wielded . wieldedItems . wieldableItem . Raw.damage) +-- | Is the character fully healed up to or past their initial hitpoints? +isFullyHealed :: Character -> Bool +isFullyHealed = (>= initialHitpoints) . characterHitpoints + +-- | Is the character dead? isDead :: Character -> Bool isDead = (== 0) . characterHitpoints -- cgit 1.4.1