Skip to content

Commit

Permalink
Fixed issue with map, help, about not showing
Browse files Browse the repository at this point in the history
  • Loading branch information
ben_singer committed Nov 14, 2024
1 parent a78087f commit 7341d8f
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 13 deletions.
4 changes: 2 additions & 2 deletions NetAF.Tests/Commands/Global/About_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
}
}
4 changes: 2 additions & 2 deletions NetAF.Tests/Commands/Global/Help_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
}
}
4 changes: 2 additions & 2 deletions NetAF.Tests/Commands/Global/Map_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
}
}
8 changes: 6 additions & 2 deletions NetAF/Assets/Interaction/ReactionResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,22 @@
public enum ReactionResult
{
/// <summary>
/// Error.
/// An error reaction.
/// </summary>
Error = 0,
/// <summary>
/// OK.
/// An OK reaction.
/// </summary>
OK,
/// <summary>
/// A silent reaction.
/// </summary>
Silent,
/// <summary>
/// A mode change reaction.
/// </summary>
ModeChanged,
/// <summary>
/// A reaction that has a fatal effect on the player.
/// </summary>
Fatal
Expand Down
2 changes: 1 addition & 1 deletion NetAF/Commands/Global/About.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion NetAF/Commands/Global/Help.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion NetAF/Commands/Global/Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions NetAF/Logic/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 7341d8f

Please sign in to comment.