muddesigner/MudEngine/WinPC_Engine/DAL/DataPaths.cs
Scionwest_cp f2c5b594c5 * 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.
2012-03-03 23:29:58 -08:00

91 lines
2.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.IO;
namespace MudEngine.DAL
{
public enum DataTypes
{
Players,
Environments,
Characters,
Equipment
}
/// <summary>
/// Contains the paths for the engines file storage.
/// </summary>
public class DataPaths
{
public DataPaths()
{
String path = Assembly.GetExecutingAssembly().Location;
String assemblyFile = Path.GetFileName(path);
this._InstallRoot = path.Substring(0, path.Length - assemblyFile.Length);
this.SetAbsolutePath(Path.Combine(this._InstallRoot, "Players"), DataTypes.Players);
}
public void SetAbsolutePath(String path, DataTypes objectType)
{
if (!path.EndsWith(@"\"))
path = path.Insert(path.Length, @"\");
switch (objectType)
{
case DataTypes.Players:
this._Players = path;
break;
}
}
public void SetRelativePath(String path, DataTypes objectType)
{
}
public String GetPath(DataTypes objectType)
{
if (objectType == DataTypes.Players)
return this._Players;
else
return String.Empty;
}
public String GetFilePath(DataTypes objectType, String filename)
{
String result = String.Empty;
switch (objectType)
{
case DataTypes.Players:
result = Path.Combine(this._Players, filename + this.GetExtension(DataTypes.Players));
break;
}
return result;
}
public String GetExtension(DataTypes objectType)
{
String result = String.Empty;
switch (objectType)
{
case DataTypes.Players:
result = ".player";
break;
}
return result;
}
private String _InstallRoot;
private String _Players;
private String _Environments;
private String _Characters;
private String _Equipment;
}
}