From eeafd0fa0ed85957f0609863d1d06b570c55341b Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Sat, 6 Nov 2021 12:24:10 -0400 Subject: fix(gs/xanthous): Don't gen dupe tutorial messages Don't generate tutorial messages on levels other than the first. Change-Id: I7681377461b92f5d5015931b0088bef9d358d2e4 Reviewed-on: https://cl.tvl.fyi/c/depot/+/3804 Reviewed-by: grfn Tested-by: BuildkiteCI --- users/grfn/xanthous/src/Xanthous/App.hs | 10 ++++++---- users/grfn/xanthous/src/Xanthous/Generators/Level.hs | 10 +++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/users/grfn/xanthous/src/Xanthous/App.hs b/users/grfn/xanthous/src/Xanthous/App.hs index bf6a63e086ce..9318c713478b 100644 --- a/users/grfn/xanthous/src/Xanthous/App.hs +++ b/users/grfn/xanthous/src/Xanthous/App.hs @@ -568,12 +568,14 @@ showPanel panel = do genLevel :: Word -- ^ Level number, starting at 0 -> AppM Level -genLevel _num = do +genLevel num = do let dims = Dimensions 80 80 generator <- choose $ CaveAutomata :| [Dungeon] - level <- case generator of - CaveAutomata -> generateLevel SCaveAutomata CaveAutomata.defaultParams dims - Dungeon -> generateLevel SDungeon Dungeon.defaultParams dims + let + doGen = case generator of + CaveAutomata -> generateLevel SCaveAutomata CaveAutomata.defaultParams + Dungeon -> generateLevel SDungeon Dungeon.defaultParams + level <- doGen dims num pure $!! level levelToGameLevel :: Level -> GameLevel diff --git a/users/grfn/xanthous/src/Xanthous/Generators/Level.hs b/users/grfn/xanthous/src/Xanthous/Generators/Level.hs index 81f21f55ff00..ac97159f422c 100644 --- a/users/grfn/xanthous/src/Xanthous/Generators/Level.hs +++ b/users/grfn/xanthous/src/Xanthous/Generators/Level.hs @@ -85,7 +85,7 @@ parseGeneratorInput = Opt.subparser generatorCommand sgen name desc parseParams = Opt.command name (Opt.info - (GeneratorInput <$> pure sgen <*> parseParams) + (GeneratorInput sgen <$> parseParams) (Opt.progDesc desc) ) @@ -132,8 +132,9 @@ generateLevel => SGenerator gen -> Params gen -> Dimensions + -> Word -- ^ Level number, starting at 0 -> m Level -generateLevel gen ps dims = do +generateLevel gen ps dims num = do rand <- mkStdGen <$> getRandom let cells = generate gen ps dims rand _levelWalls = cellsToWalls cells @@ -146,7 +147,10 @@ generateLevel gen ps dims = do let upStaircase = _EntityMap # [(_levelCharacterPosition, UpStaircase)] downStaircase <- placeDownStaircase cells let _levelStaircases = upStaircase <> downStaircase - _levelTutorialMessage <- tutorialMessage cells _levelCharacterPosition + _levelTutorialMessage <- + if num == 0 + then tutorialMessage cells _levelCharacterPosition + else pure mempty pure Level {..} levelToEntityMap :: Level -> EntityMap SomeEntity -- cgit 1.4.1