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:
parent
b3238d0227
commit
304b2d07eb
7 changed files with 155 additions and 91 deletions
|
@ -21,7 +21,8 @@ namespace MudEngine.Commands
|
|||
public List<String> Help { get; set; }
|
||||
|
||||
private Realm realm;
|
||||
BaseCharacter player;
|
||||
private BaseCharacter player;
|
||||
private Boolean isEditing;
|
||||
|
||||
public CommandEditRealm()
|
||||
{
|
||||
|
@ -60,29 +61,35 @@ namespace MudEngine.Commands
|
|||
player.Send("Realm Editing canceled. The supplied Realm name is not valid.");
|
||||
return;
|
||||
}
|
||||
//Otherwise, the Realm does exist and was retrieved.
|
||||
//Lets build our Editing menu's and allow for Realm Editing.
|
||||
//Otherwise, the Realm does exist and was retrieved.
|
||||
//Lets build our Editing menu's and allow for Realm Editing.
|
||||
else
|
||||
{
|
||||
//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
|
||||
//Always re-build the menu so the user doesn't need to re-enter the edit command.
|
||||
//When the user selects the exit option, the loop will end.
|
||||
isEditing = true;
|
||||
while (isEditing)
|
||||
{
|
||||
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.
|
||||
catch
|
||||
{
|
||||
player.Send("Realm Editing canceled. The supplied value was not numeric!");
|
||||
return;
|
||||
}
|
||||
catch
|
||||
{
|
||||
player.Send("Realm Editing canceled. The supplied value was not numeric!");
|
||||
return;
|
||||
}
|
||||
|
||||
//Parse the menu option that the admin supplied.
|
||||
ParseMenuSelection(value);
|
||||
//Parse the menu option that the admin supplied.
|
||||
ParseMenuSelection(value);
|
||||
}
|
||||
//let the admin know that we have now exited the editor.
|
||||
player.Send("Editing completed.");
|
||||
}
|
||||
|
@ -238,6 +245,7 @@ namespace MudEngine.Commands
|
|||
ParseInitialSelection(entry);
|
||||
break;
|
||||
case 9:
|
||||
isEditing = false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -254,7 +262,7 @@ namespace MudEngine.Commands
|
|||
String input = "";
|
||||
switch (value)
|
||||
{
|
||||
//Simple Description
|
||||
//Simple Description
|
||||
case 1:
|
||||
player.FlushConsole();
|
||||
player.Send("Enter a simple description for this Realm.");
|
||||
|
@ -277,7 +285,7 @@ namespace MudEngine.Commands
|
|||
player.ActiveGame.Save();
|
||||
player.Send("New Simple Description saved.");
|
||||
break;
|
||||
//Detailed Description
|
||||
//Detailed Description
|
||||
case 2:
|
||||
Boolean isEditing = true;
|
||||
Int32 line = 1;
|
||||
|
@ -322,7 +330,7 @@ namespace MudEngine.Commands
|
|||
else if (input.ToLower().StartsWith("edit"))
|
||||
{
|
||||
//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 (String.IsNullOrEmpty(editLine))
|
||||
|
|
|
@ -21,7 +21,8 @@ namespace MudEngine.Commands
|
|||
public List<String> Help { get; set; }
|
||||
|
||||
private Room room;
|
||||
BaseCharacter player;
|
||||
private BaseCharacter player;
|
||||
private Boolean isEditing;
|
||||
|
||||
public CommandEditRoom()
|
||||
{
|
||||
|
@ -82,25 +83,30 @@ namespace MudEngine.Commands
|
|||
//Lets build our Editing menu's and allow for Room Editing.
|
||||
else
|
||||
{
|
||||
//Construct the main editing menu.
|
||||
BuildMenuMain();
|
||||
isEditing = true;
|
||||
|
||||
//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
|
||||
while (isEditing)
|
||||
{
|
||||
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;
|
||||
}
|
||||
//Construct the main editing menu.
|
||||
BuildMenuMain();
|
||||
|
||||
//Parse the menu option that the admin supplied.
|
||||
ParseMenuSelection(value);
|
||||
//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.
|
||||
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.
|
||||
player.Send("Editing completed.");
|
||||
}
|
||||
|
@ -120,7 +126,7 @@ namespace MudEngine.Commands
|
|||
player.Send("3: Senses");
|
||||
player.Send("4: Initial Room");
|
||||
player.Send("5: Settings");
|
||||
player.Send("6: Doorways");
|
||||
//player.Send("6: Doorways");
|
||||
player.Send("9: Exit");
|
||||
player.Send("Enter numeric selection: ", false);
|
||||
}
|
||||
|
@ -262,6 +268,7 @@ namespace MudEngine.Commands
|
|||
case 6: //Doorways
|
||||
break;
|
||||
case 9:
|
||||
isEditing = false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -694,7 +701,7 @@ namespace MudEngine.Commands
|
|||
|
||||
//Next, we need to loop through every Room within this Room
|
||||
//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)
|
||||
{
|
||||
|
|
|
@ -21,7 +21,8 @@ namespace MudEngine.Commands
|
|||
public List<String> Help { get; set; }
|
||||
|
||||
private Zone zone;
|
||||
BaseCharacter player;
|
||||
private BaseCharacter player;
|
||||
private Boolean isEditing;
|
||||
|
||||
public CommandEditZone()
|
||||
{
|
||||
|
@ -76,25 +77,31 @@ namespace MudEngine.Commands
|
|||
//Lets build our Editing menu's and allow for Zone Editing.
|
||||
else
|
||||
{
|
||||
//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
|
||||
//Always re-build the menu so the user doesn't need to re-enter the edit command.
|
||||
//When the user selects the exit option, the loop will end.
|
||||
isEditing = true;
|
||||
while (isEditing)
|
||||
{
|
||||
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;
|
||||
}
|
||||
//Construct the main editing menu.
|
||||
BuildMenuMain();
|
||||
|
||||
//Parse the menu option that the admin supplied.
|
||||
ParseMenuSelection(value);
|
||||
//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.
|
||||
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.
|
||||
player.Send("Editing completed.");
|
||||
}
|
||||
|
@ -113,7 +120,7 @@ namespace MudEngine.Commands
|
|||
player.Send("2: Names");
|
||||
player.Send("3: Senses");
|
||||
player.Send("4: Initial Zone");
|
||||
player.Send("5: Settings");
|
||||
// player.Send("5: Settings");
|
||||
player.Send("9: Exit");
|
||||
player.Send("Enter numeric selection: ", false);
|
||||
}
|
||||
|
@ -253,6 +260,7 @@ namespace MudEngine.Commands
|
|||
case 5: //Settings
|
||||
break;
|
||||
case 9:
|
||||
isEditing = false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -195,6 +195,7 @@ namespace MudEngine.GameManagement
|
|||
scriptEngine = new Scripting.ScriptEngine(this);
|
||||
World = new GameWorld(this);
|
||||
WorldTime = new GameTime(this);
|
||||
InitialRealm = new Realm(this);
|
||||
|
||||
//Prepare the Save Paths for all of our Game objects.
|
||||
DataPaths = new SaveDataPaths("World", "Player");
|
||||
|
@ -279,6 +280,17 @@ namespace MudEngine.GameManagement
|
|||
//Load the game and world if it was previously saved.
|
||||
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.");
|
||||
return true;
|
||||
}
|
||||
|
@ -429,6 +441,16 @@ namespace MudEngine.GameManagement
|
|||
//Restore the world.
|
||||
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.");
|
||||
}
|
||||
|
||||
|
|
|
@ -74,17 +74,6 @@ namespace MudEngine.GameManagement
|
|||
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()
|
||||
|
|
|
@ -70,7 +70,7 @@ namespace MudEngine.GameObjects.Environment
|
|||
{
|
||||
get
|
||||
{
|
||||
return this.Realm + ">" + Zone + ">" + Filename;
|
||||
return this.Realm + ">" + this.Zone + ">" + this.Filename;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,26 +57,56 @@ public class CommandList : IGameCommand
|
|||
switch (data[0])
|
||||
{
|
||||
case "realms":
|
||||
player.Send("Currently loaded Realm files:");
|
||||
foreach (Realm r in player.ActiveGame.World.RealmCollection)
|
||||
player.Send(r.Filename + " | ", false);
|
||||
if (player.ActiveGame.World.RealmCollection.Count == 0)
|
||||
player.Send("There are currently no loaded Realm files.");
|
||||
else
|
||||
{
|
||||
player.Send("Currently loaded Realm files:");
|
||||
foreach (Realm r in player.ActiveGame.World.RealmCollection)
|
||||
player.Send(r.Filename + " | ", false);
|
||||
}
|
||||
break;
|
||||
case "players":
|
||||
player.Send("Players with created characters:");
|
||||
BaseCharacter p = new BaseCharacter(player.ActiveGame);
|
||||
foreach (String file in System.IO.Directory.GetFiles(player.ActiveGame.DataPaths.Players, "*.character"))
|
||||
if (System.IO.Directory.GetFiles(player.ActiveGame.DataPaths.Players, "*.character").Length == 0)
|
||||
player.Send("There are currently no characters created on this server.");
|
||||
else
|
||||
{
|
||||
p.Load(file);
|
||||
player.Send(p.Name + " | ", false);
|
||||
player.Send("Players with created characters:");
|
||||
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;
|
||||
case "zones":
|
||||
player.Send("Currently loaded Zones. This spans across every Realm in the world.");
|
||||
foreach (Realm r in player.ActiveGame.World.RealmCollection)
|
||||
if (player.ActiveGame.World.RealmCollection.Count == 0)
|
||||
{
|
||||
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue