diff --git a/MudEngine/Commands/CommandExit.cs b/MudEngine/Commands/CommandExit.cs index fd17a93..1ea93cb 100644 --- a/MudEngine/Commands/CommandExit.cs +++ b/MudEngine/Commands/CommandExit.cs @@ -16,6 +16,13 @@ namespace MudEngine.Commands { public Boolean Override { get; set; } public String Name { get; set; } + public List Help { get; set; } + + public CommandExit() + { + Help = new List(); + Help.Add("Exits the game cleanly."); + } public void Execute(String command, BaseCharacter player) { diff --git a/MudEngine/Commands/CommandGetTime.cs b/MudEngine/Commands/CommandGetTime.cs index b6823d0..b138375 100644 --- a/MudEngine/Commands/CommandGetTime.cs +++ b/MudEngine/Commands/CommandGetTime.cs @@ -12,6 +12,13 @@ namespace MudEngine.Commands public String Name { get; set; } public Boolean Override { get; set; } + public List Help { get; set; } + + public CommandGetTime() + { + Help = new List(); + Help.Add("Gives you the current time and date in the game world."); + } public void Execute(String command, BaseCharacter player) { diff --git a/MudEngine/Commands/CommandLinkRoom.cs b/MudEngine/Commands/CommandLinkRoom.cs new file mode 100644 index 0000000..3a43ee1 --- /dev/null +++ b/MudEngine/Commands/CommandLinkRoom.cs @@ -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 Help { get; set; } + + public CommandLinkRoom() + { + Help = new List(); + 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); + } + } + } +} diff --git a/MudEngine/Commands/CommandLoad.cs b/MudEngine/Commands/CommandLoad.cs index c26ff65..d43bff3 100644 --- a/MudEngine/Commands/CommandLoad.cs +++ b/MudEngine/Commands/CommandLoad.cs @@ -15,7 +15,7 @@ namespace MudEngine.Commands { public Boolean Override { get; set; } public String Name { get; set; } - + public List Help { get; set; } public void Execute(String command, BaseCharacter player) { String path = player.ActiveGame.DataPaths.Players; diff --git a/MudEngine/Commands/CommandLogin.cs b/MudEngine/Commands/CommandLogin.cs index 05aa6e7..41a21d7 100644 --- a/MudEngine/Commands/CommandLogin.cs +++ b/MudEngine/Commands/CommandLogin.cs @@ -16,7 +16,7 @@ namespace MudEngine.Commands { public Boolean Override { get; set; } public String Name { get; set; } - + public List Help { get; set; } public void Execute(String command, BaseCharacter player) { player.Send(player.ActiveGame.GameTitle); diff --git a/MudEngine/Commands/CommandLook.cs b/MudEngine/Commands/CommandLook.cs index 3006aa5..de35709 100644 --- a/MudEngine/Commands/CommandLook.cs +++ b/MudEngine/Commands/CommandLook.cs @@ -16,7 +16,7 @@ namespace MudEngine.Commands { public String Name { get; set; } public Boolean Override { get; set; } - + public List Help { get; set; } public void Execute(String command, BaseCharacter player) { if (player.CurrentRoom == null) diff --git a/MudEngine/Commands/CommandRestart.cs b/MudEngine/Commands/CommandRestart.cs index 7f196aa..d4dd017 100644 --- a/MudEngine/Commands/CommandRestart.cs +++ b/MudEngine/Commands/CommandRestart.cs @@ -20,7 +20,7 @@ namespace MudEngine.Commands { public String Name { get; set; } public Boolean Override { get; set; } - + public List Help { get; set; } public void Execute(String command, BaseCharacter player) { if (player.Role == SecurityRoles.Admin) diff --git a/MudEngine/Commands/CommandSave.cs b/MudEngine/Commands/CommandSave.cs index 0bd601b..2d77635 100644 --- a/MudEngine/Commands/CommandSave.cs +++ b/MudEngine/Commands/CommandSave.cs @@ -15,7 +15,7 @@ namespace MudEngine.Commands { public Boolean Override { get; set; } public String Name { get; set; } - + public List Help { get; set; } public void Execute(String command, BaseCharacter player) { player.Save(player.ActiveGame.DataPaths.Players); diff --git a/MudEngine/Commands/CommandSaveWorld.cs b/MudEngine/Commands/CommandSaveWorld.cs index 9a2b98c..f5fba12 100644 --- a/MudEngine/Commands/CommandSaveWorld.cs +++ b/MudEngine/Commands/CommandSaveWorld.cs @@ -16,7 +16,7 @@ namespace MudEngine.Commands { public Boolean Override { get; set; } public String Name { get; set; } - + public List Help { get; set; } public void Execute(String command, BaseCharacter player) { if ((player.Role == SecurityRoles.Admin) || (player.Role == SecurityRoles.GM)) diff --git a/MudEngine/Commands/CommandWalk.cs b/MudEngine/Commands/CommandWalk.cs index 9fb6184..baefc60 100644 --- a/MudEngine/Commands/CommandWalk.cs +++ b/MudEngine/Commands/CommandWalk.cs @@ -16,6 +16,7 @@ namespace MudEngine.Commands { public String Name { get; set; } public Boolean Override { get; set; } + public List Help { get; set; } public void Execute(String command, BaseCharacter player) { diff --git a/MudEngine/GameManagement/CommandEngine.cs b/MudEngine/GameManagement/CommandEngine.cs index fff738a..c7bda29 100644 --- a/MudEngine/GameManagement/CommandEngine.cs +++ b/MudEngine/GameManagement/CommandEngine.cs @@ -57,6 +57,11 @@ namespace MudEngine.GameManagement return null; } + public static String GetCommandName(IGameCommand command) + { + return command.Name.Substring("Command".Length); + } + public static Boolean IsValidCommand(String Name) { if (CommandCollection.ContainsKey(Name.ToLower())) diff --git a/MudEngine/GameManagement/GameTime.cs b/MudEngine/GameManagement/GameTime.cs index 61aaa2c..98a5b86 100644 --- a/MudEngine/GameManagement/GameTime.cs +++ b/MudEngine/GameManagement/GameTime.cs @@ -142,11 +142,11 @@ namespace MudEngine.GameManagement DayTransitions = TimeOfDayOptions.Transition; - SecondsPerMinute = 5; - MinutesPerHour = 5; - HoursPerDay = 5; - DaysPerMonth = 31; - MonthsPerYear = 12; + SecondsPerMinute = 1; + MinutesPerHour = 1; + HoursPerDay = 1; + DaysPerMonth = 3; + MonthsPerYear = 3; CurrentWorldTime = InitialGameTime; } @@ -170,7 +170,7 @@ namespace MudEngine.GameManagement CurrentSystemTime = DateTime.Now; Int32 amount = Math.Abs(ts.Seconds); 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; } + + 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; + } } } diff --git a/MudEngine/GameManagement/ICommand.cs b/MudEngine/GameManagement/ICommand.cs index 9217541..d965057 100644 --- a/MudEngine/GameManagement/ICommand.cs +++ b/MudEngine/GameManagement/ICommand.cs @@ -18,6 +18,10 @@ namespace MudEngine.GameManagement String Name { get; set; } //Used to override commands with the same name Boolean Override { get; set; } + + //Used when the player enters the help command + List Help { get; set; } + //Executes the command. void Execute(String command, BaseCharacter player); } diff --git a/MudEngine/GameManagement/Log.cs b/MudEngine/GameManagement/Log.cs index 9817c74..1405c87 100644 --- a/MudEngine/GameManagement/Log.cs +++ b/MudEngine/GameManagement/Log.cs @@ -34,6 +34,7 @@ namespace MudEngine.GameManagement //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 + //TODO: Allow for enabling critical error messages being forced into the console, regardless if !IsMultiplayer if ((pushMessage) && (!IsVerbose)) Console.WriteLine(message); else diff --git a/MudEngine/MudEngine.csproj b/MudEngine/MudEngine.csproj index 2dc365a..895865e 100644 --- a/MudEngine/MudEngine.csproj +++ b/MudEngine/MudEngine.csproj @@ -59,6 +59,7 @@ + diff --git a/MudEngine/Scripting/ScriptEngine.cs b/MudEngine/Scripting/ScriptEngine.cs index 6223d04..58e9f6e 100644 --- a/MudEngine/Scripting/ScriptEngine.cs +++ b/MudEngine/Scripting/ScriptEngine.cs @@ -142,7 +142,7 @@ namespace MudEngine.Scripting Directory.CreateDirectory("temp"); //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) { diff --git a/MudGame/MudGame.csproj b/MudGame/MudGame.csproj index 3facf31..b863b05 100644 --- a/MudGame/MudGame.csproj +++ b/MudGame/MudGame.csproj @@ -45,8 +45,11 @@ + + Always + - PreserveNewest + Always PreserveNewest @@ -60,6 +63,9 @@ PreserveNewest + + Always + diff --git a/MudGame/Program.cs b/MudGame/Program.cs index 76f0c2d..487dfa4 100644 --- a/MudGame/Program.cs +++ b/MudGame/Program.cs @@ -130,8 +130,9 @@ namespace MudGame { Log.Write("Critical Error! " + ex.Message); } - //Save the game on shut-down. - game.Save(); + //The Game should save itself during shutdown, requiring to save it on the runtime end will + //present possible issues with 3rd party runtimes not saving if they don't know better to do so. + //game.Save(); } } } \ No newline at end of file diff --git a/MudGame/Scripts/CommandClear.cs b/MudGame/Scripts/CommandClear.cs index 24c28a6..f4ad4d0 100644 --- a/MudGame/Scripts/CommandClear.cs +++ b/MudGame/Scripts/CommandClear.cs @@ -2,7 +2,7 @@ public class CommandClear : IGameCommand { public Boolean Override { get; set; } public String Name { get; set; } - + public List Help { get; set; } public void Execute(String command, BaseCharacter player) { player.FlushConsole(); diff --git a/MudGame/Scripts/CommandCreate.cs b/MudGame/Scripts/CommandCreate.cs index c81358e..b830c39 100644 --- a/MudGame/Scripts/CommandCreate.cs +++ b/MudGame/Scripts/CommandCreate.cs @@ -1,135 +1,314 @@ - public class CommandCreate : IGameCommand +public class CommandCreate : IGameCommand +{ + public Boolean Override { get; set; } + public String Name { get; set; } + public List Help { get; set; } + + public CommandCreate() { - public Boolean Override { get; set; } - public String Name { get; set; } + Help = new List(); + 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. + } + + //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("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") + { + player.Send("Creation aborted."); + return; + } + + try + { + selection = Convert.ToInt32(input); + } + catch (Exception) + { + Log.Write("Invalid selection!"); + player.Send("Invalid selection!"); + player.Send("Creation aborted."); + return; + } + //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; + case 3: + CreateRoom(player); + break; + case 4: + return; + } + } + + //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") { - return; //Don't let them know this even exists. + 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); } - //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) + input = player.ReadInput(); + + if (input.ToLower() == "cancel") { - case 1: - CreateRealm(player); + 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; - case 2: - CreateZone(player); + } + 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; } } - //Creates a Realm. - public void CreateRealm(BaseCharacter player) + 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) { - //Instance a new Realm. - Realm realm = new Realm(player.ActiveGame); - Boolean isLegalName = false; - - while (!isLegalName) + isValidRealm = true;//Default to true, assume the user entered a valid name. + foreach (Realm r in player.ActiveGame.World.RealmCollection) { - isLegalName = true; - //Get the name of this Realm from the player. - player.Send("Realm Name: ", false); - realm.Name = player.ReadInput(); + player.Send(r.Filename + " | ", false); + } - //Check if a Realm with this name already exists. - foreach (Realm r in player.ActiveGame.World.RealmCollection) + 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()) { - if (r.Name == realm.Name) - { - player.Send("Realm already exists!"); - isLegalName = false; - } + isValidRealm = true; + realm = r; + break; + } + else + { + isValidRealm = 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."); + if (!isValidRealm) + player.Send("That Realm does not exist! Please try again."); } - public void CreateZone(BaseCharacter player) + Zone zone = new Zone(player.ActiveGame); + //realm.AddZone(zone); + + Boolean isValidZone = false; + player.Send(""); //blank line + + while (!isValidZone) { - player.Send("Select which Realm this Zone will belong to."); - Boolean isValidRealm = false; - String input = ""; - Realm realm = new Realm(player.ActiveGame); - - while (!isValidRealm) + isValidZone = true;//Default to true, assume the user entered a valid name. + foreach (Zone z in realm.ZoneCollection) { - 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); - } - - input = player.ReadInput(); - - //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(z.Filename + " | ", false); } - Zone zone = new Zone(player.ActiveGame); - realm.AddZone(zone); + player.Send(""); + player.Send("Selection: ", false); - Boolean isValidZone = false; + input = player.ReadInput(); - while (!isValidZone) + if (input.ToLower() == "cancel") { - isValidZone = true; //assume the user will enter a correct value. - player.Send("Enter a name for this Zone: ", false); - String name = player.ReadInput(); + player.Send("Room creation aborted."); + return; + } - if (String.IsNullOrEmpty(name)) - continue; - - foreach (Zone z in realm.ZoneCollection) + //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()) { - if (z.Name == name) - { - isValidZone = false; - break; - } + isValidZone = true; + zone = z; + break; } - - if (isValidZone) + else { - zone.Name = name; + isValidZone = false; } } - 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 + "."); + if (!isValidZone) + player.Send("That Zone does not exist! Please try again."); } - } \ No newline at end of file + + //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); + } +} \ No newline at end of file diff --git a/MudGame/Scripts/CommandHelp.cs b/MudGame/Scripts/CommandHelp.cs new file mode 100644 index 0000000..381fd35 --- /dev/null +++ b/MudGame/Scripts/CommandHelp.cs @@ -0,0 +1,35 @@ + public class CommandHelp : IGameCommand + { + public Boolean Override { get; set; } + public String Name { get; set; } + + public List 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); + } + } + } \ No newline at end of file diff --git a/MudGame/Scripts/CommandSay.cs b/MudGame/Scripts/CommandSay.cs index 904380f..5938aa2 100644 --- a/MudGame/Scripts/CommandSay.cs +++ b/MudGame/Scripts/CommandSay.cs @@ -2,7 +2,7 @@ public class CommandSay : IGameCommand { public Boolean Override { get; set; } public String Name { get; set; } - + public List Help { get; set; } public void Execute(String command, BaseCharacter player) { if (command.Length <= 4) //user only sent 'Say' or 'Say '