-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from benpollarduk/examination-changes
Added ExaminationScene and ExaminationRequest
- Loading branch information
Showing
12 changed files
with
182 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using NetAF.Assets; | ||
using NetAF.Assets.Characters; | ||
using NetAF.Assets.Locations; | ||
using NetAF.Logic; | ||
|
||
namespace NetAF.Tests.Assets | ||
{ | ||
[TestClass] | ||
public class ExaminationRequest_Tests | ||
{ | ||
[TestMethod] | ||
public void GivenCreate_WhenGameSpecified_ThenExaminerSetFromPlayer() | ||
{ | ||
var player = new PlayableCharacter(string.Empty, string.Empty); | ||
var room = new Room(string.Empty, string.Empty); | ||
var region = new Region(string.Empty, string.Empty); | ||
var overworld = new Overworld(string.Empty, string.Empty); | ||
region.AddRoom(room, 0, 0, 0); | ||
overworld.AddRegion(region); | ||
var gameCreator = Game.Create(string.Empty, string.Empty, string.Empty, () => overworld, () => player, g => EndCheckResult.NotEnded, g => EndCheckResult.NotEnded); | ||
|
||
var result = new ExaminationRequest(player, gameCreator()); | ||
|
||
Assert.AreEqual(player, result.Scene.Examiner); | ||
} | ||
|
||
[TestMethod] | ||
public void GivenCreate_WhenGameSpecified_ThenRoomSetFromPlayer() | ||
{ | ||
var player = new PlayableCharacter(string.Empty, string.Empty); | ||
var room = new Room(string.Empty, string.Empty); | ||
var region = new Region(string.Empty, string.Empty); | ||
var overworld = new Overworld(string.Empty, string.Empty); | ||
region.AddRoom(room, 0, 0, 0); | ||
overworld.AddRegion(region); | ||
var gameCreator = Game.Create(string.Empty, string.Empty, string.Empty, () => overworld, () => player, g => EndCheckResult.NotEnded, g => EndCheckResult.NotEnded); | ||
|
||
var result = new ExaminationRequest(player, gameCreator()); | ||
|
||
Assert.AreEqual(room, result.Scene.Room); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using NetAF.Logic; | ||
|
||
namespace NetAF.Assets | ||
{ | ||
/// <summary> | ||
/// Represents a request to examine an IExaminable. | ||
/// </summary> | ||
public class ExaminationRequest | ||
{ | ||
#region Propeties | ||
|
||
/// <summary> | ||
/// Get the examinable object. | ||
/// </summary> | ||
public IExaminable Examinable { get; private set; } | ||
|
||
/// <summary> | ||
/// Get the examination scene. | ||
/// </summary> | ||
public ExaminationScene Scene { get; private set; } | ||
|
||
#endregion | ||
|
||
#region Constructors | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the ExaminationRequest class. | ||
/// </summary> | ||
/// <param name="examinable">The object being examined.</param> | ||
/// <param name="scene">The scene the object is being examined from.</param> | ||
public ExaminationRequest(IExaminable examinable, ExaminationScene scene) | ||
{ | ||
Examinable = examinable; | ||
Scene = scene; | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the ExaminationRequest class. | ||
/// </summary> | ||
/// <param name="examinable">The object being examined.</param> | ||
/// <param name="game">The executing game.</param> | ||
public ExaminationRequest(IExaminable examinable, Game game) : this(examinable, new ExaminationScene(game)) | ||
{ | ||
} | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using NetAF.Assets.Characters; | ||
using NetAF.Assets.Locations; | ||
using NetAF.Logic; | ||
|
||
namespace NetAF.Assets | ||
{ | ||
/// <summary> | ||
/// Represents a scene that an examination occurs in. | ||
/// </summary> | ||
public class ExaminationScene | ||
{ | ||
#region StaticProperties | ||
|
||
/// <summary> | ||
/// Get a default value for when there is no scene. | ||
/// </summary> | ||
public static ExaminationScene NoScene { get; } = new ExaminationScene(null, null); | ||
|
||
#endregion | ||
|
||
#region Propeties | ||
|
||
/// <summary> | ||
/// Get the examiner. | ||
/// </summary> | ||
public Character Examiner { get; private set; } | ||
|
||
/// <summary> | ||
/// Get the room the examinable is being examined from. | ||
/// </summary> | ||
public Room Room { get; private set; } | ||
|
||
#endregion | ||
|
||
#region Constructors | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the ExaminationScene class. | ||
/// </summary> | ||
/// <param name="examiner">The character who is examining the object.</param> | ||
/// <param name="room">The room the examinable is being examined from.</param> | ||
public ExaminationScene(Character examiner, Room room) | ||
{ | ||
Examiner = examiner; | ||
Room = room; | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the ExaminationScene class. | ||
/// </summary> | ||
/// <param name="game">The executing game.</param> | ||
public ExaminationScene(Game game) : this(game.Player, game.Overworld?.CurrentRegion?.CurrentRoom) | ||
{ | ||
} | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters