From 18315b2fb60a59a1f4e1b6f91423f34aa580f99a Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Sat, 30 Oct 2021 12:25:38 -0400 Subject: [PATCH] fix(gs/xanthous): Preserve character state when going up stairs 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 Tested-by: BuildkiteCI --- users/grfn/xanthous/src/Xanthous/App.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/users/grfn/xanthous/src/Xanthous/App.hs b/users/grfn/xanthous/src/Xanthous/App.hs index 689a6a35c..bb6d6cf4d 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"]