Skip to content

Commit

Permalink
Merge pull request #96 from benpollarduk/refactor
Browse files Browse the repository at this point in the history
Refactor
  • Loading branch information
benpollarduk authored Nov 16, 2024
2 parents ee256e5 + 6a04790 commit da359c3
Show file tree
Hide file tree
Showing 57 changed files with 104 additions and 108 deletions.
5 changes: 3 additions & 2 deletions NetAF.Examples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using NetAF.Examples.Assets.Regions.Zelda.Rooms;
using NetAF.Extensions;
using NetAF.Logic;
using NetAF.Logic.Configuration;

namespace NetAF.Examples
{
Expand Down Expand Up @@ -51,7 +52,7 @@ private static void PopulateHub(Region hub, Overworld overworld, Region[] otherR
if (!move)
return new Reaction(ReactionResult.Error, $"Could not move to {otherRegion.Identifier.Name}.");
return new Reaction(ReactionResult.OK, $"You peer inside the sphere and feel faint. When the sensation passes you open you eyes and have been transported to the {otherRegion.Identifier.Name}.");
return new Reaction(ReactionResult.Inform, $"You peer inside the sphere and feel faint. When the sensation passes you open you eyes and have been transported to the {otherRegion.Identifier.Name}.");
})
];

Expand Down Expand Up @@ -93,7 +94,7 @@ static Overworld overworldCreator()
if (!result)
return new(ReactionResult.Error, $"Failed to jump to {x} {y} {z}.");
return new(ReactionResult.OK, $"Jumped to {x} {y} {z}.");
return new(ReactionResult.Inform, $"Jumped to {x} {y} {z}.");
}),
new Save(),
new Load()
Expand Down
6 changes: 3 additions & 3 deletions NetAF.Tests/Assets/ExaminableObject_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void GivenExamine_WhenDefaultExaminationWith1CustomCommand_ThenCustomComm
{
CustomCommand[] commands =
[
new CustomCommand(new CommandHelp("Test Command", "Test Command Description."), true, true, (_, _) => new Reaction(ReactionResult.OK, ""))
new CustomCommand(new CommandHelp("Test Command", "Test Command Description."), true, true, (_, _) => new Reaction(ReactionResult.Inform, ""))
];

var i = new Item("Test", "Test Description.", commands: commands);
Expand All @@ -38,8 +38,8 @@ public void GivenExamine_WhenDefaultExaminationWith2CustomCommands_ThenCustomCom
{
CustomCommand[] commands =
[
new CustomCommand(new CommandHelp("A*", "Test Command Description."), true, true, (_, _) => new Reaction(ReactionResult.OK, "")),
new CustomCommand(new CommandHelp("B*", "Test Command Description."), true, true, (_, _) => new Reaction(ReactionResult.OK, ""))
new CustomCommand(new CommandHelp("A*", "Test Command Description."), true, true, (_, _) => new Reaction(ReactionResult.Inform, "")),
new CustomCommand(new CommandHelp("B*", "Test Command Description."), true, true, (_, _) => new Reaction(ReactionResult.Inform, ""))
];

var i = new Item("Test", "Test Description.", commands: commands);
Expand Down
4 changes: 2 additions & 2 deletions NetAF.Tests/Commands/Frame/CommandsOff_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ public void GivenNullGame_WhenInvoke_ThenError()
}

[TestMethod]
public void GivenValidGame_WhenInvoke_ThenOK()
public void GivenValidGame_WhenInvoke_ThenInform()
{
var game = Game.Create(new GameInfo(string.Empty, string.Empty, string.Empty), string.Empty, AssetGenerator.Retained(null, null), GameEndConditions.NoEnd, TestGameConfiguration.Default).Invoke();
var command = new CommandsOff();

var result = command.Invoke(game);

Assert.AreEqual(ReactionResult.OK, result.Result);
Assert.AreEqual(ReactionResult.Inform, result.Result);
}
}
}
4 changes: 2 additions & 2 deletions NetAF.Tests/Commands/Frame/CommandsOn_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ public void GivenNullGame_WhenInvoke_ThenError()
}

