Implemented an abstract BaseCommand

This commit is contained in:
Budoray_cp 2011-09-13 19:50:52 -07:00
parent 795b95f1b4
commit a403b24a05
7 changed files with 34 additions and 70 deletions

View file

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using MudEngine.GameManagement;
using MudEngine.GameObjects.Characters;
using MudEngine.GameObjects.Environment;
namespace MudEngine.Commands
{
public abstract class BaseCommand : IGameCommand
{
public Boolean Override { get; set; }
//public String Name { get; set; }
public List<String> Help { get; set; }
private Realm realm;
private BaseCharacter player;
private Boolean isEditing;
public BaseCommand()
{
Help = new List<string>();
}
public abstract void Execute(String command, BaseCharacter player);
}
}

View file

@ -13,21 +13,10 @@ using MudEngine.GameObjects.Environment;
namespace MudEngine.Commands namespace MudEngine.Commands
{ {
public class CommandEditRealm : IGameCommand public class CommandEditRealm : BaseCommand
{ {
public Boolean Override { get; set; }
public String Name { get; set; }
public List<String> Help { get; set; }
private Realm realm;
private BaseCharacter player;
private Boolean isEditing;
public CommandEditRealm() public CommandEditRealm()
{ {
Help = new List<string>();
Help.Add("Use the Edit command to edit existing objects properties."); Help.Add("Use the Edit command to edit existing objects properties.");
Help.Add("Usage: Edit ObjectType ObjectName"); Help.Add("Usage: Edit ObjectType ObjectName");
Help.Add("Usage: Edit ObjectType FullyQualifiedName"); Help.Add("Usage: Edit ObjectType FullyQualifiedName");

View file

@ -13,21 +13,10 @@ using MudEngine.GameObjects.Environment;
namespace MudEngine.Commands namespace MudEngine.Commands
{ {
public class CommandEditRoom : IGameCommand public class CommandEditRoom : BaseCommand
{ {
public Boolean Override { get; set; }
public String Name { get; set; }
public List<String> Help { get; set; }
private Room room;
private BaseCharacter player;
private Boolean isEditing;
public CommandEditRoom() public CommandEditRoom()
{ {
Help = new List<string>();
Help.Add("Use the Edit command to edit existing objects properties."); Help.Add("Use the Edit command to edit existing objects properties.");
Help.Add("Usage: EditRoom Realm>Room>Room"); Help.Add("Usage: EditRoom Realm>Room>Room");
Help.Add("Example: EditRoom MyRealmName>MyRoom>MyRoom"); Help.Add("Example: EditRoom MyRealmName>MyRoom>MyRoom");

View file

@ -13,21 +13,10 @@ using MudEngine.GameObjects.Environment;
namespace MudEngine.Commands namespace MudEngine.Commands
{ {
public class CommandEditZone : IGameCommand public class CommandEditZone : BaseCommand
{ {
public Boolean Override { get; set; }
public String Name { get; set; }
public List<String> Help { get; set; }
private Zone zone;
private BaseCharacter player;
private Boolean isEditing;
public CommandEditZone() public CommandEditZone()
{ {
Help = new List<string>();
Help.Add("Use the Edit command to edit existing objects properties."); Help.Add("Use the Edit command to edit existing objects properties.");
Help.Add("Usage: EditZone Realm>Zone"); Help.Add("Usage: EditZone Realm>Zone");
Help.Add("Example: EditZone MyRealmName>MyZone"); Help.Add("Example: EditZone MyRealmName>MyZone");

View file

@ -19,32 +19,13 @@ namespace MudEngine.Commands
/// by modifying the source. /// by modifying the source.
/// TODO: Update the engine to dynamically look for a Login script rather than relying on CommandLogin. /// TODO: Update the engine to dynamically look for a Login script rather than relying on CommandLogin.
/// </summary> /// </summary>
public class CommandLogin : IGameCommand public class CommandLogin : BaseCommand
{ {
/// <summary>
/// Used by the Command Engine to allow for overriding any other commands that contain the same name.
/// TODO: Does Overriding Commands still work? This is part of some old code I wrote several years back and might be broke.
/// </summary>
public Boolean Override { get; set; }
/// The name of the command.
/// If Override is set to true, this command will override any other command that contains the same name.
/// </summary>
public String Name { get; set; }
/// <summary>
/// A collection of strings that contains helpfull information for this Command.
/// When the user enteres 'Help Exit' the game will print the content of this collection.
/// This is treated like a virtual book, each entry in the collection is printed as a new line.
/// </summary>
public List<String> Help { get; set; }
/// <summary> /// <summary>
/// Class constructor /// Class constructor
/// </summary> /// </summary>
public CommandLogin() public CommandLogin()
{ {
Help = new List<string>();
Help.Add("Logs the player into their respective account."); Help.Add("Logs the player into their respective account.");
} }

View file

@ -16,16 +16,10 @@ using MudEngine.FileSystem;
namespace MudEngine.Commands namespace MudEngine.Commands
{ {
class CommandRestart : IGameCommand class CommandRestart : BaseCommand
{ {
public String Name { get; set; }
public Boolean Override { get; set; }
public List<String> Help { get; set; }
public CommandRestart() public CommandRestart()
{ {
Help = new List<string>();
Help.Add("Restarts the game server."); Help.Add("Restarts the game server.");
} }

View file

@ -12,16 +12,10 @@ using MudEngine.GameObjects.Environment;
namespace MudEngine.Commands namespace MudEngine.Commands
{ {
public class CommandSaveWorld : IGameCommand public class CommandSaveWorld : BaseCommand
{ {
public Boolean Override { get; set; }
public String Name { get; set; }
public List<String> Help { get; set; }
public CommandSaveWorld() public CommandSaveWorld()
{ {
Help = new List<string>();
Help.Add("Saves the game world."); Help.Add("Saves the game world.");
} }