MudEngine:

- All commands are now required to have a Help property.

MudGame:
 - Finished the Create command. Now allows for creating Realms, Zones and Rooms
 - Added LinkRoom command for linking Rooms. Not finished.
 - Added Help command. Typing Help prints all of the currently available commands. Typing Help 'CommandName' prints that Commands help property. Default commands print a help document.
This commit is contained in:
Scionwest_cp 2010-08-19 19:09:45 -07:00
parent f51e17af7b
commit 386d90df19
22 changed files with 678 additions and 114 deletions

View file

@ -16,6 +16,13 @@ namespace MudEngine.Commands
{ {
public Boolean Override { get; set; } public Boolean Override { get; set; }
public String Name { get; set; } public String Name { get; set; }
public List<String> Help { get; set; }
public CommandExit()
{
Help = new List<string>();
Help.Add("Exits the game cleanly.");
}
public void Execute(String command, BaseCharacter player) public void Execute(String command, BaseCharacter player)
{ {

View file

@ -12,6 +12,13 @@ namespace MudEngine.Commands
public String Name { get; set; } public String Name { get; set; }
public Boolean Override { get; set; } public Boolean Override { get; set; }
public List<String> Help { get; set; }
public CommandGetTime()
{
Help = new List<string>();
Help.Add("Gives you the current time and date in the game world.");
}
public void Execute(String command, BaseCharacter player) public void Execute(String command, BaseCharacter player)
{ {

View file

@ -0,0 +1,271 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using MudEngine.FileSystem;
using MudEngine.GameManagement;
using MudEngine.GameObjects;
using MudEngine.GameObjects.Characters;
using MudEngine.GameObjects.Environment;
namespace MudEngine.Commands
{
public class CommandLinkRoom : IGameCommand
{
public Boolean Override { get; set; }
public String Name { get; set; }
public List<String> Help { get; set; }
public CommandLinkRoom()
{
Help = new List<string>();
Help.Add("Use this to link two previously created Rooms together");
Help.Add("Note that this command is not fully implemented and does not work.");
}
public void Execute(String command, BaseCharacter player)
{
player.Send("Room linkage tool");
player.Send("Please select an option.");
player.Send("1: Link Room");
player.Send("2: Exit");
string input = player.ReadInput();
Int32 value = 0;
try
{
value = Convert.ToInt32(input);
}
catch (Exception)
{
player.Send("Invalid selection. Please use numeric values.");
return;
}
player.Send("");
player.Send("Please select which Realm your departing Room resides within:");
player.Send("");
Boolean isValidRealm = false;
Realm realm = new Realm(player.ActiveGame);
while (!isValidRealm)
{
isValidRealm = true;//Default to true, assume the user entered a valid name.
foreach (Realm r in player.ActiveGame.World.RealmCollection)
{
player.Send(r.Filename + " | ", false);
}
player.Send("");
player.Send("Selection: ", false);
input = player.ReadInput();
if (input.ToLower() == "cancel")
{
player.Send("Room Linking aborted.");
return;
}
//Ensure it's a valid name, if not then loop back and try again.
foreach (Realm r in player.ActiveGame.World.RealmCollection)
{
if (r.Filename.ToLower() == input.ToLower())
{
isValidRealm = true;
realm = r;
break;
}
else
{
isValidRealm = false;
}
}
if (!isValidRealm)
player.Send("That Realm does not exist! Please try again.");
}
player.Send("");
player.Send("Please select which Zone your departing Room resides within:");
player.Send("");
Boolean isValidZone = false;
Zone zone = new Zone(player.ActiveGame);
while (!isValidZone)
{
isValidZone = true;//Default to true, assume the user entered a valid name.
foreach (Zone z in realm.ZoneCollection)
{
player.Send(z.Filename + " | ", false);
}
player.Send("");
player.Send("Selection: ", false);
input = player.ReadInput();
if (input.ToLower() == "cancel")
{
player.Send("Room Linking aborted.");
return;
}
//Ensure it's a valid name, if not then loop back and try again.
foreach (Zone z in realm.ZoneCollection)
{
if (z.Filename.ToLower() == input.ToLower())
{
isValidZone = true;
zone = z;
break;
}
else
{
isValidZone = false;
}
}
if (!isValidZone)
player.Send("That Zone does not exist! Please try again.");
}
player.Send("");
player.Send("Please select which Room that you wish to be the departing Room:");
player.Send("");
Boolean isValidRoom = false;
Room departingRoom = new Room(player.ActiveGame);
while (!isValidRoom)
{
isValidRoom = true;//Default to true, assume the user entered a valid name.
foreach (Room r in zone.RoomCollection)
{
player.Send(r.Filename + " | ", false);
}
player.Send("");
player.Send("Selection: ", false);
input = player.ReadInput();
if (input.ToLower() == "cancel")
{
player.Send("Room Linking aborted.");
return;
}
//Ensure it's a valid name, if not then loop back and try again.
foreach (Room r in zone.RoomCollection)
{
if (r.Filename.ToLower() == input.ToLower())
{
isValidRoom = true;
departingRoom = r;
break;
}
else
{
isValidRoom = false;
}
}
if (!isValidRoom)
player.Send("That Room does not exist! Please try again.");
}
player.Send("");
player.Send("Please select which Room that you wish to be the Arrival Room:");
player.Send("");
isValidRoom = false;
Room arrivalRoom = new Room(player.ActiveGame);
while (!isValidRoom)
{
isValidRoom = true;//Default to true, assume the user entered a valid name.
foreach (Room r in zone.RoomCollection)
{
player.Send(r.Filename + " | ", false);
}
player.Send("");
player.Send("Selection: ", false);
input = player.ReadInput();
if (input.ToLower() == "cancel")
{
player.Send("Room Linking aborted.");
return;
}
//Ensure it's a valid name, if not then loop back and try again.
foreach (Room r in zone.RoomCollection)
{
if (r.Filename.ToLower() == input.ToLower())
{
isValidRoom = true;
departingRoom = r;
break;
}
else
{
isValidRoom = false;
}
}
if (!isValidRoom)
player.Send("That Room does not exist! Please try again.");
}
player.Send("");
player.Send("Please select which Room that you wish to be the departing Room:");
player.Send("");
player.Send("Please select which direction you would like to travel while departing the departure Room.");
Array values = Enum.GetValues(typeof(AvailableTravelDirections));
foreach (Int32 v in values)
{
//Since enum values are not strings, we can't simply just assign the String to the enum
String displayName = Enum.GetName(typeof(AvailableTravelDirections), v);
player.Send(displayName + " | ");
}
player.Send("Enter Selection: ", false);
input = player.ReadInput();
AvailableTravelDirections direction = new AvailableTravelDirections();
Boolean isValidDirection = false;
foreach (Int32 v in values)
{
//Since enum values are not strings, we can't simply just assign the String to the enum
String displayName = Enum.GetName(typeof(AvailableTravelDirections), v);
//If the value = the String saved, then perform the needed conversion to get our data back
if (displayName.ToLower() == input.ToLower())
{
direction = (AvailableTravelDirections)Enum.Parse(typeof(AvailableTravelDirections), displayName);
isValidDirection = true;
break;
}
}
if (!isValidDirection)
{
player.Send("Invalid direction supplied!");
}
else
{
zone.LinkRooms(direction, arrivalRoom, departingRoom);
}
}
}
}

View file

@ -15,7 +15,7 @@ namespace MudEngine.Commands
{ {
public Boolean Override { get; set; } public Boolean Override { get; set; }
public String Name { get; set; } public String Name { get; set; }
public List<String> Help { get; set; }
public void Execute(String command, BaseCharacter player) public void Execute(String command, BaseCharacter player)
{ {
String path = player.ActiveGame.DataPaths.Players; String path = player.ActiveGame.DataPaths.Players;

View file

@ -16,7 +16,7 @@ namespace MudEngine.Commands
{ {
public Boolean Override { get; set; } public Boolean Override { get; set; }
public String Name { get; set; } public String Name { get; set; }
public List<String> Help { get; set; }
public void Execute(String command, BaseCharacter player) public void Execute(String command, BaseCharacter player)
{ {
player.Send(player.ActiveGame.GameTitle); player.Send(player.ActiveGame.GameTitle);

View file

@ -16,7 +16,7 @@ namespace MudEngine.Commands
{ {
public String Name { get; set; } public String Name { get; set; }
public Boolean Override { get; set; } public Boolean Override { get; set; }
public List<String> Help { get; set; }
public void Execute(String command, BaseCharacter player) public void Execute(String command, BaseCharacter player)
{ {
if (player.CurrentRoom == null) if (player.CurrentRoom == null)

View file

@ -20,7 +20,7 @@ namespace MudEngine.Commands
{ {
public String Name { get; set; } public String Name { get; set; }
public Boolean Override { get; set; } public Boolean Override { get; set; }
public List<String> Help { get; set; }
public void Execute(String command, BaseCharacter player) public void Execute(String command, BaseCharacter player)
{ {
if (player.Role == SecurityRoles.Admin) if (player.Role == SecurityRoles.Admin)

View file

@ -15,7 +15,7 @@ namespace MudEngine.Commands
{ {
public Boolean Override { get; set; } public Boolean Override { get; set; }
public String Name { get; set; } public String Name { get; set; }
public List<String> Help { get; set; }
public void Execute(String command, BaseCharacter player) public void Execute(String command, BaseCharacter player)
{ {
player.Save(player.ActiveGame.DataPaths.Players); player.Save(player.ActiveGame.DataPaths.Players);

View file

@ -16,7 +16,7 @@ namespace MudEngine.Commands
{ {
public Boolean Override { get; set; } public Boolean Override { get; set; }
public String Name { get; set; } public String Name { get; set; }
public List<String> Help { get; set; }
public void Execute(String command, BaseCharacter player) public void Execute(String command, BaseCharacter player)
{ {
if ((player.Role == SecurityRoles.Admin) || (player.Role == SecurityRoles.GM)) if ((player.Role == SecurityRoles.Admin) || (player.Role == SecurityRoles.GM))

View file

@ -16,6 +16,7 @@ namespace MudEngine.Commands
{ {
public String Name { get; set; } public String Name { get; set; }
public Boolean Override { get; set; } public Boolean Override { get; set; }
public List<String> Help { get; set; }
public void Execute(String command, BaseCharacter player) public void Execute(String command, BaseCharacter player)
{ {

View file

@ -57,6 +57,11 @@ namespace MudEngine.GameManagement
return null; return null;
} }
public static String GetCommandName(IGameCommand command)
{
return command.Name.Substring("Command".Length);
}
public static Boolean IsValidCommand(String Name) public static Boolean IsValidCommand(String Name)
{ {
if (CommandCollection.ContainsKey(Name.ToLower())) if (CommandCollection.ContainsKey(Name.ToLower()))

View file

@ -142,11 +142,11 @@ namespace MudEngine.GameManagement
DayTransitions = TimeOfDayOptions.Transition; DayTransitions = TimeOfDayOptions.Transition;
SecondsPerMinute = 5; SecondsPerMinute = 1;
MinutesPerHour = 5; MinutesPerHour = 1;
HoursPerDay = 5; HoursPerDay = 1;
DaysPerMonth = 31; DaysPerMonth = 3;
MonthsPerYear = 12; MonthsPerYear = 3;
CurrentWorldTime = InitialGameTime; CurrentWorldTime = InitialGameTime;
} }
@ -170,7 +170,7 @@ namespace MudEngine.GameManagement
CurrentSystemTime = DateTime.Now; CurrentSystemTime = DateTime.Now;
Int32 amount = Math.Abs(ts.Seconds); Int32 amount = Math.Abs(ts.Seconds);
IncrementSecond(amount); IncrementSecond(amount);
Log.Write(GetCurrentWorldTime()); //Log.Write(GetCurrentWorldTime());
} }
} }
@ -311,5 +311,51 @@ namespace MudEngine.GameManagement
return day + ", " + month + " " + CurrentWorldTime.Day + ", " + CurrentWorldTime.Year + ": " + CurrentWorldTime.Hour + ":" + CurrentWorldTime.Minute + ":" + CurrentWorldTime.Second; return day + ", " + month + " " + CurrentWorldTime.Day + ", " + CurrentWorldTime.Year + ": " + CurrentWorldTime.Hour + ":" + CurrentWorldTime.Minute + ":" + CurrentWorldTime.Second;
} }
public Int32 GetCurrentSecond()
{
return CurrentWorldTime.Second;
}
public Int32 GetCurrentMinute()
{
return CurrentWorldTime.Minute;
}
public Int32 GetCurrentHour()
{
return CurrentWorldTime.Hour;
}
public Int32 GetCurrentDayNumber()
{
return CurrentWorldTime.Day;
}
public String GetCurrentDayName()
{
if (DayNames.Count > CurrentWorldTime.Day)
return "No Day Name available for the current Date.";
else
return DayNames[CurrentWorldTime.Day - 1];//Days start at 1, array index starts at 0
}
public Int32 GetCurrentMonthNumber()
{
return CurrentWorldTime.Month;
}
public String GetCurrentMonthName()
{
if (MonthNames.Count > CurrentWorldTime.Month)
return "No Month Name available for the current Date.";
else
return MonthNames[CurrentWorldTime.Month - 1]; //Day starts at 1, array index starts at 0.
}
public Int32 GetCurrentYear()
{
return CurrentWorldTime.Year;
}
} }
} }

View file

@ -18,6 +18,10 @@ namespace MudEngine.GameManagement
String Name { get; set; } String Name { get; set; }
//Used to override commands with the same name //Used to override commands with the same name
Boolean Override { get; set; } Boolean Override { get; set; }
//Used when the player enters the help command
List<String> Help { get; set; }
//Executes the command. //Executes the command.
void Execute(String command, BaseCharacter player); void Execute(String command, BaseCharacter player);
} }

View file

@ -34,6 +34,7 @@ namespace MudEngine.GameManagement
//Add to the cache so consoles can get these messages if they want to. //Add to the cache so consoles can get these messages if they want to.
//If Pushmessage=true then we skip caching and dump it straight to the console //If Pushmessage=true then we skip caching and dump it straight to the console
//TODO: Allow for enabling critical error messages being forced into the console, regardless if !IsMultiplayer
if ((pushMessage) && (!IsVerbose)) if ((pushMessage) && (!IsVerbose))
Console.WriteLine(message); Console.WriteLine(message);
else else

View file

@ -59,6 +59,7 @@
<Compile Include="Commands\CommandLoad.cs" /> <Compile Include="Commands\CommandLoad.cs" />
<Compile Include="Commands\CommandLogin.cs" /> <Compile Include="Commands\CommandLogin.cs" />
<Compile Include="Commands\CommandSaveWorld.cs" /> <Compile Include="Commands\CommandSaveWorld.cs" />
<Compile Include="Commands\CommandLinkRoom.cs" />
<Compile Include="FileSystem\SaveDataPaths.cs" /> <Compile Include="FileSystem\SaveDataPaths.cs" />
<Compile Include="GameManagement\CommandEngine.cs" /> <Compile Include="GameManagement\CommandEngine.cs" />
<Compile Include="GameManagement\CommandResults.cs" /> <Compile Include="GameManagement\CommandResults.cs" />

View file

@ -142,7 +142,7 @@ namespace MudEngine.Scripting
Directory.CreateDirectory("temp"); Directory.CreateDirectory("temp");
//Setup the additional sourcecode that's needed in the script. //Setup the additional sourcecode that's needed in the script.
String[] usingStatements = new String[] { "using System;", "using MudEngine.GameObjects;", "using MudEngine.GameObjects.Characters;", "using MudEngine.GameObjects.Environment;", "using MudEngine.GameObjects.Items;", "using MudEngine.GameManagement;", "using MudEngine.FileSystem;", "using MudEngine.Scripting;" }; String[] usingStatements = new String[] { "using System;", "using System.Collections.Generic;", "using MudEngine.GameObjects;", "using MudEngine.GameObjects.Characters;", "using MudEngine.GameObjects.Environment;", "using MudEngine.GameObjects.Items;", "using MudEngine.GameManagement;", "using MudEngine.FileSystem;", "using MudEngine.Scripting;" };
foreach (String script in scripts) foreach (String script in scripts)
{ {

View file

@ -45,8 +45,11 @@
<ItemGroup> <ItemGroup>
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<None Include="Scripts\CommandHelp.cs">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Scripts\CommandCreate.cs"> <None Include="Scripts\CommandCreate.cs">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
<None Include="Scripts\CommandSay.cs"> <None Include="Scripts\CommandSay.cs">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
@ -60,6 +63,9 @@
<None Include="Scripts\EarthGame.cs"> <None Include="Scripts\EarthGame.cs">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Include="Settings.ini">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\MudEngine\MudEngine.csproj"> <ProjectReference Include="..\MudEngine\MudEngine.csproj">

View file

@ -130,8 +130,9 @@ namespace MudGame
{ {
Log.Write("Critical Error! " + ex.Message); Log.Write("Critical Error! " + ex.Message);
} }
//Save the game on shut-down. //The Game should save itself during shutdown, requiring to save it on the runtime end will
game.Save(); //present possible issues with 3rd party runtimes not saving if they don't know better to do so.
//game.Save();
} }
} }
} }

View file

@ -2,7 +2,7 @@ public class CommandClear : IGameCommand
{ {
public Boolean Override { get; set; } public Boolean Override { get; set; }
public String Name { get; set; } public String Name { get; set; }
public List<String> Help { get; set; }
public void Execute(String command, BaseCharacter player) public void Execute(String command, BaseCharacter player)
{ {
player.FlushConsole(); player.FlushConsole();

View file

@ -1,135 +1,314 @@
 public class CommandCreate : IGameCommand public class CommandCreate : IGameCommand
{
public Boolean Override { get; set; }
public String Name { get; set; }
public List<String> Help { get; set; }
public CommandCreate()
{ {
public Boolean Override { get; set; } Help = new List<string>();
public String Name { get; set; } Help.Add("Allows for the creation of environment objects.");
Help.Add("Linking of Rooms are not supported yet.");
//Help.Add("In order to link Rooms together use the LinkRoom command.");
}
public void Execute(String command, BaseCharacter player) public void Execute(String command, BaseCharacter player)
{
if ((player.Role == SecurityRoles.Player) || (player.Role == SecurityRoles.NPC))
{ {
if ((player.Role == SecurityRoles.Player) || (player.Role == SecurityRoles.NPC)) return; //Don't let them know this even exists.
{
return; //Don't let them know this even exists.
}
//Build our create menu.
player.Send("");
player.Send("Welcome to " + player.ActiveGame.GameTitle + " World Creation Tool.");
player.Send("What would you like to create?");
player.Send("");
player.Send("1: Realm");
player.Send("2: Zone");
player.Send("3: Room");
player.Send("4: Exit Tool");
player.Send("Selection: ", false);
Int32 selection = Convert.ToInt32(player.ReadInput());
//Fire off what ever Method we need to, according to the users input.
switch (selection)
{
case 1:
CreateRealm(player);
break;
case 2:
CreateZone(player);
break;
}
} }
//Creates a Realm. //Build our create menu.
public void CreateRealm(BaseCharacter player) player.Send("");
player.Send("Welcome to " + player.ActiveGame.GameTitle + " World Creation Tool.");
player.Send("What would you like to create?");
player.Send("");
player.Send("1: Realm");
player.Send("2: Zone");
player.Send("3: Room");
player.Send("4: Exit Tool");
player.Send("At point during creation, you may type 'Cancel' to exit with no changes saved.");
player.Send("");
player.Send("Selection: ", false);
Int32 selection = 0;
String input = player.ReadInput();
//Allows for aborting the creation tool if the user wants too.
if (input.ToLower() == "cancel")
{ {
//Instance a new Realm. player.Send("Creation aborted.");
Realm realm = new Realm(player.ActiveGame); return;
Boolean isLegalName = false;
while (!isLegalName)
{
isLegalName = true;
//Get the name of this Realm from the player.
player.Send("Realm Name: ", false);
realm.Name = player.ReadInput();
//Check if a Realm with this name already exists.
foreach (Realm r in player.ActiveGame.World.RealmCollection)
{
if (r.Name == realm.Name)
{
player.Send("Realm already exists!");
isLegalName = false;
}
}
}
player.ActiveGame.World.AddRealm(realm);
Log.Write(player.Name + " has created a Realm called " + realm.Name);
player.Send(realm.Name + " has been created and added to the world.");
} }
public void CreateZone(BaseCharacter player) try
{ {
player.Send("Select which Realm this Zone will belong to."); selection = Convert.ToInt32(input);
Boolean isValidRealm = false; }
String input = ""; catch (Exception)
Realm realm = new Realm(player.ActiveGame); {
Log.Write("Invalid selection!");
while (!isValidRealm) player.Send("Invalid selection!");
{ player.Send("Creation aborted.");
isValidRealm = true;//Default to true, assume the user entered a valid name. return;
foreach (Realm r in player.ActiveGame.World.RealmCollection) }
{ //Fire off what ever Method we need to, according to the users input.
player.Send(r.Filename + " | ", false); switch (selection)
} {
case 1:
input = player.ReadInput(); CreateRealm(player);
break;
//Ensure it's a valid name, if not then loop back and try again. case 2:
foreach (Realm r in player.ActiveGame.World.RealmCollection) CreateZone(player);
{ break;
if (r.Filename.ToLower() == input.ToLower()) case 3:
{ CreateRoom(player);
isValidRealm = true; break;
realm = r; case 4:
break; return;
}
else
{
isValidRealm = false;
}
}
if (!isValidRealm)
player.Send("That Realm does not exist! Please try again.");
}
Zone zone = new Zone(player.ActiveGame);
realm.AddZone(zone);
Boolean isValidZone = false;
while (!isValidZone)
{
isValidZone = true; //assume the user will enter a correct value.
player.Send("Enter a name for this Zone: ", false);
String name = player.ReadInput();
if (String.IsNullOrEmpty(name))
continue;
foreach (Zone z in realm.ZoneCollection)
{
if (z.Name == name)
{
isValidZone = false;
break;
}
}
if (isValidZone)
{
zone.Name = name;
}
}
Log.Write(player.Name + " has created a Zone called " + zone.Name + " within the Realm " + realm.Name);
player.Send(zone.Name + " has been created and added to Realm " + realm.Name + ".");
} }
} }
//Creates a Realm.
public void CreateRealm(BaseCharacter player)
{
//Instance a new Realm.
Realm realm = new Realm(player.ActiveGame);
Boolean isLegalName = false;
while (!isLegalName)
{
isLegalName = true;
//Get the name of this Realm from the player.
player.Send("Realm Name: ", false);
realm.Name = player.ReadInput();
//Check for canceling
if (realm.Name.ToLower() == "cancel")
{
player.Send("Creation aborted.");
return;
}
//Check if a Realm with this name already exists.
foreach (Realm r in player.ActiveGame.World.RealmCollection)
{
if (r.Name == realm.Name)
{
player.Send("Realm already exists!");
isLegalName = false;
}
}
}
player.ActiveGame.World.AddRealm(realm);
Log.Write(player.Name + " has created a Realm called " + realm.Name);
player.Send(realm.Name + " has been created and added to the world.");
}
public void CreateZone(BaseCharacter player)
{
player.Send("Select which Realm this Zone will belong to.");
Boolean isValidRealm = false;
String input = "";
Realm realm = new Realm(player.ActiveGame);
while (!isValidRealm)
{
isValidRealm = true;//Default to true, assume the user entered a valid name.
foreach (Realm r in player.ActiveGame.World.RealmCollection)
{
player.Send(r.Filename + " | ", false);
}
player.Send("");
player.Send("Selection: ", false);
input = player.ReadInput();
if (input.ToLower() == "cancel")
{
player.Send("Zone creation aborted.");
return;
}
//Ensure it's a valid name, if not then loop back and try again.
foreach (Realm r in player.ActiveGame.World.RealmCollection)
{
if (r.Filename.ToLower() == input.ToLower())
{
isValidRealm = true;
realm = r;
break;
}
else
{
isValidRealm = false;
}
}
if (!isValidRealm)
player.Send("That Realm does not exist! Please try again.");
}
Zone zone = new Zone(player.ActiveGame);
//realm.AddZone(zone);
Boolean isValidZone = false;
player.Send(""); //blank line
while (!isValidZone)
{
isValidZone = true; //assume the user will enter a correct value.
player.Send("Enter a name for this Zone: ", false);
String name = player.ReadInput();
if (String.IsNullOrEmpty(name))
continue;
foreach (Zone z in realm.ZoneCollection)
{
if (z.Name == name)
{
isValidZone = false;
break;
}
}
if (isValidZone)
{
zone.Name = name;
}
}
Log.Write(player.Name + " has created a Zone called " + zone.Name + " within the Realm " + realm.Name);
player.Send(zone.Name + " has been created and added to Realm " + realm.Name + ".");
realm.AddZone(zone);
}
public void CreateRoom(BaseCharacter player)
{
player.Send("Select which Realm this Zone will belong to.");
Boolean isValidRealm = false;
String input = "";
Realm realm = new Realm(player.ActiveGame);
while (!isValidRealm)
{
isValidRealm = true;//Default to true, assume the user entered a valid name.
foreach (Realm r in player.ActiveGame.World.RealmCollection)
{
player.Send(r.Filename + " | ", false);
}
player.Send("");
player.Send("Selection: ", false);
input = player.ReadInput();
if (input.ToLower() == "cancel")
{
player.Send("Zone creation aborted.");
return;
}
//Ensure it's a valid name, if not then loop back and try again.
foreach (Realm r in player.ActiveGame.World.RealmCollection)
{
if (r.Filename.ToLower() == input.ToLower())
{
isValidRealm = true;
realm = r;
break;
}
else
{
isValidRealm = false;
}
}
if (!isValidRealm)
player.Send("That Realm does not exist! Please try again.");
}
Zone zone = new Zone(player.ActiveGame);
//realm.AddZone(zone);
Boolean isValidZone = false;
player.Send(""); //blank line
while (!isValidZone)
{
isValidZone = true;//Default to true, assume the user entered a valid name.
foreach (Zone z in realm.ZoneCollection)
{
player.Send(z.Filename + " | ", false);
}
player.Send("");
player.Send("Selection: ", false);
input = player.ReadInput();
if (input.ToLower() == "cancel")
{
player.Send("Room creation aborted.");
return;
}
//Ensure it's a valid name, if not then loop back and try again.
foreach (Zone z in realm.ZoneCollection)
{
if (z.Filename.ToLower() == input.ToLower())
{
isValidZone = true;
zone = z;
break;
}
else
{
isValidZone = false;
}
}
if (!isValidZone)
player.Send("That Zone does not exist! Please try again.");
}
//Create the Room.
Room room = new Room(player.ActiveGame);
Boolean isValidRoom = false;
player.Send(""); //blank line
while (!isValidRoom)
{
isValidRoom = true; //assume the user will enter a correct value.
player.Send("Enter a name for this Room: ", false);
String name = player.ReadInput();
if (String.IsNullOrEmpty(name))
continue;
foreach (Room r in zone.RoomCollection)
{
if (r.Name == name)
{
isValidRoom = false;
break;
}
}
if (isValidRoom)
{
room.Name = name;
}
}
Log.Write(player.Name + " has created a Room called " + zone.Name + " within the Zone " + realm.Name + "->" + zone.Name);
player.Send(room.Name + " has been created and added to " + realm.Name + "->" + zone.Name + ".");
zone.AddRoom(room);
}
}

View file

@ -0,0 +1,35 @@
 public class CommandHelp : IGameCommand
{
public Boolean Override { get; set; }
public String Name { get; set; }
public List<String> Help { get; set; }
public void Execute(String command, BaseCharacter player)
{
string topic = command.Substring("Help".Length);
//TODO: Help command should display a complete list of available commands and should have self contained help topics.
if (topic.Length == 0)
{
player.Send("Available commands: ", false);
foreach (String cmd in CommandEngine.GetCommands())
{
IGameCommand g = CommandEngine.GetCommand(cmd);
player.Send(CommandEngine.GetCommandName(g) + ", ", false);
}
player.Send("");
player.Send("Usage: Help 'Command'");
return;
}
else
topic = topic.Trim();
IGameCommand gc = CommandEngine.GetCommand("Command" + topic);
foreach (String help in gc.Help)
{
player.Send(help);
}
}
}

View file

@ -2,7 +2,7 @@ public class CommandSay : IGameCommand
{ {
public Boolean Override { get; set; } public Boolean Override { get; set; }
public String Name { get; set; } public String Name { get; set; }
public List<String> Help { get; set; }
public void Execute(String command, BaseCharacter player) public void Execute(String command, BaseCharacter player)
{ {
if (command.Length <= 4) //user only sent 'Say' or 'Say ' if (command.Length <= 4) //user only sent 'Say' or 'Say '