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:
parent
32421916e0
commit
1351691136
4 changed files with 12 additions and 2 deletions
|
@ -77,8 +77,12 @@ startEvent = do
|
||||||
Nothing -> prompt_ @'StringPrompt ["character", "namePrompt"] Uncancellable
|
Nothing -> prompt_ @'StringPrompt ["character", "namePrompt"] Uncancellable
|
||||||
$ \(StringResult s) -> do
|
$ \(StringResult s) -> do
|
||||||
character . characterName ?= s
|
character . characterName ?= s
|
||||||
say ["welcome"] =<< use character
|
whenM (uses sentWelcome not) $ say ["welcome"] =<< use character
|
||||||
Just n -> say ["welcome"] $ object [ "characterName" A..= n ]
|
sentWelcome .= True
|
||||||
|
Just n ->
|
||||||
|
whenM (uses sentWelcome not) $ do
|
||||||
|
say ["welcome"] $ object [ "characterName" A..= n ]
|
||||||
|
sentWelcome .= True
|
||||||
|
|
||||||
initLevel :: AppM ()
|
initLevel :: AppM ()
|
||||||
initLevel = do
|
initLevel = do
|
||||||
|
|
|
@ -28,6 +28,7 @@ instance Arbitrary GameState where
|
||||||
let _promptState = NoPrompt -- TODO
|
let _promptState = NoPrompt -- TODO
|
||||||
_activePanel <- arbitrary
|
_activePanel <- arbitrary
|
||||||
_debugState <- arbitrary
|
_debugState <- arbitrary
|
||||||
|
_sentWelcome <- arbitrary
|
||||||
pure $ GameState {..}
|
pure $ GameState {..}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ initialStateFromSeed seed =
|
||||||
_debugState = DebugState
|
_debugState = DebugState
|
||||||
{ _allRevealed = False
|
{ _allRevealed = False
|
||||||
}
|
}
|
||||||
|
_sentWelcome = False
|
||||||
in GameState {..}
|
in GameState {..}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ module Xanthous.Game.State
|
||||||
, messageHistory
|
, messageHistory
|
||||||
, randomGen
|
, randomGen
|
||||||
, activePanel
|
, activePanel
|
||||||
|
, sentWelcome
|
||||||
, promptState
|
, promptState
|
||||||
, characterEntityID
|
, characterEntityID
|
||||||
, GamePromptState(..)
|
, GamePromptState(..)
|
||||||
|
@ -405,6 +406,7 @@ data GameState = GameState
|
||||||
, _characterEntityID :: !EntityID
|
, _characterEntityID :: !EntityID
|
||||||
, _messageHistory :: !MessageHistory
|
, _messageHistory :: !MessageHistory
|
||||||
, _randomGen :: !StdGen
|
, _randomGen :: !StdGen
|
||||||
|
, _sentWelcome :: Bool
|
||||||
|
|
||||||
-- | The active panel displayed in the UI, if any
|
-- | The active panel displayed in the UI, if any
|
||||||
, _activePanel :: !(Maybe Panel)
|
, _activePanel :: !(Maybe Panel)
|
||||||
|
@ -425,6 +427,8 @@ instance Eq GameState where
|
||||||
, gs ^. revealedPositions
|
, gs ^. revealedPositions
|
||||||
, gs ^. characterEntityID
|
, gs ^. characterEntityID
|
||||||
, gs ^. messageHistory
|
, gs ^. messageHistory
|
||||||
|
, gs ^. sentWelcome
|
||||||
|
, gs ^. activePanel
|
||||||
)
|
)
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue