MudEngine:

- Realm, Room and Zone editing no longer closes the menu once a task is finished. Use the Exit menu option to close the editing menu
 - Revised how the Game checks for existing InitialLocations. If a InitialLocation does not exist, but is created during server runtime, new players will automatically be placed there without the need to restart the server.
 - Improved the List command.
This commit is contained in:
Scionwest_cp 2010-09-12 16:18:28 -07:00
parent b3238d0227
commit 304b2d07eb
7 changed files with 155 additions and 91 deletions

View file

@ -21,7 +21,8 @@ namespace MudEngine.Commands
public List<String> Help { get; set; } public List<String> Help { get; set; }
private Realm realm; private Realm realm;
BaseCharacter player; private BaseCharacter player;
private Boolean isEditing;
public CommandEditRealm() public CommandEditRealm()
{ {
@ -52,7 +53,7 @@ namespace MudEngine.Commands
//We have a filename, retrieve the Realm the admin wants to edit. //We have a filename, retrieve the Realm the admin wants to edit.
realm = player.ActiveGame.World.GetRealm(filename); realm = player.ActiveGame.World.GetRealm(filename);
//If no Realm was retrieved (due to it not existing), let the admin know //If no Realm was retrieved (due to it not existing), let the admin know
//that the Realm filename was not valid. //that the Realm filename was not valid.
if (realm == null) if (realm == null)
@ -60,29 +61,35 @@ namespace MudEngine.Commands
player.Send("Realm Editing canceled. The supplied Realm name is not valid."); player.Send("Realm Editing canceled. The supplied Realm name is not valid.");
return; return;
} }
//Otherwise, the Realm does exist and was retrieved. //Otherwise, the Realm does exist and was retrieved.
//Lets build our Editing menu's and allow for Realm Editing. //Lets build our Editing menu's and allow for Realm Editing.
else else
{ {
//Construct the main editing menu. //Always re-build the menu so the user doesn't need to re-enter the edit command.
BuildMenuMain(); //When the user selects the exit option, the loop will end.
isEditing = true;
//Find out what menu option the admin wants to use. while (isEditing)
Int32 value = 0;
//Attempt to convert the String entered by the admin into a numeric value
try
{ {
value = Convert.ToInt32(player.ReadInput()); //Construct the main editing menu.
} BuildMenuMain();
//Find out what menu option the admin wants to use.
Int32 value = 0;
//Attempt to convert the String entered by the admin into a numeric value
try
{
value = Convert.ToInt32(player.ReadInput());
}
//If a non-numeric value is supplied, the conversion failed. This is us catching that failure. //If a non-numeric value is supplied, the conversion failed. This is us catching that failure.
catch catch
{ {
player.Send("Realm Editing canceled. The supplied value was not numeric!"); player.Send("Realm Editing canceled. The supplied value was not numeric!");
return; return;
} }
//Parse the menu option that the admin supplied. //Parse the menu option that the admin supplied.
ParseMenuSelection(value); ParseMenuSelection(value);
}
//let the admin know that we have now exited the editor. //let the admin know that we have now exited the editor.
player.Send("Editing completed."); player.Send("Editing completed.");
} }
@ -135,7 +142,7 @@ namespace MudEngine.Commands
player.Send("Example: A Realm with a Visible name of \"My Test Realm\" can have a filename of \"Test.Realm\". You would access this object as a Admin by specifying a object name of \"Test\""); player.Send("Example: A Realm with a Visible name of \"My Test Realm\" can have a filename of \"Test.Realm\". You would access this object as a Admin by specifying a object name of \"Test\"");
player.Send("Select from the available options below:"); player.Send("Select from the available options below:");
player.Send(""); player.Send("");
player.Send("1: Realm Visibile Name"); player.Send("1: Realm Visibile Name");
player.Send("2: Realm Filename"); player.Send("2: Realm Filename");
player.Send("9: Exit"); player.Send("9: Exit");
@ -238,6 +245,7 @@ namespace MudEngine.Commands
ParseInitialSelection(entry); ParseInitialSelection(entry);
break; break;
case 9: case 9:
isEditing = false;
break; break;
default: default:
break; break;
@ -254,7 +262,7 @@ namespace MudEngine.Commands
String input = ""; String input = "";
switch (value) switch (value)
{ {
//Simple Description //Simple Description
case 1: case 1:
player.FlushConsole(); player.FlushConsole();
player.Send("Enter a simple description for this Realm."); player.Send("Enter a simple description for this Realm.");
@ -277,7 +285,7 @@ namespace MudEngine.Commands
player.ActiveGame.Save(); player.ActiveGame.Save();
player.Send("New Simple Description saved."); player.Send("New Simple Description saved.");
break; break;
//Detailed Description //Detailed Description
case 2: case 2:
Boolean isEditing = true; Boolean isEditing = true;
Int32 line = 1; Int32 line = 1;
@ -322,7 +330,7 @@ namespace MudEngine.Commands
else if (input.ToLower().StartsWith("edit")) else if (input.ToLower().StartsWith("edit"))
{ {
//Retrieve the line number from the users input. //Retrieve the line number from the users input.
String editLine= input.Substring("edit".Length).Trim(); String editLine = input.Substring("edit".Length).Trim();
//If no line number was provided, cancel. //If no line number was provided, cancel.
if (String.IsNullOrEmpty(editLine)) if (String.IsNullOrEmpty(editLine))
@ -543,33 +551,33 @@ namespace MudEngine.Commands
player.Send("Current Value: ", false); player.Send("Current Value: ", false);
player.Send(realm.Feel); player.Send(realm.Feel);
} }
player.Send("Enter Value: ", false); player.Send("Enter Value: ", false);
realm.Feel = player.ReadInput(); realm.Feel = player.ReadInput();
break; break;
case 2: //Listen case 2: //Listen
player.Send("Enter the new default LISTEN description for this Realm."); player.Send("Enter the new default LISTEN description for this Realm.");
player.Send("If you wish to clear the current description, just press ENTER to save a blank description."); player.Send("If you wish to clear the current description, just press ENTER to save a blank description.");
if (!String.IsNullOrEmpty(realm.Listen)) if (!String.IsNullOrEmpty(realm.Listen))
{ {
player.Send("Current Value: ", false); player.Send("Current Value: ", false);
player.Send(realm.Listen); player.Send(realm.Listen);
} }
player.Send("Enter value: ", false); player.Send("Enter value: ", false);
realm.Listen = player.ReadInput(); realm.Listen = player.ReadInput();
break; break;
case 3: //Smell case 3: //Smell
player.Send("Enter the new default SMELL description for this Realm."); player.Send("Enter the new default SMELL description for this Realm.");
player.Send("If you wish to clear the current description, just press ENTER to save a blank description."); player.Send("If you wish to clear the current description, just press ENTER to save a blank description.");
if (!String.IsNullOrEmpty(realm.Smell)) if (!String.IsNullOrEmpty(realm.Smell))
{ {
player.Send("Current Value: ", false); player.Send("Current Value: ", false);
player.Send(realm.Smell); player.Send(realm.Smell);
} }
player.Send("Enter value: ", false); player.Send("Enter value: ", false);
realm.Smell = player.ReadInput(); realm.Smell = player.ReadInput();
break; break;

View file

@ -21,7 +21,8 @@ namespace MudEngine.Commands
public List<String> Help { get; set; } public List<String> Help { get; set; }
private Room room; private Room room;
BaseCharacter player; private BaseCharacter player;
private Boolean isEditing;
public CommandEditRoom() public CommandEditRoom()
{ {
@ -82,25 +83,30 @@ namespace MudEngine.Commands
//Lets build our Editing menu's and allow for Room Editing. //Lets build our Editing menu's and allow for Room Editing.
else else
{ {
//Construct the main editing menu. isEditing = true;
BuildMenuMain();
//Find out what menu option the admin wants to use. while (isEditing)
Int32 value = 0;
//Attempt to convert the String entered by the admin into a numeric value
try
{ {
value = Convert.ToInt32(player.ReadInput()); //Construct the main editing menu.
} BuildMenuMain();
//If a non-numeric value is supplied, the conversion failed. This is us catching that failure.
catch
{
player.Send("Room Editing canceled. The supplied value was not numeric!");
return;
}
//Parse the menu option that the admin supplied. //Find out what menu option the admin wants to use.
ParseMenuSelection(value); Int32 value = 0;
//Attempt to convert the String entered by the admin into a numeric value
try
{
value = Convert.ToInt32(player.ReadInput());
}
//If a non-numeric value is supplied, the conversion failed. This is us catching that failure.
catch
{
player.Send("Room Editing canceled. The supplied value was not numeric!");
return;
}
//Parse the menu option that the admin supplied.
ParseMenuSelection(value);
}
//let the admin know that we have now exited the editor. //let the admin know that we have now exited the editor.
player.Send("Editing completed."); player.Send("Editing completed.");
} }
@ -120,7 +126,7 @@ namespace MudEngine.Commands
player.Send("3: Senses"); player.Send("3: Senses");
player.Send("4: Initial Room"); player.Send("4: Initial Room");
player.Send("5: Settings"); player.Send("5: Settings");
player.Send("6: Doorways"); //player.Send("6: Doorways");
player.Send("9: Exit"); player.Send("9: Exit");
player.Send("Enter numeric selection: ", false); player.Send("Enter numeric selection: ", false);
} }
@ -262,6 +268,7 @@ namespace MudEngine.Commands
case 6: //Doorways case 6: //Doorways
break; break;
case 9: case 9:
isEditing = false;
break; break;
default: default:
break; break;
@ -694,7 +701,7 @@ namespace MudEngine.Commands
//Next, we need to loop through every Room within this Room //Next, we need to loop through every Room within this Room
//and update their Rooms names to match the new one //and update their Rooms names to match the new one
foreach(Realm r in player.ActiveGame.World.RealmCollection) foreach (Realm r in player.ActiveGame.World.RealmCollection)
{ {
foreach (Zone z in r.ZoneCollection) foreach (Zone z in r.ZoneCollection)
{ {

View file

@ -21,7 +21,8 @@ namespace MudEngine.Commands
public List<String> Help { get; set; } public List<String> Help { get; set; }
private Zone zone; private Zone zone;
BaseCharacter player; private BaseCharacter player;
private Boolean isEditing;
public CommandEditZone() public CommandEditZone()
{ {
@ -76,25 +77,31 @@ namespace MudEngine.Commands
//Lets build our Editing menu's and allow for Zone Editing. //Lets build our Editing menu's and allow for Zone Editing.
else else
{ {
//Construct the main editing menu. //Always re-build the menu so the user doesn't need to re-enter the edit command.
BuildMenuMain(); //When the user selects the exit option, the loop will end.
isEditing = true;
//Find out what menu option the admin wants to use. while (isEditing)
Int32 value = 0;
//Attempt to convert the String entered by the admin into a numeric value
try
{ {
value = Convert.ToInt32(player.ReadInput()); //Construct the main editing menu.
} BuildMenuMain();
//If a non-numeric value is supplied, the conversion failed. This is us catching that failure.
catch
{
player.Send("Zone Editing canceled. The supplied value was not numeric!");
return;
}
//Parse the menu option that the admin supplied. //Find out what menu option the admin wants to use.
ParseMenuSelection(value); Int32 value = 0;
//Attempt to convert the String entered by the admin into a numeric value
try
{
value = Convert.ToInt32(player.ReadInput());
}
//If a non-numeric value is supplied, the conversion failed. This is us catching that failure.
catch
{
player.Send("Zone Editing canceled. The supplied value was not numeric!");
return;
}
//Parse the menu option that the admin supplied.
ParseMenuSelection(value);
}
//let the admin know that we have now exited the editor. //let the admin know that we have now exited the editor.
player.Send("Editing completed."); player.Send("Editing completed.");
} }
@ -113,7 +120,7 @@ namespace MudEngine.Commands
player.Send("2: Names"); player.Send("2: Names");
player.Send("3: Senses"); player.Send("3: Senses");
player.Send("4: Initial Zone"); player.Send("4: Initial Zone");
player.Send("5: Settings"); // player.Send("5: Settings");
player.Send("9: Exit"); player.Send("9: Exit");
player.Send("Enter numeric selection: ", false); player.Send("Enter numeric selection: ", false);
} }
@ -253,6 +260,7 @@ namespace MudEngine.Commands
case 5: //Settings case 5: //Settings
break; break;
case 9: case 9:
isEditing = false;
break; break;
default: default:
break; break;

View file

@ -195,6 +195,7 @@ namespace MudEngine.GameManagement
scriptEngine = new Scripting.ScriptEngine(this); scriptEngine = new Scripting.ScriptEngine(this);
World = new GameWorld(this); World = new GameWorld(this);
WorldTime = new GameTime(this); WorldTime = new GameTime(this);
InitialRealm = new Realm(this);
//Prepare the Save Paths for all of our Game objects. //Prepare the Save Paths for all of our Game objects.
DataPaths = new SaveDataPaths("World", "Player"); DataPaths = new SaveDataPaths("World", "Player");
@ -279,6 +280,17 @@ namespace MudEngine.GameManagement
//Load the game and world if it was previously saved. //Load the game and world if it was previously saved.
Load(); Load();
String[] env = InitialRealm.InitialZone.InitialRoom.RoomLocation.Split('>');
if (env.Length == 3)
{
if ((String.IsNullOrEmpty(env[0])) || (String.IsNullOrEmpty(env[1])) || (String.IsNullOrEmpty(env[2])))
{
Log.Write("Error: No starting location defined!");
}
}
else
Log.Write("Error: No starting location defined!");
Log.Write("Game startup complete."); Log.Write("Game startup complete.");
return true; return true;
} }
@ -429,6 +441,16 @@ namespace MudEngine.GameManagement
//Restore the world. //Restore the world.
World.Load(); World.Load();
//Check if any the initial room exists or not.
if ((this.InitialRealm == null) || (this.InitialRealm.InitialZone == null) || (this.InitialRealm.InitialZone.InitialRoom == null))
{
Log.Write("ERROR: No initial location defined. Game startup failed!");
Log.Write("Players will start in the Abyss. Each player will contain their own instance of this room.");
//return false;
}
else
Log.Write("Initial Location loaded: " + this.InitialRealm.InitialZone.InitialRoom.RoomLocationWithoutExtension);
Log.Write("Game Restore complete."); Log.Write("Game Restore complete.");
} }

View file

@ -74,17 +74,6 @@ namespace MudEngine.GameManagement
break; break;
} }
} }
//Check if any the initial room exists or not.
if ((_Game.InitialRealm == null) || (_Game.InitialRealm.InitialZone == null) || (_Game.InitialRealm.InitialZone.InitialRoom == null))
{
Log.Write("ERROR: No initial location defined. Game startup failed!");
Log.Write("Players will start in the Abyss. Each player will contain their own instance of this room.");
//return false;
}
else
Log.Write("Initial Location loaded: " + _Game.InitialRealm.InitialZone.InitialRoom.RoomLocationWithoutExtension);
} }
public void Save() public void Save()