[TestMethod]
public void GivenValidGame_WhenInvoke_ThenOK()
public void GivenValidGame_WhenInvoke_ThenInform()
{
var game = Game.Create(new GameInfo(string.Empty, string.Empty, string.Empty), string.Empty, AssetGenerator.Retained(null, null), GameEndConditions.NoEnd, TestGameConfiguration.Default).Invoke();
var command = new CommandsOn();

var result = command.Invoke(game);

Assert.AreEqual(ReactionResult.OK, result.Result);
Assert.AreEqual(ReactionResult.Inform, result.Result);
}
}
}
4 changes: 2 additions & 2 deletions NetAF.Tests/Commands/Frame/KeyOff_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ public void GivenNullGame_WhenInvoke_ThenError()
}

[TestMethod]
public void GivenValidGame_WhenInvoke_ThenOK()
public void GivenValidGame_WhenInvoke_ThenInform()
{
var game = Game.Create(new GameInfo(string.Empty, string.Empty, string.Empty), string.Empty, AssetGenerator.Retained(null, null), GameEndConditions.NoEnd, TestGameConfiguration.Default).Invoke();
var command = new KeyOff();

var result = command.Invoke(game);

Assert.AreEqual(ReactionResult.OK, result.Result);
Assert.AreEqual(ReactionResult.Inform, result.Result);
}
}
}
4 changes: 2 additions & 2 deletions NetAF.Tests/Commands/Frame/KeyOn_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ public void GivenNullGame_WhenInvoke_ThenError()
}

[TestMethod]
public void GivenValidGame_WhenInvoke_ThenOK()
public void GivenValidGame_WhenInvoke_ThenInform()
{
var game = Game.Create(new GameInfo(string.Empty, string.Empty, string.Empty), string.Empty, AssetGenerator.Retained(null, null), GameEndConditions.NoEnd, TestGameConfiguration.Default).Invoke();
var command = new KeyOn();

var result = command.Invoke(game);

Assert.AreEqual(ReactionResult.OK, result.Result);
Assert.AreEqual(ReactionResult.Inform, result.Result);
}
}
}
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_ThenModeChanged()
public void GivenValidGame_WhenInvoke_ThenGameModeChanged()
{
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_ThenModeChanged()

var result = command.Invoke(game);

Assert.AreEqual(ReactionResult.ModeChanged, result.Result);
Assert.AreEqual(ReactionResult.GameModeChanged, result.Result);
}
}
}
4 changes: 2 additions & 2 deletions NetAF.Tests/Commands/Global/End_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_ThenOK()
public void GivenValidGame_WhenInvoke_ThenInform()
{
RegionMaker regionMaker = new(string.Empty, string.Empty);
Room room = new(string.Empty, string.Empty);
Expand All @@ -33,7 +33,7 @@ public void GivenValidGame_WhenInvoke_ThenOK()

var result = command.Invoke(game);

Assert.AreEqual(ReactionResult.OK, result.Result);
Assert.AreEqual(ReactionResult.Inform, result.Result);
}
}
}
4 changes: 2 additions & 2 deletions NetAF.Tests/Commands/Global/Exit_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ public void GivenNullGame_WhenInvoke_ThenError()
}

