From 72edcff32307ffebda07d350634792cc86b268bb Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Mon, 20 Jan 2020 10:31:02 -0500 Subject: Put new levels at the right position in the list New levels need to go at the *end* of the list of levels, not the beginning - otherwise we jump to the proper position on the new level but the current level stays the same (oops). --- src/Xanthous/App.hs | 3 +-- src/Xanthous/Data/Levels.hs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Xanthous/App.hs b/src/Xanthous/App.hs index 2fd821af1c..5774663281 100644 --- a/src/Xanthous/App.hs +++ b/src/Xanthous/App.hs @@ -300,8 +300,7 @@ handleCommand GoDown = do let newLevelNum = Levels.pos levs + 1 levs' <- nextLevel (levelToEntityMap <$> genLevel newLevelNum) levs cEID <- use characterEntityID - pCharacter <- use $ entities . at cEID - entities . at cEID .= Nothing + pCharacter <- entities . at cEID <<.= Nothing levels .= levs' entities . at cEID .= pCharacter else say_ ["cant", "goDown"] diff --git a/src/Xanthous/Data/Levels.hs b/src/Xanthous/Data/Levels.hs index 5fc3f93341..efc0f53ace 100644 --- a/src/Xanthous/Data/Levels.hs +++ b/src/Xanthous/Data/Levels.hs @@ -102,7 +102,7 @@ nextLevel genLevel levs = pure $ seeks succ levs | otherwise = genLevel <&> \level -> - seek (pos levs + 1) . partialMkLevels $ level <| allLevels levs + seek (pos levs + 1) . partialMkLevels $ allLevels levs |> level -- | Go to the previous level. Returns Nothing if 'pos' is 0 prevLevel :: Levels level -> Maybe (Levels level) -- cgit 1.4.1