diff options
author | Griffin Smith <root@gws.fyi> | 2020-01-20T16·37-0500 |
---|---|---|
committer | Griffin Smith <root@gws.fyi> | 2020-01-20T16·37-0500 |
commit | 7082a4088ba06c825eb45f89888fed2f4577ed10 (patch) | |
tree | 0d4669b2d5e3815876ff1019a3f3c06e1e37304f /src/Xanthous/App.hs | |
parent | 72edcff32307ffebda07d350634792cc86b268bb (diff) |
Store revealed positions on the level itself
This was a bit of an oversight initially - we should be storing the positions that the character has seen *on the level*, rather than on the entire game state, for obvious reasons. This introduces a GameLevel record, which has this field, the entities, and also the up staircase position, which we can *also* use to position the character after going down to a level we've already visited.
Diffstat (limited to 'src/Xanthous/App.hs')
-rw-r--r-- | src/Xanthous/App.hs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/Xanthous/App.hs b/src/Xanthous/App.hs index 577466328101..1f7714da1d57 100644 --- a/src/Xanthous/App.hs +++ b/src/Xanthous/App.hs @@ -1,5 +1,6 @@ -{-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE ViewPatterns #-} {-# LANGUAGE UndecidableInstances #-} +{-# LANGUAGE RecordWildCards #-} -------------------------------------------------------------------------------- module Xanthous.App (makeApp) where -------------------------------------------------------------------------------- @@ -298,7 +299,7 @@ handleCommand GoDown = do then do levs <- use levels let newLevelNum = Levels.pos levs + 1 - levs' <- nextLevel (levelToEntityMap <$> genLevel newLevelNum) levs + levs' <- nextLevel (levelToGameLevel <$> genLevel newLevelNum) levs cEID <- use characterEntityID pCharacter <- entities . at cEID <<.= Nothing levels .= levs' @@ -600,3 +601,10 @@ genLevel _num = do Dungeon -> generateLevel SDungeon Dungeon.defaultParams dims characterPosition .= level ^. levelCharacterPosition pure $!! level + +levelToGameLevel :: Level -> GameLevel +levelToGameLevel level = + let _levelEntities = levelToEntityMap level + _upStaircasePosition = level ^. levelCharacterPosition + _levelRevealedPositions = mempty + in GameLevel {..} |