[TestMethod]
public void GivenValidGame_WhenInvoke_ThenOK()
public void GivenValidGame_WhenInvoke_ThenSilent()
{
var game = Game.Create(new GameInfo(string.Empty, string.Empty, string.Empty), string.Empty, AssetGenerator.Retained(null, null), null, TestGameConfiguration.Default).Invoke();
var command = new Exit();

var result = command.Invoke(game);

Assert.AreEqual(ReactionResult.OK, result.Result);
Assert.AreEqual(ReactionResult.Silent, 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_ThenModeChanged()
public void GivenValidGame_WhenInvoke_ThenGameModeChanged()
{
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_ThenModeChanged()

var result = command.Invoke(game);

Assert.AreEqual(ReactionResult.ModeChanged, result.Result);
Assert.AreEqual(ReactionResult.GameModeChanged, 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_ThenModeChanged()
public void GivenValidGame_WhenInvoke_ThenGameModeChanged()
{
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_ThenModeChanged()

var result = command.Invoke(game);

Assert.AreEqual(ReactionResult.ModeChanged, result.Result);
Assert.AreEqual(ReactionResult.GameModeChanged, result.Result);
}
}
}
4 changes: 2 additions & 2 deletions NetAF.Tests/Commands/Global/New_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ public void GivenNullGame_WhenInvoke_ThenError()
}

[TestMethod]
public void GivenValidGame_WhenInvoke_ThenOK()
public void GivenValidGame_WhenInvoke_ThenSilent()
{
var game = Game.Create(new GameInfo(string.Empty, string.Empty, string.Empty), string.Empty, AssetGenerator.Retained(null, null), null, TestGameConfiguration.Default).Invoke();
var command = new New();

var result = command.Invoke(game);

Assert.AreEqual(ReactionResult.OK, result.Result);
Assert.AreEqual(ReactionResult.Silent, result.Result);
}
}
}
4 changes: 2 additions & 2 deletions NetAF.Tests/Commands/Persistence/Load_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace NetAF.Tests.Commands.Persistence
public class Load_Tests
{
[TestMethod]
public void GivenValidPathAndFileExists_WhenInvoke_ThenOK()
public void GivenValidPathAndFileExists_WhenInvoke_ThenInform()
{
var regionMaker = new RegionMaker(string.Empty, string.Empty);
var item = new Item(string.Empty, string.Empty) { IsPlayerVisible = false };
Expand All @@ -40,7 +40,7 @@ public void GivenValidPathAndFileExists_WhenInvoke_ThenOK()
if (fileExists)
File.Delete(path);

Assert.AreEqual(ReactionResult.OK, result.Result);
Assert.AreEqual(ReactionResult.Inform, result.Result);
}

[TestMethod]
Expand Down
4 changes: 2 additions & 2 deletions NetAF.Tests/Commands/Persistence/Save_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace NetAF.Tests.Commands.Persistence
public class Save_Tests
{
[TestMethod]
public void GivenValidPath_WhenInvoke_ThenOK()
public void GivenValidPath_WhenInvoke_ThenInform()
{
var regionMaker = new RegionMaker(string.Empty, string.Empty);
var item = new Item(string.Empty, string.Empty) { IsPlayerVisible = false };
Expand All @@ -36,7 +36,7 @@ public void GivenValidPath_WhenInvoke_ThenOK()
if (fileExists)
File.Delete(path);

Assert.AreEqual(ReactionResult.OK, result.Result);
Assert.AreEqual(ReactionResult.Inform, result.Result);
}

[TestMethod]
Expand Down
4 changes: 2 additions & 2 deletions NetAF.Tests/Commands/Scene/Drop_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void GivenPlayerDoesNotHaveItem_WhenInvoke_ThenError()
}

[TestMethod]
public void GivenItemIsDroppable_WhenInvoke_ThenOK()
public void GivenItemIsDroppable_WhenInvoke_ThenInform()
{
var room = new Room(Identifier.Empty, Description.Empty);
var region = new Region(string.Empty, string.Empty);
Expand All @@ -68,7 +68,7 @@ public void GivenItemIsDroppable_WhenInvoke_ThenOK()

var result = command.Invoke(game);

Assert.AreEqual(ReactionResult.OK, result.Result);
Assert.AreEqual(ReactionResult.Inform, result.Result);
}
}
}
4 changes: 2 additions & 2 deletions NetAF.Tests/Commands/Scene/Examine_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ public void GivenNothingToExamine_WhenInvoke_ThenError()
}

[TestMethod]
public void GivenSomethingToExamine_WhenInvoke_ThenOK()
public void GivenSomethingToExamine_WhenInvoke_ThenInform()
{
var game = Game.Create(new GameInfo(string.Empty, string.Empty, string.Empty), string.Empty, AssetGenerator.Retained(null, null), GameEndConditions.NoEnd, TestGameConfiguration.Default).Invoke();
var region = new Region(Identifier.Empty, Description.Empty);
var command = new Examine(region);

var result = command.Invoke(game);

Assert.AreEqual(ReactionResult.OK, result.Result);
Assert.AreEqual(ReactionResult.Inform, result.Result);
}
}
}
4 changes: 2 additions & 2 deletions NetAF.Tests/Commands/Scene/Move_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void GivenCantMove_WhenInvoke_ThenError()
}

