From 7341d8ff2be57592aac883ec18a68a658c552933 Mon Sep 17 00:00:00 2001 From: ben_singer Date: Thu, 14 Nov 2024 16:10:35 +0000 Subject: [PATCH] Fixed issue with map, help, about not showing --- NetAF.Tests/Commands/Global/About_Tests.cs | 4 ++-- NetAF.Tests/Commands/Global/Help_Tests.cs | 4 ++-- NetAF.Tests/Commands/Global/Map_Tests.cs | 4 ++-- NetAF/Assets/Interaction/ReactionResult.cs | 8 ++++++-- NetAF/Commands/Global/About.cs | 2 +- NetAF/Commands/Global/Help.cs | 2 +- NetAF/Commands/Global/Map.cs | 2 +- NetAF/Logic/Game.cs | 5 +++-- 8 files changed, 18 insertions(+), 13 deletions(-) diff --git a/NetAF.Tests/Commands/Global/About_Tests.cs b/NetAF.Tests/Commands/Global/About_Tests.cs index fa5abace..e1e2f4d4 100644 --- a/NetAF.Tests/Commands/Global/About_Tests.cs +++ b/NetAF.Tests/Commands/Global/About_Tests.cs @@ -23,7 +23,7 @@ public void GivenNullGame_WhenInvoke_ThenError() } [TestMethod] - public void GivenValidGame_WhenInvoke_ThenSilent() + public void GivenValidGame_WhenInvoke_ThenModeChanged() { var overworld = new Overworld(Identifier.Empty, Description.Empty); var region = new Region(Identifier.Empty, Description.Empty); @@ -35,7 +35,7 @@ public void GivenValidGame_WhenInvoke_ThenSilent() var result = command.Invoke(game); - Assert.AreEqual(ReactionResult.Silent, result.Result); + Assert.AreEqual(ReactionResult.ModeChanged, result.Result); } } } diff --git a/NetAF.Tests/Commands/Global/Help_Tests.cs b/NetAF.Tests/Commands/Global/Help_Tests.cs index 42de9414..66c8f256 100644 --- a/NetAF.Tests/Commands/Global/Help_Tests.cs +++ b/NetAF.Tests/Commands/Global/Help_Tests.cs @@ -23,7 +23,7 @@ public void GivenNullGame_WhenInvoke_ThenError() } [TestMethod] - public void GivenValidGame_WhenInvoke_ThenSilent() + public void GivenValidGame_WhenInvoke_ThenModeChanged() { var room = new Room(Identifier.Empty, Description.Empty); var character = new PlayableCharacter(Identifier.Empty, Description.Empty); @@ -39,7 +39,7 @@ public void GivenValidGame_WhenInvoke_ThenSilent() var result = command.Invoke(game); - Assert.AreEqual(ReactionResult.Silent, result.Result); + Assert.AreEqual(ReactionResult.ModeChanged, result.Result); } } } diff --git a/NetAF.Tests/Commands/Global/Map_Tests.cs b/NetAF.Tests/Commands/Global/Map_Tests.cs index 0335c84c..d289928c 100644 --- a/NetAF.Tests/Commands/Global/Map_Tests.cs +++ b/NetAF.Tests/Commands/Global/Map_Tests.cs @@ -22,7 +22,7 @@ public void GivenNullGame_WhenInvoke_ThenError() } [TestMethod] - public void GivenValidGame_WhenInvoke_ThenSilent() + public void GivenValidGame_WhenInvoke_ThenModeChanged() { var overworld = new Overworld(Identifier.Empty, Description.Empty); var region = new Region(Identifier.Empty, Description.Empty); @@ -34,7 +34,7 @@ public void GivenValidGame_WhenInvoke_ThenSilent() var result = command.Invoke(game); - Assert.AreEqual(ReactionResult.Silent, result.Result); + Assert.AreEqual(ReactionResult.ModeChanged, result.Result); } } } diff --git a/NetAF/Assets/Interaction/ReactionResult.cs b/NetAF/Assets/Interaction/ReactionResult.cs index 33fb7082..4b62b17e 100644 --- a/NetAF/Assets/Interaction/ReactionResult.cs +++ b/NetAF/Assets/Interaction/ReactionResult.cs @@ -6,11 +6,11 @@ public enum ReactionResult { /// - /// Error. + /// An error reaction. /// Error = 0, /// - /// OK. + /// An OK reaction. /// OK, /// @@ -18,6 +18,10 @@ public enum ReactionResult /// Silent, /// + /// A mode change reaction. + /// + ModeChanged, + /// /// A reaction that has a fatal effect on the player. /// Fatal diff --git a/NetAF/Commands/Global/About.cs b/NetAF/Commands/Global/About.cs index 7a136837..693e21e3 100644 --- a/NetAF/Commands/Global/About.cs +++ b/NetAF/Commands/Global/About.cs @@ -30,7 +30,7 @@ public Reaction Invoke(Logic.Game game) return new(ReactionResult.Error, "No game specified."); game.ChangeMode(new AboutMode()); - return new(ReactionResult.Silent, string.Empty); + return new(ReactionResult.ModeChanged, string.Empty); } #endregion diff --git a/NetAF/Commands/Global/Help.cs b/NetAF/Commands/Global/Help.cs index 86933093..c57395c8 100644 --- a/NetAF/Commands/Global/Help.cs +++ b/NetAF/Commands/Global/Help.cs @@ -40,7 +40,7 @@ .. game.Configuration.Interpreter.GetContextualCommandHelp(game), ]; game.ChangeMode(new HelpMode([.. commands.Distinct()])); - return new(ReactionResult.Silent, string.Empty); + return new(ReactionResult.ModeChanged, string.Empty); } #endregion diff --git a/NetAF/Commands/Global/Map.cs b/NetAF/Commands/Global/Map.cs index 5105c236..797ddcc1 100644 --- a/NetAF/Commands/Global/Map.cs +++ b/NetAF/Commands/Global/Map.cs @@ -31,7 +31,7 @@ public Reaction Invoke(Game game) return new(ReactionResult.Error, "No game specified."); game.ChangeMode(new RegionMapMode()); - return new(ReactionResult.Silent, string.Empty); + return new(ReactionResult.ModeChanged, string.Empty); } #endregion diff --git a/NetAF/Logic/Game.cs b/NetAF/Logic/Game.cs index 5250d17c..adcb22ea 100644 --- a/NetAF/Logic/Game.cs +++ b/NetAF/Logic/Game.cs @@ -165,9 +165,9 @@ internal void Execute() // display the reaction now DisplayReaction(reaction); } - else if (Mode.Type == GameModeType.Information) + else if (reaction.Result != ReactionResult.ModeChanged && Mode.Type == GameModeType.Information) { - // revert back to scene mode + // revert back to scene mode as the command didn't change the mode and the current mode is information, essentially the mode has expired ChangeMode(new SceneMode()); } @@ -359,6 +359,7 @@ private void DisplayReaction(Reaction reaction) ChangeMode(new ReactionMode(Overworld.CurrentRegion.CurrentRoom.Identifier.Name, message)); break; case ReactionResult.Silent: + case ReactionResult.ModeChanged: break; case ReactionResult.OK: case ReactionResult.Fatal: