Skip to content

Commit

Permalink
Fixed build error
Browse files Browse the repository at this point in the history
  • Loading branch information
ben_singer committed Nov 18, 2024
1 parent ab3000e commit a2daa51
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
3 changes: 2 additions & 1 deletion NetAF.Tests/Logic/Game_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NetAF.Logic.Modes;
using NetAF.Logic.Configuration;
using NetAF.Commands;

namespace NetAF.Tests.Logic
{
Expand Down Expand Up @@ -145,7 +146,7 @@ public void GivenSimpleGame_WhenChangeModeToTransition_ThenNoExceptionThrown()
OverworldMaker overworldMaker = new(string.Empty, string.Empty, regionMaker);
var game = Game.Create(new(string.Empty, string.Empty, string.Empty), string.Empty, AssetGenerator.Retained(overworldMaker.Make(), new PlayableCharacter(string.Empty, string.Empty)), GameEndConditions.NoEnd, TestGameConfiguration.Default).Invoke();
game.ChangeMode(new ReactionMode("Test", "Test"));
game.ChangeMode(new ReactionMode("Test", Reaction.Inform));
});
}

Expand Down
3 changes: 2 additions & 1 deletion NetAF.Tests/Logic/Modes/ReactionMode_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using NetAF.Assets.Locations;
using NetAF.Utilities;
using NetAF.Logic.Modes;
using NetAF.Commands;

namespace NetAF.Tests.Logic.Modes
{
Expand All @@ -20,7 +21,7 @@ public void GivenNew_WhenRenderWithNonEmptyString_ThenNoExceptionThrown()
regionMaker[0, 0, 0] = room;
OverworldMaker overworldMaker = new(string.Empty, string.Empty, regionMaker);
var game = Game.Create(new(string.Empty, string.Empty, string.Empty), string.Empty, AssetGenerator.Retained(overworldMaker.Make(), new PlayableCharacter(string.Empty, string.Empty)), GameEndConditions.NoEnd, TestGameConfiguration.Default).Invoke();
var mode = new ReactionMode(string.Empty, "a");
var mode = new ReactionMode(string.Empty, new Reaction(ReactionResult.Inform, "a"));
mode.Render(game);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,28 @@ namespace NetAF.Tests.Rendering.FrameBuilders.Console
public class ConsoleReactionFrameBuilder_Tests
{
[TestMethod]
public void GivenDefaults_WhenBuild_ThenNoException()
public void GivenDefaultsAndRenderErrorMessage_WhenBuild_ThenNoException()
{
Assertions.NoExceptionThrown(() =>
{
var gridStringBuilder = new GridStringBuilder();
var builder = new ConsoleReactionFrameBuilder(gridStringBuilder);
builder.Build(string.Empty, string.Empty, new Size(80, 50));
builder.Build(string.Empty, string.Empty, true, new Size(80, 50));
});
}

[TestMethod]
public void GivenDefaultsAndRenderNonMessage_WhenBuild_ThenNoException()
{
Assertions.NoExceptionThrown(() =>
{
var gridStringBuilder = new GridStringBuilder();
var builder = new ConsoleReactionFrameBuilder(gridStringBuilder);
builder.Build(string.Empty, string.Empty, false, new Size(80, 50));
});
}

}
}
2 changes: 1 addition & 1 deletion NetAF/Logic/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private void HandleReaction(Reaction reaction)
if (reaction.Result == ReactionResult.Error || reaction.Result == ReactionResult.Inform)
{
// display the reaction
ChangeMode(new ReactionMode(Overworld.CurrentRegion.CurrentRoom.Identifier.Name, reaction.Description));
ChangeMode(new ReactionMode(Overworld.CurrentRegion.CurrentRoom.Identifier.Name, reaction));
}
else if (reaction.Result != ReactionResult.GameModeChanged && Mode.Type == GameModeType.Information)
{
Expand Down
10 changes: 5 additions & 5 deletions NetAF/Logic/Modes/ReactionMode.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using NetAF.Interpretation;
using NetAF.Commands;
using NetAF.Interpretation;

namespace NetAF.Logic.Modes
{
/// <summary>
/// Provides a display mode for reaction.
/// </summary>
/// <param name="title">The title.</param>
/// <param name="message">The message.</param>
/// <param name="isError">If the message is an error..</param>
public sealed class ReactionMode(string title, string message, bool isError) : IGameMode
/// <param name="reaction">The reaction.</param>
public sealed class ReactionMode(string title, Reaction reaction) : IGameMode
{
#region Implementation of IGameMode

Expand All @@ -28,7 +28,7 @@ public sealed class ReactionMode(string title, string message, bool isError) : I
/// <param name="game">The game.</param>
public void Render(Game game)
{
var frame = game.Configuration.FrameBuilders.ReactionModeFrameBuilder.Build(title, message, isError, game.Configuration.DisplaySize);
var frame = game.Configuration.FrameBuilders.ReactionModeFrameBuilder.Build(title, reaction.Description, reaction.Result == ReactionResult.Error, game.Configuration.DisplaySize);
game.Configuration.Adapter.RenderFrame(frame);
}

Expand Down

0 comments on commit a2daa51

Please sign in to comment.