about summary refs log tree commit diff
path: root/users/grfn/xanthous/src
diff options
context:
space:
mode:
authorGriffin Smith <grfn@gws.fyi>2021-10-30T16·25-0400
committergrfn <grfn@gws.fyi>2021-10-30T17·16+0000
commit18315b2fb60a59a1f4e1b6f91423f34aa580f99a (patch)
tree4e2e028d15398d55bd5738b8bbea99d473bdcd7f /users/grfn/xanthous/src
parentddfea5aca0d227f560fcbb4034a34f28ae40dd08 (diff)
fix(gs/xanthous): Preserve character state when going up stairs r/2996
Carry over everything except the character's position when going up
stairs, so that eg the character doesn't lose everything they picked up
and instantly heal to full when going up a level.

Change-Id: I08513578a72f2410a363bbadbb273d95826a3f1b
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3766
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
Diffstat (limited to 'users/grfn/xanthous/src')
-rw-r--r--users/grfn/xanthous/src/Xanthous/App.hs8
1 files changed, 7 insertions, 1 deletions
diff --git a/users/grfn/xanthous/src/Xanthous/App.hs b/users/grfn/xanthous/src/Xanthous/App.hs
index 689a6a35ca30..bb6d6cf4ddda 100644
--- a/users/grfn/xanthous/src/Xanthous/App.hs
+++ b/users/grfn/xanthous/src/Xanthous/App.hs
@@ -353,7 +353,13 @@ handleCommand GoUp = do
   hasStairs <- uses entitiesAtCharacter $ elem (SomeEntity UpStaircase)
   if hasStairs
   then uses levels prevLevel >>= \case
-    Just levs' -> levels .= levs'
+    Just levs' -> do
+      cEID <- use characterEntityID
+      pCharacter <- entities . at cEID <<.= Nothing
+      levels .= levs'
+      charPos <- use characterPosition
+      entities . at cEID .= pCharacter
+      characterPosition .= charPos
     Nothing ->
       -- TODO in nethack, this leaves the game. Maybe something similar here?
       say_ ["cant", "goUp"]