muddesigner/MudGame/Scripts/AdminCommands/CommandCreateRoom.cs
Scionwest_cp a347607337 Mud Designer:
- Added new Project. Mud Designer project will include the GUI elements needed for graphically building a MUD. Due to Environment creation being finalized, work on a GUI based Environment creation can start.

Mud Engine:
 - Objects no longer require a path to be supplied when calling Object.Save()
 - EditRealm command now edits senses.
 - EditRoom now fully supports creating doorways, however editing existing doorways and linking to existing rooms is not implemented. This command only supports creating new doorways for non-existing Rooms (Rooms are generated as needed)
 - EditZone Now fully supports senses and implemented.
 - Game now supports loading of .ini files when calling Game.Load()
 - All objects now include a SavePath properties. Override this to supply a path for where the object needs to be saved. All Environment and BaseCharacter objects override the BaseObject.SavePath to save into ActiveGame.DataPaths.Environemnts and Players respectively.
 - ObjectCollection now instanced during ScriptEngine initialization to prevent exceptions during runtime.
 - Create command no longer converts all names to lower case.
 - Updated the Walk command to execute the Look command in a safe manor without injecting a command into the player Telnet console.
2010-09-26 08:00:34 -07:00

67 lines
No EOL
2.7 KiB
C#

/// <summary>
/// This command creates a Room within the players current Realm>Zone.
/// Admins using this command will not need to supply a fully qualified path like the 'Create' command requires.
/// However, they are restricted to creating Rooms only within their current Realm>Zone.
/// </summary>
class CommandCreateRoom : IGameCommand
{
/// <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; }
/// <summary>
/// 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>
/// Constructor for the class.
/// </summary>
public CommandCreateRoom()
{
Help = new List<string>();
Help.Add("Creates a Room within the Admin's current Realm>Zone");
}
public void Execute(String command, BaseCharacter player)
{
if ((player.Role == SecurityRoles.Admin) || (player.Role == SecurityRoles.GM))
{
String roomname = command.Substring("Createroom".Length).Trim();
if (String.IsNullOrEmpty(roomname))
{
player.Send("You must supply a Room name! Refer to 'Help CreateRoom' for usage examples.");
return;
}
if ((String.IsNullOrEmpty(player.CurrentRoom.Realm)) || (String.IsNullOrEmpty(player.CurrentRoom.Zone)))
{
player.Send("You are not currently within a pre-existing Zone.");
player.Send("Use the Teleport command to teleport yourself into a valid Zone before using the CreateRoom command.");
return;
}
Room r = new Room(player.ActiveGame);
r.Realm = player.CurrentRoom.Realm;
r.Zone = player.CurrentRoom.Zone;
r.Name = roomname;
player.ActiveGame.World.GetRealm(r.Realm).GetZone(r.Zone)[0].AddRoom(r);
player.Send(r.Name + " created within " + r.Realm + ">" + r.Zone + ".");
Log.Write(player.Name + " created a new Room in " + r.RoomLocation);
}
}
}