Don't send the welcome message when loading

Don't re-send the welcome message when loading the game if it's already
been sent. This is done by just tracking whether or not we've sent it as
a boolean in the game state, which may be a bit of a hack but should be fine
This commit is contained in:
Griffin Smith 2019-12-23 18:10:22 -05:00
parent 32421916e0
commit 1351691136
4 changed files with 12 additions and 2 deletions

View file

@ -77,8 +77,12 @@ startEvent = do
Nothing -> prompt_ @'StringPrompt ["character", "namePrompt"] Uncancellable
$ \(StringResult s) -> do
character . characterName ?= s
say ["welcome"] =<< use character
Just n -> say ["welcome"] $ object [ "characterName" A..= n ]
whenM (uses sentWelcome not) $ say ["welcome"] =<< use character
sentWelcome .= True
Just n ->
whenM (uses sentWelcome not) $ do
say ["welcome"] $ object [ "characterName" A..= n ]
sentWelcome .= True
initLevel :: AppM ()
initLevel = do

View file

@ -28,6 +28,7 @@ instance Arbitrary GameState where
let _promptState = NoPrompt -- TODO
_activePanel <- arbitrary
_debugState <- arbitrary
_sentWelcome <- arbitrary
pure $ GameState {..}

View file

@ -50,6 +50,7 @@ initialStateFromSeed seed =
_debugState = DebugState
{ _allRevealed = False
}
_sentWelcome = False
in GameState {..}

View file

@ -11,6 +11,7 @@ module Xanthous.Game.State
, messageHistory
, randomGen
, activePanel
, sentWelcome
, promptState
, characterEntityID
, GamePromptState(..)
@ -405,6 +406,7 @@ data GameState = GameState
, _characterEntityID :: !EntityID
, _messageHistory :: !MessageHistory
, _randomGen :: !StdGen
, _sentWelcome :: Bool
-- | The active panel displayed in the UI, if any
, _activePanel :: !(Maybe Panel)
@ -425,6 +427,8 @@ instance Eq GameState where
, gs ^. revealedPositions
, gs ^. characterEntityID
, gs ^. messageHistory
, gs ^. sentWelcome
, gs ^. activePanel
)
--------------------------------------------------------------------------------