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 <grfn@gws.fyi>
Tested-by: BuildkiteCI
This commit is contained in:
Griffin Smith 2021-10-30 12:25:38 -04:00 committed by grfn
parent ddfea5aca0
commit 18315b2fb6

View file

@ -353,7 +353,13 @@ handleCommand GoUp = do
hasStairs <- uses entitiesAtCharacter $ elem (SomeEntity UpStaircase) hasStairs <- uses entitiesAtCharacter $ elem (SomeEntity UpStaircase)
if hasStairs if hasStairs
then uses levels prevLevel >>= \case 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 -> Nothing ->
-- TODO in nethack, this leaves the game. Maybe something similar here? -- TODO in nethack, this leaves the game. Maybe something similar here?
say_ ["cant", "goUp"] say_ ["cant", "goUp"]