* DataPaths now has two new helper methods. GetFilePath for returning the path to a supplied filename for a specified object type. GetExtension which returns a file extension for the specified object type.

* XMLData now contains a GetData() method for returning data from the stored data collection.
* XMLData now contains a Load() method for loading a previously saved XML data file.
* StandardCharacter now automatically generates a filename.
* StandardCharacter.Connected added.  Use Connected to check if they are connected to the server regardless of the values for Enabled and LoggedIn.  LoggedIn is now true once the Login command is completed.
* Default Character Role is now Player.
* Server.ServerOwner property added.  When a character is logged in matching the ServerOwner name, it will automatically be assigned the Admin role.
* StandardCharacter.ExecuteSilentCommand() method added for executing a command and not having the "Command: " line printed to the screen when the command is completed.  Useful for daisy chained commands.
* StandardCharacter login code is now 100% completed.  Including save/load code and new character creation.
* StandardCharacter.SetRole() method added.  Admins can set the role of any other character in the game if they want to.
* BaseScript & StandardCharacter now have their Load() code fully implemented.  They can save and load their files now.
* Player creation command added.  Can only be executed from within the login command.  If it is executed from any other object it will bail.
* Stop command now only works when a Character with Role = Admin issues the command.  During development of a MUD Game, this would typically be the Server.ServerOwner character who will have Admin rights.
* ConnectionManager had some bugs fixed such as not removing Threads from the Thread collection when a character disconnected.  Also re-organized the character connection code some.
This commit is contained in:
Scionwest_cp 2012-03-03 23:29:58 -08:00
parent 4b6c394f43
commit f2c5b594c5
13 changed files with 307 additions and 34 deletions

View file

@ -6,6 +6,7 @@ using System.Xml.Linq;
using System.Reflection;
using MudEngine.GameScripts;
using MudEngine.Core;
namespace MudEngine.DAL
{
@ -19,6 +20,7 @@ namespace MudEngine.DAL
public XMLData(String objectType)
{
SaveData = new XElement(objectType);
this._RootNode = objectType;
}
public void AddSaveData(String property, String value)
@ -26,6 +28,17 @@ namespace MudEngine.DAL
this.SaveData.Add(new XElement(property, value));
}
public String GetData(String property)
{
foreach (XElement element in SaveData.Elements())
{
if (element.Name.LocalName == property)
return element.Value;
}
return String.Empty;
}
public Boolean Save(String filename)
{
try
@ -38,5 +51,22 @@ namespace MudEngine.DAL
return false;
}
}
public Boolean Load(String filename)
{
try
{
this.SaveData = XElement.Load(filename);
return true;
}
catch (Exception ex)
{
Logger.WriteLine(ex.Message);
return false;
}
}
private String _RootNode;
}
}