View file

@ -70,7 +70,7 @@ namespace MudEngine.GameObjects.Environment
{ {
get get
{ {
return this.Realm + ">" + Zone + ">" + Filename; return this.Realm + ">" + this.Zone + ">" + this.Filename;
} }
} }

View file

@ -57,26 +57,56 @@ public class CommandList : IGameCommand
switch (data[0]) switch (data[0])
{ {
case "realms": case "realms":
player.Send("Currently loaded Realm files:"); if (player.ActiveGame.World.RealmCollection.Count == 0)
foreach (Realm r in player.ActiveGame.World.RealmCollection) player.Send("There are currently no loaded Realm files.");
player.Send(r.Filename + " | ", false); else
{
player.Send("Currently loaded Realm files:");
foreach (Realm r in player.ActiveGame.World.RealmCollection)
player.Send(r.Filename + " | ", false);
}
break; break;
case "players": case "players":
player.Send("Players with created characters:"); if (System.IO.Directory.GetFiles(player.ActiveGame.DataPaths.Players, "*.character").Length == 0)
BaseCharacter p = new BaseCharacter(player.ActiveGame); player.Send("There are currently no characters created on this server.");
foreach (String file in System.IO.Directory.GetFiles(player.ActiveGame.DataPaths.Players, "*.character")) else
{ {
p.Load(file); player.Send("Players with created characters:");
player.Send(p.Name + " | ", false); BaseCharacter p = new BaseCharacter(player.ActiveGame);
foreach (String file in System.IO.Directory.GetFiles(player.ActiveGame.DataPaths.Players, "*.character"))
{
p.Load(file);
player.Send(p.Name + " | ", false);
}
} }
break; break;
case "zones": case "zones":
player.Send("Currently loaded Zones. This spans across every Realm in the world."); if (player.ActiveGame.World.RealmCollection.Count == 0)
foreach (Realm r in player.ActiveGame.World.RealmCollection)
{ {
foreach (Zone z in r.ZoneCollection) player.Send("There are currently no Zones created on this server.");
}
else
{
List<String> names = new List<String>();
foreach (Realm r in player.ActiveGame.World.RealmCollection)
{ {
player.Send(System.IO.Path.GetFileNameWithoutExtension(r.Filename) + ">" + System.IO.Path.GetFileNameWithoutExtension(z.Filename)); foreach (Zone z in r.ZoneCollection)
{
names.Add(System.IO.Path.GetFileNameWithoutExtension(r.Filename) + ">" + System.IO.Path.GetFileNameWithoutExtension(z.Filename));
}
}
if (names.Count == 0)
{
player.Send("There are currently no Zones created on this server.");
}
else
{
player.Send("Currently loaded Zones. This spans across every Realm in the world.");
foreach (String name in names)
{
player.Send(name);
}
} }
} }
break; break;