[TestMethod]
public void GivenCanMove_WhenInvoke_ThenOK()
public void GivenCanMove_WhenInvoke_ThenInform()
{
var region = new Region(Identifier.Empty, Description.Empty);
region.AddRoom(new Room(Identifier.Empty, Description.Empty, [new Exit(Direction.North)]), 0, 0, 0);
Expand All @@ -39,7 +39,7 @@ public void GivenCanMove_WhenInvoke_ThenOK()

var result = command.Invoke(game);

Assert.AreEqual(ReactionResult.OK, result.Result);
Assert.AreEqual(ReactionResult.Inform, result.Result);
}
}
}
4 changes: 2 additions & 2 deletions NetAF.Tests/Commands/Scene/TakeAll_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void GivenNoItemsAreTakeable_WhenInvoke_ThenError()
}

[TestMethod]
public void GivenItemsAreTakeable_WhenInvoke_ThenOK()
public void GivenItemsAreTakeable_WhenInvoke_ThenInform()
{
var room = new Room(Identifier.Empty, Description.Empty);
var character = new PlayableCharacter(Identifier.Empty, Description.Empty);
Expand All @@ -63,7 +63,7 @@ public void GivenItemsAreTakeable_WhenInvoke_ThenOK()

var result = command.Invoke(game);

Assert.AreEqual(ReactionResult.OK, result.Result);
Assert.AreEqual(ReactionResult.Inform, result.Result);
}
}
}
4 changes: 2 additions & 2 deletions NetAF.Tests/Commands/Scene/Take_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void GivenItemIsNotTakeable_WhenInvoke_ThenError()
}

[TestMethod]
public void GivenItemIsTakeable_WhenInvoke_ThenOK()
public void GivenItemIsTakeable_WhenInvoke_ThenInform()
{
var room = new Room(Identifier.Empty, Description.Empty);
var character = new PlayableCharacter(Identifier.Empty, Description.Empty);
Expand All @@ -97,7 +97,7 @@ public void GivenItemIsTakeable_WhenInvoke_ThenOK()

var result = command.Invoke(game);

Assert.AreEqual(ReactionResult.OK, result.Result);
Assert.AreEqual(ReactionResult.Inform, result.Result);
}
}
}
12 changes: 6 additions & 6 deletions NetAF.Tests/Commands/Scene/UseOn_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void GivenNoPlayer_WhenInvoke_ThenError()
}

[TestMethod]
public void GivenTargetIsNpc_WhenInvoke_ThenOK()
public void GivenTargetIsNpc_WhenInvoke_ThenInform()
{
var item = new Item(Identifier.Empty, Description.Empty, true);
var npc = new NonPlayableCharacter(Identifier.Empty, Description.Empty);
Expand All @@ -64,11 +64,11 @@ public void GivenTargetIsNpc_WhenInvoke_ThenOK()

var result = command.Invoke(game);

Assert.AreEqual(ReactionResult.OK, result.Result);
Assert.AreEqual(ReactionResult.Inform, result.Result);
}

[TestMethod]
public void GivenTargetIsPlayer_WhenInvoke_ThenOK()
public void GivenTargetIsPlayer_WhenInvoke_ThenInform()
{
var item = new Item(Identifier.Empty, Description.Empty, true);
var pc = new PlayableCharacter(Identifier.Empty, Description.Empty);
Expand All @@ -82,11 +82,11 @@ public void GivenTargetIsPlayer_WhenInvoke_ThenOK()

var result = command.Invoke(game);

Assert.AreEqual(ReactionResult.OK, result.Result);
Assert.AreEqual(ReactionResult.Inform, result.Result);
}

[TestMethod]
public void GivenTargetIsRoom_WhenInvoke_ThenOK()
public void GivenTargetIsRoom_WhenInvoke_ThenInform()
{
var item = new Item(Identifier.Empty, Description.Empty, true);
var room = new Room(Identifier.Empty, Description.Empty);
Expand All @@ -100,7 +100,7 @@ public void GivenTargetIsRoom_WhenInvoke_ThenOK()

var result = command.Invoke(game);

Assert.AreEqual(ReactionResult.OK, result.Result);
Assert.AreEqual(ReactionResult.Inform, result.Result);
}
}
}
1 change: 1 addition & 0 deletions NetAF.Tests/Logic/Game_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using NetAF.Utilities;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NetAF.Logic.Modes;
using NetAF.Logic.Configuration;

namespace NetAF.Tests.Logic
{
Expand Down
Loading

0 comments on commit da359c3

Please sign in to comment.