- Changed the IGameCommand Interface constructor for the Execute method. - Updated all of the game commands to make use of the new Execute Method Constructor requirements set by the updated interface. - Look command now returns a description of the players current Room. - Walk command now supports moving players from one Room to another. Use 'Walk Direction' where Direction equals the direction you want to travel (Example: 'Walk North") - TravelDirections.GetTravelDirectionValue now checks the supplied direction value in a case-insensitive manor. - Add a new CommandEngine that handles the commands inputed from the user. - Modified CommandResult to return an array of objects rather than a single object. Runtime: - Now scans the supplied collection of objects returned to the runtime after executing a game command, and adjusts the runtime components as needed, including printing information to the console. - Now displays various warnings during startup to let the user know if certain content hasn't been set within the ProjectInformation yet. - Now executes the 'Look' command on startup to display the users current location. - Fully supports the 'Look' and 'Walk' commands.
56 lines
No EOL
1.9 KiB
C#
56 lines
No EOL
1.9 KiB
C#
using System;
|
|
|
|
namespace MudDesigner.MudEngine.GameObjects
|
|
{
|
|
public enum AvailableTravelDirections
|
|
{
|
|
None = 0,
|
|
North,
|
|
South,
|
|
East,
|
|
West,
|
|
Up,
|
|
Down,
|
|
}
|
|
|
|
public static class TravelDirections
|
|
{
|
|
public static AvailableTravelDirections GetReverseDirection(AvailableTravelDirections Direction)
|
|
{
|
|
switch (Direction)
|
|
{
|
|
case AvailableTravelDirections.Down:
|
|
return AvailableTravelDirections.Up;
|
|
case AvailableTravelDirections.East:
|
|
return AvailableTravelDirections.West;
|
|
case AvailableTravelDirections.None:
|
|
return AvailableTravelDirections.None;
|
|
case AvailableTravelDirections.North:
|
|
return AvailableTravelDirections.South;
|
|
case AvailableTravelDirections.South:
|
|
return AvailableTravelDirections.North;
|
|
case AvailableTravelDirections.Up:
|
|
return AvailableTravelDirections.Down;
|
|
case AvailableTravelDirections.West:
|
|
return AvailableTravelDirections.East;
|
|
default:
|
|
return AvailableTravelDirections.None;
|
|
}
|
|
}
|
|
|
|
public static AvailableTravelDirections GetTravelDirectionValue(string Direction)
|
|
{
|
|
Array values = Enum.GetValues(typeof(AvailableTravelDirections));
|
|
|
|
foreach (int value in values)
|
|
{
|
|
string displayName = Enum.GetName(typeof(AvailableTravelDirections), value);
|
|
|
|
if (displayName.ToLower() == Direction.ToLower())
|
|
return (AvailableTravelDirections)Enum.Parse(typeof(AvailableTravelDirections), displayName);
|
|
}
|
|
|
|
return AvailableTravelDirections.None;
|
|
}
|
|
}
|
|
} |