MudEngine:

- Converted all Types from C# types to .NET Types (such as bool changed to Boolean, and int changed to Int32).
 - Zone no longer gets saved from within GameWorld.Save, but rather in Realm.Save()
 - Room no longer gets saved from within GameWorld.Save(), but rather in Zone.Save();
 - Added new SaveWorld command that admins only can execute to force save the world. It's not fully implemented at this time.

MudGame:
 - began work on command execution from within the server while it's running.
This commit is contained in:
Scionwest_cp 2010-08-14 00:20:43 -07:00
parent 9585cede63
commit a52ccf8da9
36 changed files with 365 additions and 297 deletions

View file

@ -9,7 +9,7 @@ namespace MUDCompiler
{
class Program
{
static void Main(string[] args)
static void Main(String[] args)
{
Console.WriteLine("===========================");
Console.WriteLine("MUD Engine Content Compiler");
@ -20,7 +20,7 @@ namespace MUDCompiler
Console.WriteLine("2): Exit Compiler");
Console.Write("Enter Selection: ");
string command = Console.ReadLine();
String command = Console.ReadLine();
//command error checking.
if (String.IsNullOrEmpty(command))

View file

@ -14,10 +14,10 @@ namespace MudEngine.Commands
{
public class CommandClear : IGameCommand
{
public bool Override { get; set; }
public string Name { get; set; }
public Boolean Override { get; set; }
public String Name { get; set; }
public CommandResults Execute(string command, BaseCharacter player)
public CommandResults Execute(String command, BaseCharacter player)
{
player.FlushConsole();

View file

@ -14,22 +14,22 @@ namespace MudEngine.Commands
{
public class CommandExit : IGameCommand
{
public bool Override { get; set; }
public string Name { get; set; }
public Boolean Override { get; set; }
public String Name { get; set; }
public CommandResults Execute(string command, BaseCharacter player)
public CommandResults Execute(String command, BaseCharacter player)
{
if (player.ActiveGame.IsMultiplayer)
{
//Let other players know that the user walked in.
for (int i = 0; i != player.ActiveGame.PlayerCollection.Length; i++)
for (Int32 i = 0; i != player.ActiveGame.PlayerCollection.Length; i++)
{
if (player.ActiveGame.PlayerCollection[i].Name == player.Name)
continue;
string room = player.ActiveGame.PlayerCollection[i].CurrentRoom.Name;
string realm = player.ActiveGame.PlayerCollection[i].CurrentRoom.Realm;
string zone = player.ActiveGame.PlayerCollection[i].CurrentRoom.Zone;
String room = player.ActiveGame.PlayerCollection[i].CurrentRoom.Name;
String realm = player.ActiveGame.PlayerCollection[i].CurrentRoom.Realm;
String zone = player.ActiveGame.PlayerCollection[i].CurrentRoom.Zone;
if ((room == player.CurrentRoom.Name) && (realm == player.CurrentRoom.Realm) && (zone == player.CurrentRoom.Zone))
{

View file

@ -9,11 +9,11 @@ namespace MudEngine.Commands
{
public class CommandGetTime : MudEngine.GameManagement.IGameCommand
{
public string Name { get; set; }
public String Name { get; set; }
public bool Override { get; set; }
public Boolean Override { get; set; }
public MudEngine.GameManagement.CommandResults Execute(string command, BaseCharacter player)
public MudEngine.GameManagement.CommandResults Execute(String command, BaseCharacter player)
{
player.Send(player.ActiveGame.WorldTime.GetCurrentWorldTime());

View file

@ -13,13 +13,13 @@ namespace MudEngine.Commands
{
public class CommandLoad : IGameCommand
{
public bool Override { get; set; }
public string Name { get; set; }
public Boolean Override { get; set; }
public String Name { get; set; }
public CommandResults Execute(string command, BaseCharacter player)
public CommandResults Execute(String command, BaseCharacter player)
{
string path = player.ActiveGame.DataPaths.Players;
string filename = Path.Combine(path, player.Filename);
String path = player.ActiveGame.DataPaths.Players;
String filename = Path.Combine(path, player.Filename);
player.Load(filename);

View file

@ -14,10 +14,10 @@ namespace MudEngine.Commands
{
public class CommandLogin : IGameCommand
{
public bool Override { get; set; }
public string Name { get; set; }
public Boolean Override { get; set; }
public String Name { get; set; }
public CommandResults Execute(string command, BaseCharacter player)
public CommandResults Execute(String command, BaseCharacter player)
{
player.Send(player.ActiveGame.GameTitle);
player.Send(player.ActiveGame.Version);
@ -26,15 +26,15 @@ namespace MudEngine.Commands
player.Send("Enter Character Name: ", false);
string input = player.ReadInput();
String input = player.ReadInput();
Boolean playerFound = false;
string savedFile = "";
String savedFile = "";
//See if this character already exists.
if (!Directory.Exists(player.ActiveGame.DataPaths.Players))
Directory.CreateDirectory(player.ActiveGame.DataPaths.Players);
foreach (string filename in Directory.GetFiles(player.ActiveGame.DataPaths.Players))
foreach (String filename in Directory.GetFiles(player.ActiveGame.DataPaths.Players))
{
if (Path.GetFileNameWithoutExtension(filename).ToLower() == input.ToLower())
{
@ -48,7 +48,7 @@ namespace MudEngine.Commands
//Next search if there is an existing player already logged in with this name, if so disconnect them.
if (player.ActiveGame.IsMultiplayer)
{
for (int i = 0; i <= player.ActiveGame.PlayerCollection.Length - 1; i++)
for (Int32 i = 0; i <= player.ActiveGame.PlayerCollection.Length - 1; i++)
{
if (player.ActiveGame.PlayerCollection[i].Name.ToLower() == input.ToLower())
{
@ -76,14 +76,14 @@ namespace MudEngine.Commands
//Let other players know that the user walked in.
if (player.ActiveGame.IsMultiplayer)
{
for (int i = 0; i != player.ActiveGame.PlayerCollection.Length; i++)
for (Int32 i = 0; i != player.ActiveGame.PlayerCollection.Length; i++)
{
if (player.ActiveGame.PlayerCollection[i].Name == player.Name)
continue;
string room = player.ActiveGame.PlayerCollection[i].CurrentRoom.Name;
string realm = player.ActiveGame.PlayerCollection[i].CurrentRoom.Realm;
string zone = player.ActiveGame.PlayerCollection[i].CurrentRoom.Zone;
String room = player.ActiveGame.PlayerCollection[i].CurrentRoom.Name;
String realm = player.ActiveGame.PlayerCollection[i].CurrentRoom.Realm;
String zone = player.ActiveGame.PlayerCollection[i].CurrentRoom.Zone;
if ((room == player.CurrentRoom.Name) && (realm == player.CurrentRoom.Realm) && (zone == player.CurrentRoom.Zone))
{

View file

@ -14,10 +14,10 @@ namespace MudEngine.Commands
{
public class CommandLook : IGameCommand
{
public string Name { get; set; }
public bool Override { get; set; }
public String Name { get; set; }
public Boolean Override { get; set; }
public CommandResults Execute(string command, BaseCharacter player)
public CommandResults Execute(String command, BaseCharacter player)
{
if (player.CurrentRoom == null)
{
@ -28,7 +28,7 @@ namespace MudEngine.Commands
player.Send(player.CurrentRoom.Description);
else
{
foreach(string entry in player.CurrentRoom.DetailedDescription)
foreach(String entry in player.CurrentRoom.DetailedDescription)
{
player.Send(entry);
}

View file

@ -18,18 +18,18 @@ namespace MudEngine.Commands
{
class CommandRestart : IGameCommand
{
public string Name { get; set; }
public bool Override { get; set; }
public String Name { get; set; }
public Boolean Override { get; set; }
public CommandResults Execute(string command, BaseCharacter player)
public CommandResults Execute(String command, BaseCharacter player)
{
if (player.Role == SecurityRoles.Admin)
{
string path = player.ActiveGame.DataPaths.Players;
String path = player.ActiveGame.DataPaths.Players;
for (int i = 0; i < player.ActiveGame.PlayerCollection.Length; i++)
for (Int32 i = 0; i < player.ActiveGame.PlayerCollection.Length; i++)
{
string filename = Path.Combine(path, player.ActiveGame.PlayerCollection[i].Filename);
String filename = Path.Combine(path, player.ActiveGame.PlayerCollection[i].Filename);
player.ActiveGame.PlayerCollection[i].Save(filename);
}

View file

@ -13,10 +13,10 @@ namespace MudEngine.Commands
{
public class CommandSave : IGameCommand
{
public bool Override { get; set; }
public string Name { get; set; }
public Boolean Override { get; set; }
public String Name { get; set; }
public CommandResults Execute(string command, BaseCharacter player)
public CommandResults Execute(String command, BaseCharacter player)
{
/*
if (player.ActiveGame.PlayerCollection.Length != 0)

View file

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using MudEngine.FileSystem;
using MudEngine.GameObjects.Characters;
using MudEngine.GameManagement;
using MudEngine.Commands;
using MudEngine.GameObjects.Environment;
namespace MudEngine.Commands
{
public class CommandSaveWorld : IGameCommand
{
public Boolean Override { get; set; }
public String Name { get; set; }
public CommandResults Execute(String command, BaseCharacter player)
{
if ((player.Role == SecurityRoles.Admin) || (player.Role == SecurityRoles.GM))
{
player.ActiveGame.Save();
}
return new CommandResults();
}
}
}

View file

@ -14,13 +14,13 @@ namespace MudEngine.Commands
{
public class CommandWalk : IGameCommand
{
public string Name { get; set; }
public bool Override { get; set; }
public String Name { get; set; }
public Boolean Override { get; set; }
public CommandResults Execute(string command, BaseCharacter player)
public CommandResults Execute(String command, BaseCharacter player)
{
string[] words = command.Split(' ');
List<string> directions = new List<string>();
String[] words = command.Split(' ');
List<String> directions = new List<String>();
if (words.Length == 1)
return new CommandResults("No direction supplied");

View file

@ -33,7 +33,7 @@ namespace MudEngine.FileSystem
/// <param name="filename"></param>
/// <param name="name"></param>
/// <param name="value"></param>
public static void WriteLine(string filename, string value, string name)
public static void WriteLine(String filename, String value, String name)
{
if (!File.Exists(filename))
{
@ -52,9 +52,9 @@ namespace MudEngine.FileSystem
}
}
public static string GetData(string filename, string name)
public static String GetData(String filename, String name)
{
foreach (string line in File.ReadAllLines(filename))
foreach (String line in File.ReadAllLines(filename))
{
//Ignore comments
if (line.StartsWith(";"))
@ -72,11 +72,11 @@ namespace MudEngine.FileSystem
/// </summary>
/// <param name="DataType"></param>
/// <returns></returns>
public static string GetDataPath(SaveDataTypes DataType)
public static String GetDataPath(SaveDataTypes DataType)
{
string assemblyPath = System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName;
string assemblyName = System.IO.Path.GetFileName(assemblyPath);
string installBase = assemblyPath.Substring(0, assemblyPath.Length - assemblyName.Length);
String assemblyPath = System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName;
String assemblyName = System.IO.Path.GetFileName(assemblyPath);
String installBase = assemblyPath.Substring(0, assemblyPath.Length - assemblyName.Length);
if (DataType == SaveDataTypes.Root)
return installBase;
@ -84,20 +84,20 @@ namespace MudEngine.FileSystem
return System.IO.Path.Combine(installBase, DataType.ToString());
}
public static string GetDataPath(string Realm, string Zone)
public static String GetDataPath(String Realm, String Zone)
{
string assemblyPath = System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName;
string assemblyName = System.IO.Path.GetFileName(assemblyPath);
string installBase = assemblyPath.Substring(0, assemblyPath.Length - assemblyName.Length);
string realmsPath = System.IO.Path.Combine(installBase, "Realms");
string requestRealm = Path.Combine(installBase, Realm);
string requestedRealmZones = Path.Combine(installBase, "Zones");
string requestedZone = Path.Combine(installBase, Zone);
String assemblyPath = System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName;
String assemblyName = System.IO.Path.GetFileName(assemblyPath);
String installBase = assemblyPath.Substring(0, assemblyPath.Length - assemblyName.Length);
String realmsPath = System.IO.Path.Combine(installBase, "Realms");
String requestRealm = Path.Combine(installBase, Realm);
String requestedRealmZones = Path.Combine(installBase, "Zones");
String requestedZone = Path.Combine(installBase, Zone);
return requestedZone;
}
public static string GetDataPath(string Realm, string Zone, string Room)
public static String GetDataPath(String Realm, String Zone, String Room)
{
return System.IO.Path.Combine(GetDataPath(Realm, Zone), Room);
}

View file

@ -7,7 +7,7 @@ namespace MudEngine.FileSystem
{
public struct SaveDataPaths
{
public string Players
public String Players
{
get
{
@ -19,7 +19,7 @@ namespace MudEngine.FileSystem
}
}
public string Environment
public String Environment
{
get
{
@ -30,10 +30,10 @@ namespace MudEngine.FileSystem
_Environment = value;
}
}
private string _Players;
private string _Environment;
private String _Players;
private String _Environment;
public SaveDataPaths(string environment, string players)
public SaveDataPaths(String environment, String players)
{
_Players = players;
_Environment = environment;

View file

@ -10,7 +10,7 @@ namespace MudEngine.FileSystem
{
internal class XmlSerialization
{
internal static void Save(string Filename, object o)
internal static void Save(String Filename, object o)
{
Stream stream = File.Create(Filename);
@ -25,7 +25,7 @@ namespace MudEngine.FileSystem
/// </summary>
/// <param name="Filename">The Xml document to deserialize.</param>
/// <returns></returns>
internal static object Load(string Filename, object o)
internal static object Load(String Filename, object o)
{
Stream stream = File.OpenRead(Filename);

View file

@ -19,9 +19,9 @@ namespace MudEngine.GameManagement
/// <summary>
/// Gets or Sets a Dictionary list of available commands to use.
/// </summary>
public static Dictionary<string, IGameCommand> CommandCollection { get; set; }
public static Dictionary<String, IGameCommand> CommandCollection { get; set; }
internal Dictionary<string, IGameCommand> __Commands { get; set; }
internal Dictionary<String, IGameCommand> __Commands { get; set; }
public CommandEngine()
{
@ -31,11 +31,11 @@ namespace MudEngine.GameManagement
//_Commands = CommandEngine.CommandCollection;
}
public static List<string> GetCommands()
public static List<String> GetCommands()
{
List<string> temp = new List<string>();
List<String> temp = new List<String>();
foreach (string name in CommandEngine.CommandCollection.Keys)
foreach (String name in CommandEngine.CommandCollection.Keys)
{
temp.Add(name);
}
@ -43,7 +43,7 @@ namespace MudEngine.GameManagement
return temp;
}
public static IGameCommand GetCommand(string command)
public static IGameCommand GetCommand(String command)
{
if (IsValidCommand(command))
{
@ -57,7 +57,7 @@ namespace MudEngine.GameManagement
return null;
}
public static bool IsValidCommand(string Name)
public static Boolean IsValidCommand(String Name)
{
if (CommandCollection.ContainsKey(Name.ToLower()))
return true;
@ -70,13 +70,13 @@ namespace MudEngine.GameManagement
/// <param name="Name"></param>
/// <param name="Parameter"></param>
/// <returns></returns>
public CommandResults ExecuteCommand(string command, BaseCharacter player)
public CommandResults ExecuteCommand(String command, BaseCharacter player)
{
string commandKey = command.Insert(0, "Command");
String commandKey = command.Insert(0, "Command");
if (Game.IsDebug)
Log.Write("Executing command: " + command);
foreach (string key in CommandEngine.CommandCollection.Keys)
foreach (String key in CommandEngine.CommandCollection.Keys)
{
if (commandKey.ToLower().Contains(key.ToLower()))
{
@ -106,7 +106,7 @@ namespace MudEngine.GameManagement
LoadCommandLibrary(Assembly.GetExecutingAssembly());
}
public static void LoadCommandLibrary(string libraryFilename)
public static void LoadCommandLibrary(String libraryFilename)
{
if (System.IO.File.Exists(libraryFilename))
{
@ -126,7 +126,7 @@ namespace MudEngine.GameManagement
LoadCommandLibrary(commandLibrary, false);
}
public static void LoadCommandLibrary(Assembly commandLibrary, bool purgeOldCommands)
public static void LoadCommandLibrary(Assembly commandLibrary, Boolean purgeOldCommands)
{
//no assembly passed for whatever reason, don't attempt to enumerate through it.
if (commandLibrary == null)
@ -170,7 +170,7 @@ namespace MudEngine.GameManagement
public static void ClearCommands()
{
CommandCollection = new Dictionary<string, IGameCommand>();
CommandCollection = new Dictionary<String, IGameCommand>();
}
}
}

View file

@ -22,7 +22,7 @@ namespace MudEngine.GameManagement
this.Result = Result;
}
public CommandResults(string message)
public CommandResults(String message)
{
this.Result = new object[] { message };
}

View file

@ -17,6 +17,7 @@ using MudEngine.GameObjects;
using MudEngine.GameObjects.Characters;
using MudEngine.GameObjects.Environment;
using MudEngine.Scripting;
using MudEngine.Networking;
namespace MudEngine.GameManagement
{
@ -33,18 +34,18 @@ namespace MudEngine.GameManagement
/// <summary>
/// Gets or Sets if this game is running in debug mode. Additional information is sent to the log if enabled.
/// </summary>
public static bool IsDebug { get; set; }
public static Boolean IsDebug { get; set; }
/// <summary>
/// Gets or Sets if the game will run with a server or not.
/// </summary>
public bool IsMultiplayer { get; set; }
public Boolean IsMultiplayer { get; set; }
/// <summary>
/// Gets or Sets if this game is currently running.
/// </summary>
[Browsable(false)]
public bool IsRunning { get; internal set; }
public Boolean IsRunning { get; internal set; }
/// <summary>
/// Gets or Sets the paths to various project related objects.
@ -60,14 +61,14 @@ namespace MudEngine.GameManagement
/// Gets or Sets the path to the current project
/// </summary>
[Browsable(false)]
public string ProjectPath { get; set; }
public String ProjectPath { get; set; }
/// <summary>
/// Gets or Sets if all objects will be laoded during server startup. Enabling this results in a slower server start time, but faster object access.
/// </summary>
[Category("Project Settings")]
[Description("If enabled, all objects will be loaded during server startup resulting in a slower server start time, but faster load time during gameplay")]
public bool PreCacheObjects { get; set; }
public Boolean PreCacheObjects { get; set; }
/// <summary>
/// Gets a copy of all identifiers being used in the game.
@ -81,25 +82,25 @@ namespace MudEngine.GameManagement
/// <summary>
/// Gets or Sets the name of the company
/// </summary>
public string CompanyName { get; set; }
public String CompanyName { get; set; }
[Category("Company Settings")]
[Description("The website URL that a player can visit to view additional information related to the game")]
/// <summary>
/// Gets or Sets the companies website for this project
/// </summary>
public string Website { get; set; }
public String Website { get; set; }
[Category("Project Settings")]
[Description("The name of the game displayed to the users, and title bar of the runtime.")]
public string GameTitle { get; set; }
public String GameTitle { get; set; }
/// <summary>
/// Gets or Sets the current working version of the game.
/// </summary>
[Category("Project Settings")]
[Description("The current working version of the game.")]
public string Version { get; set; }
public String Version { get; set; }
[Browsable(false)]
public List<Currency> CurrencyList { get; set; }
@ -115,7 +116,7 @@ namespace MudEngine.GameManagement
/// <summary>
/// The Story that is displayed on initial player entry into the game
/// </summary>
public string Story { get; set; }
public String Story { get; set; }
[Category("Project Settings")]
[Description("Enable or Disable Auto-saving of players when the player travels")]
@ -123,7 +124,7 @@ namespace MudEngine.GameManagement
/// Gets or Sets if the Game world is automatically saved at a specified interval.
/// Players will be saved every-time they change location.
/// </summary>
public bool AutoSave { get; set; }
public Boolean AutoSave { get; set; }
/// <summary>
/// Gets or Sets the interval in which the Game will automatically save every game object.
@ -135,17 +136,17 @@ namespace MudEngine.GameManagement
/// <summary>
/// Gets or Sets if room names are hidden during console output.
/// </summary>
public bool HideRoomNames { get; set; }
public Boolean HideRoomNames { get; set; }
[Category("Game Currency")]
[DefaultValue(1)]
[Description("Sets the amount that the base currency is valued at.")]
public uint BaseCurrencyAmount { get; set; }
public Int32 BaseCurrencyAmount { get; set; }
[Category("Game Currency")]
[DefaultValue("Copper")]
public string BaseCurrencyName { get; set; }
public String BaseCurrencyName { get; set; }
public GameTime WorldTime { get; set; }
@ -162,7 +163,7 @@ namespace MudEngine.GameManagement
/// <summary>
/// Gets the current running Server object.
/// </summary>
public MudEngine.Networking.Server Server { get; internal set; }
public Server Server { get; internal set; }
/// <summary>
/// Gets or Sets the protocol used by the server.
@ -172,12 +173,12 @@ namespace MudEngine.GameManagement
/// <summary>
/// Gets or Sets the port that the server will run on
/// </summary>
public int ServerPort { get; set; }
public Int32 ServerPort { get; set; }
/// <summary>
/// Gets or Sets the maximum number of Players permitted to run on this Games server.
/// </summary>
public int MaximumPlayers { get; set; }
public Int32 MaximumPlayers { get; set; }
#endregion
#endregion
@ -212,7 +213,7 @@ namespace MudEngine.GameManagement
//Setup the player arrays
//used to be in Start
PlayerCollection = new BaseCharacter[MaximumPlayers];
for (int i = 0; i < MaximumPlayers; i++)
for (Int32 i = 0; i < MaximumPlayers; i++)
PlayerCollection[i] = new BaseCharacter(this);
GameTime.Time t = new GameTime.Time();
@ -240,7 +241,7 @@ namespace MudEngine.GameManagement
/// <summary>
/// Starts the game and runs the server if IsMultiplayer is true
/// </summary>
public virtual bool Start()
public virtual Boolean Start()
{
Log.Write("Game Initializing...");
if (!Directory.Exists(DataPaths.Players))
@ -263,7 +264,7 @@ namespace MudEngine.GameManagement
if (IsDebug)
{
foreach (string command in CommandEngine.CommandCollection.Keys)
foreach (String command in CommandEngine.CommandCollection.Keys)
Log.Write("Command Loaded: " + command);
}
@ -314,7 +315,7 @@ namespace MudEngine.GameManagement
DateTime serverTime = new DateTime();
DateTime systemTime = DateTime.Now;
int lastSaveGap = 0;
Int32 lastSaveGap = 0;
WorldTime.Update();
@ -349,7 +350,7 @@ namespace MudEngine.GameManagement
Log.Write("Saving Game world....");
Log.Write("Saving Game Players...");
for (int i = 0; i <= PlayerCollection.Length - 1; i++)
for (Int32 i = 0; i <= PlayerCollection.Length - 1; i++)
{
if (PlayerCollection[i].Name == "New BaseCharacter")
continue;

View file

@ -9,12 +9,12 @@ namespace MudEngine.GameManagement
{
public struct Time
{
public int Year { get; set; }
public int Month { get; set; }
public int Day { get; set; }
public int Hour { get; set; }
public int Minute { get; set; }
public int Second { get; set; }
public Int32 Year { get; set; }
public Int32 Month { get; set; }
public Int32 Day { get; set; }
public Int32 Hour { get; set; }
public Int32 Minute { get; set; }
public Int32 Second { get; set; }
private GameTime gameTime;
}
@ -45,37 +45,37 @@ namespace MudEngine.GameManagement
/// <summary>
/// Gets or Sets how many Hours it takes to make a full day in the World
/// </summary>
public int HoursPerDay { get; set; }
public Int32 HoursPerDay { get; set; }
/// <summary>
/// Gets or Sets how many minutes it takes to make a full Hour
/// </summary>
public int MinutesPerHour { get; set; }
public Int32 MinutesPerHour { get; set; }
/// <summary>
/// Gets or Sets how many seconds it takes to make a full minute
/// </summary>
public int SecondsPerMinute { get; set; }
public Int32 SecondsPerMinute { get; set; }
/// <summary>
/// Gets or Sets how many Days it takes to make a full month in the world
/// </summary>
public int DaysPerMonth { get; set; }
public Int32 DaysPerMonth { get; set; }
/// <summary>
/// Gets or Sets how many Months it takes to make a full Year in the world
/// </summary>
public int MonthsPerYear { get; set; }
public Int32 MonthsPerYear { get; set; }
/// <summary>
/// Gets or Sets the name of each Day in a Week.
/// </summary>
public List<string> DayNames { get; set; }
public List<String> DayNames { get; set; }
/// <summary>
/// Gets or Sets the name of each Month in a Year.
/// </summary>
public List<string> MonthNames { get; set; }
public List<String> MonthNames { get; set; }
/// <summary>
/// Gets or Sets what time of day the world is currently in.
@ -85,12 +85,12 @@ namespace MudEngine.GameManagement
/// <summary>
/// Gets or Sets what time of day that it begins to transition to night.
/// </summary>
public int DawnTime { get; set; }
public Int32 DawnTime { get; set; }
/// <summary>
/// /Gets or Sets what time of day that it begins to transition into day time.
/// </summary>
public int SunriseTime { get; set; }
public Int32 SunriseTime { get; set; }
/// <summary>
/// Gets or Sets the initial Time that the world starts in.
@ -103,8 +103,8 @@ namespace MudEngine.GameManagement
ServerStartTime = DateTime.Now;
DayNames = new List<string>();
MonthNames = new List<string>();
DayNames = new List<String>();
MonthNames = new List<String>();
DayNames.Add("Monday");
DayNames.Add("Tuesday");
@ -240,7 +240,7 @@ namespace MudEngine.GameManagement
CurrentWorldTime = t;
}
public string GetCurrentWorldTime()
public String GetCurrentWorldTime()
{
if (DayNames.Count < CurrentWorldTime.Day)
{
@ -251,8 +251,8 @@ namespace MudEngine.GameManagement
return "Not enough Month names specified to match up with MonthsPerYear property.";
}
string day = DayNames[CurrentWorldTime.Day - 1];
string month = MonthNames[CurrentWorldTime.Month - 1];
String day = DayNames[CurrentWorldTime.Day - 1];
String month = MonthNames[CurrentWorldTime.Month - 1];
return day + ", " + month + " " + CurrentWorldTime.Day + ", " + CurrentWorldTime.Year + ": " + CurrentWorldTime.Hour + ":" + CurrentWorldTime.Minute + ":" + CurrentWorldTime.Second;
}

View file

@ -90,35 +90,10 @@ namespace MudEngine.GameManagement
public void Save()
{
//Save all of the Environments
for (int x = 0; x <= Realms.Count - 1; x++)
for (Int32 x = 0; x <= Realms.Count - 1; x++)
{
string realmFile = Path.Combine(_Game.DataPaths.Environment, Realms[x].Filename);
//Save the Realm
Realms[x].Save(realmFile);
//Loop through each Zone in the Realm and save it.
for (int y = 0; y <= Realms[x].ZoneCollection.Count - 1; y++)
{
string zonePath = Path.Combine(_Game.DataPaths.Environment, Path.GetFileNameWithoutExtension(Realms[x].Filename), Path.GetFileNameWithoutExtension(Realms[x].ZoneCollection[y].Filename));
if (!Directory.Exists(zonePath))
Directory.CreateDirectory(zonePath);
//Save the Zone.
Realms[x].ZoneCollection[y].Save(Path.Combine(zonePath, Realms[x].ZoneCollection[y].Filename));
for (int z = 0; z <= Realms[x].ZoneCollection[y].RoomCollection.Count - 1; z++)
{
if (!Directory.Exists(Path.Combine(zonePath, "Rooms")))
Directory.CreateDirectory(Path.Combine(zonePath, "Rooms"));
string roomPath = Path.Combine(zonePath, "Rooms");
Realms[x].ZoneCollection[y].RoomCollection[z].Save(Path.Combine(roomPath, Realms[x].ZoneCollection[y].RoomCollection[z].Filename));
}
}
} //Complete Environment saving.
Realms[x].Save(_Game.DataPaths.Environment);
}
}
/// <summary>
@ -156,7 +131,7 @@ namespace MudEngine.GameManagement
/// <param name="objectType">Determins the Type of object to perform the search for. Using Standard will search for objects that inherit from BaseObject, but none of BaseObjects child Types.</param>
/// <param name="filename"></param>
/// <returns></returns>
public BaseObject GetObject(ObjectTypes objectType, string filename)
public BaseObject GetObject(ObjectTypes objectType, String filename)
{
BaseObject obj = new BaseObject(_Game);
@ -190,7 +165,7 @@ namespace MudEngine.GameManagement
/// </summary>
/// <param name="filename"></param>
/// <returns></returns>
private Realm GetRealm(string filename)
private Realm GetRealm(String filename)
{
foreach (Realm r in Realms)
{

View file

@ -15,10 +15,10 @@ namespace MudEngine.GameManagement
public interface IGameCommand
{
//Name of the command
string Name { get; set; }
String Name { get; set; }
//Used to override commands with the same name
bool Override { get; set; }
Boolean Override { get; set; }
//Executes the command.
CommandResults Execute(string command, BaseCharacter player);
CommandResults Execute(String command, BaseCharacter player);
}
}

View file

@ -10,12 +10,12 @@ namespace MudEngine.GameManagement
{
public static class Log
{
static List<string> cachedMessages = new List<string>();
static List<String> cachedMessages = new List<String>();
public static Boolean IsVerbose;
public static void Write(string message)
public static void Write(String message)
{
string filename = Path.Combine(FileManager.GetDataPath(SaveDataTypes.Root), "Log.txt");
String filename = Path.Combine(FileManager.GetDataPath(SaveDataTypes.Root), "Log.txt");
StreamWriter sw;
if (File.Exists(filename))
@ -30,12 +30,11 @@ namespace MudEngine.GameManagement
cachedMessages.Add(message);
}
public static string GetMessages()
public static String GetMessages()
{
string messages = "";
StringBuilder sb = new StringBuilder();
foreach (string message in cachedMessages)
foreach (String message in cachedMessages)
{
sb.AppendLine(message);
}
@ -48,7 +47,7 @@ namespace MudEngine.GameManagement
public static void FlushMessages()
{
cachedMessages = new List<string>();
cachedMessages = new List<String>();
}
}
}

View file

@ -14,7 +14,7 @@ namespace MudEngine.GameObjects
/// <summary>
/// Gets or Sets the size of the bag.
/// </summary>
public int Size
public Int32 Size
{
get;
set;
@ -32,7 +32,7 @@ namespace MudEngine.GameObjects
Items.Add(item);
}
public int GetSlotsRemaining()
public Int32 GetSlotsRemaining()
{
return Size - Items.Count;
}

View file

@ -19,7 +19,7 @@ namespace MudEngine.GameObjects
[Description("The Display Name assigned to this object.")]
//Required to refresh Filename property in the editors propertygrid
[RefreshProperties(RefreshProperties.All)]
public string Name
public String Name
{
get
{
@ -34,21 +34,21 @@ namespace MudEngine.GameObjects
Filename = value + "." + this.GetType().Name;
}
}
private string _Name;
private String _Name;
[Category("Object Setup")]
[Description("A brief description of this object. The description is displayed to users when they use a command for investigating an object")]
public string Description { get; set; }
public String Description { get; set; }
/// <summary>
/// A detailed description that treats each entry as a seperete line when outputted to the player
/// </summary>
public List<string> DetailedDescription { get; set; }
public List<String> DetailedDescription { get; set; }
[Category("Object Setup")]
[ReadOnly(true)]
[Description("The filename of the current object. This is assigned by the engine and not editable.")]
public string Filename
public String Filename
{
//Returns the name of the object + the objects Type as it's extension.
//Filenames are generated by the class itself, users can not assign it.
@ -59,17 +59,17 @@ namespace MudEngine.GameObjects
[Category("Environment Information")]
[Description("If a user asks to use his/her senses to investigate an area, this is one of the results that will be displayed. Senses can be used to assist blind characters.")]
[DefaultValue("You don't smell anything unsual.")]
public string Smell { get; set; }
public String Smell { get; set; }
[Category("Environment Information")]
[Description("If a user asks to use his/her senses to investigate an area, this is one of the results that will be displayed. Senses can be used to assist blind characters.")]
[DefaultValue("You hear nothing of interest.")]
public string Listen { get; set; }
public String Listen { get; set; }
[Category("Environment Information")]
[Description("If a user asks to use his/her senses to investigate an area, this is one of the results that will be displayed. Senses can be used to assist blind characters.")]
[DefaultValue("You feel nothing.")]
public string Feel { get; set; }
public String Feel { get; set; }
public Game ActiveGame { get; set; }
@ -80,7 +80,7 @@ namespace MudEngine.GameObjects
{
Name = "New " + this.GetType().Name;
ActiveGame = game;
DetailedDescription = new List<string>();
DetailedDescription = new List<String>();
this.Feel = "You feel nothing.";
this.Listen = "You hear nothing of interest.";
@ -95,7 +95,7 @@ namespace MudEngine.GameObjects
{
}
private bool ShouldSerializeName()
private Boolean ShouldSerializeName()
{
return this.Name != DefaultName();
}
@ -105,13 +105,13 @@ namespace MudEngine.GameObjects
this.Name = DefaultName();
}
private string DefaultName()
private String DefaultName()
{
return "New " + this.GetType().Name;
}
#region Public Methods
public override string ToString()
public override String ToString()
{
return this.Name;
}
@ -148,7 +148,7 @@ namespace MudEngine.GameObjects
{
}
public virtual void Save(string path)
public virtual void Save(String path)
{
if (String.IsNullOrEmpty(path))
return;
@ -156,19 +156,19 @@ namespace MudEngine.GameObjects
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
path = Path.Combine(path, Filename);
String filename = Path.Combine(path, Filename);
if (File.Exists(path))
File.Delete(path);
if (File.Exists(filename))
File.Delete(filename);
FileManager.WriteLine(path, this.Name, "Name");
FileManager.WriteLine(path, this.Description, "Description");
FileManager.WriteLine(path, this.Feel, "Feel");
FileManager.WriteLine(path, this.Listen, "Listen");
FileManager.WriteLine(path, this.Smell, "Smell");
FileManager.WriteLine(filename, this.Name, "Name");
FileManager.WriteLine(filename, this.Description, "Description");
FileManager.WriteLine(filename, this.Feel, "Feel");
FileManager.WriteLine(filename, this.Listen, "Listen");
FileManager.WriteLine(filename, this.Smell, "Smell");
}
public virtual void Load(string filename)
public virtual void Load(String filename)
{
this.Name = FileManager.GetData(filename, "Name");
this.Description = FileManager.GetData(filename, "Description");

View file

@ -67,7 +67,7 @@ namespace MudEngine.GameObjects.Characters
CommandSystem = new CommandEngine();
}
public override void Load(string filename)
public override void Load(String filename)
{
base.Load(filename);
@ -75,12 +75,12 @@ namespace MudEngine.GameObjects.Characters
//Need to re-assign the enumerator value that was previously assigned to the Role property
Array values = Enum.GetValues(typeof(SecurityRoles));
foreach (int value in values)
foreach (Int32 value in values)
{
//Since enum values are not strings, we can't simply just assign the string to the enum
string displayName = Enum.GetName(typeof(SecurityRoles), value);
//Since enum values are not strings, we can't simply just assign the String to the enum
String displayName = Enum.GetName(typeof(SecurityRoles), value);
//If the value = the string saved, then perform the needed conversion to get our data back
//If the value = the String saved, then perform the needed conversion to get our data back
if (displayName.ToLower() == FileManager.GetData(filename, "Role").ToLower())
{
Role = (SecurityRoles)Enum.Parse(typeof(SecurityRoles), displayName);
@ -138,7 +138,7 @@ namespace MudEngine.GameObjects.Characters
}
}
public override void Save(string path)
public override void Save(String path)
{
base.Save(path);
@ -157,7 +157,7 @@ namespace MudEngine.GameObjects.Characters
/// </summary>
/// <param name="travelDirection"></param>
/// <returns></returns>
public bool Move(AvailableTravelDirections travelDirection)
public Boolean Move(AvailableTravelDirections travelDirection)
{
//Check if the current room has a doorway in the supplied direction of travel.
if (!CurrentRoom.DoorwayExist(travelDirection))
@ -166,14 +166,14 @@ namespace MudEngine.GameObjects.Characters
}
//Let other players know that the user walked out.
for (int i = 0; i != ActiveGame.PlayerCollection.Length; i++)
for (Int32 i = 0; i != ActiveGame.PlayerCollection.Length; i++)
{
if (ActiveGame.PlayerCollection[i].Name == Name)
continue;
string room = ActiveGame.PlayerCollection[i].CurrentRoom.Filename;
string realm = ActiveGame.PlayerCollection[i].CurrentRoom.Realm;
string zone = ActiveGame.PlayerCollection[i].CurrentRoom.Zone;
String room = ActiveGame.PlayerCollection[i].CurrentRoom.Filename;
String realm = ActiveGame.PlayerCollection[i].CurrentRoom.Realm;
String zone = ActiveGame.PlayerCollection[i].CurrentRoom.Zone;
if ((room == CurrentRoom.Filename) && (realm == CurrentRoom.Realm) && (zone == CurrentRoom.Zone))
{
@ -193,14 +193,14 @@ namespace MudEngine.GameObjects.Characters
{
//TODO: Check the Room/Zone/Realm to see if anything needs to occure during travel.
//Let other players know that the user walked in.
for (int i = 0; i != ActiveGame.PlayerCollection.Length; i++)
for (Int32 i = 0; i != ActiveGame.PlayerCollection.Length; i++)
{
if (ActiveGame.PlayerCollection[i].Name == Name)
continue;
string room = ActiveGame.PlayerCollection[i].CurrentRoom.Name;
string realm = ActiveGame.PlayerCollection[i].CurrentRoom.Realm;
string zone = ActiveGame.PlayerCollection[i].CurrentRoom.Zone;
String room = ActiveGame.PlayerCollection[i].CurrentRoom.Name;
String realm = ActiveGame.PlayerCollection[i].CurrentRoom.Realm;
String zone = ActiveGame.PlayerCollection[i].CurrentRoom.Zone;
if ((room == CurrentRoom.Name) && (realm == CurrentRoom.Realm) && (zone == CurrentRoom.Zone))
{
@ -209,7 +209,7 @@ namespace MudEngine.GameObjects.Characters
}
}
public void ExecuteCommand(string command)
public void ExecuteCommand(String command)
{
//TODO: Character class can handle a lot of the command management here, checking various things prior to sending
//the command off to the command engine for execution.
@ -226,7 +226,7 @@ namespace MudEngine.GameObjects.Characters
StringBuilder sb = new StringBuilder();
foreach (object item in result.Result)
{
if (item is string)
if (item is String)
sb.AppendLine(item.ToString());
}
return sb.ToString();
@ -249,7 +249,7 @@ namespace MudEngine.GameObjects.Characters
//Ensure custom commands are loaded until everything is fleshed out.
if (Game.IsDebug)
{
foreach (string command in CommandEngine.GetCommands())
foreach (String command in CommandEngine.GetCommands())
{
Log.Write("Command loaded: " + command);
}
@ -268,7 +268,7 @@ namespace MudEngine.GameObjects.Characters
ExecuteCommand("Login");
ExecuteCommand("Look"); //MUST happen after Room setup is completed, otherwise the player default Abyss Room is printed.
}
internal void Receive(string data)
internal void Receive(String data)
{
//data = ExecuteCommand(data);
ExecuteCommand(data);
@ -282,7 +282,7 @@ namespace MudEngine.GameObjects.Characters
/// </summary>
/// <param name="data"></param>
/// <param name="newLine"></param>
internal void Send(string data, bool newLine)
internal void Send(String data, Boolean newLine)
{
try
{
@ -305,7 +305,7 @@ namespace MudEngine.GameObjects.Characters
/// Sends data to the player.
/// </summary>
/// <param name="data"></param>
internal void Send(string data)
internal void Send(String data)
{
Send(data, true);
}
@ -346,7 +346,7 @@ namespace MudEngine.GameObjects.Characters
Log.Write("Player " + this.Name + " disconnected.");
}
}
internal string ReadInput()
internal String ReadInput()
{
if (ActiveGame.IsMultiplayer)
{
@ -356,7 +356,7 @@ namespace MudEngine.GameObjects.Characters
try
{
byte[] buf = new byte[1];
int recved = client.Receive(buf);
Int32 recved = client.Receive(buf);
if (recved > 0)
{

View file

@ -15,7 +15,7 @@ namespace MudEngine.GameObjects
/// <summary>
/// The value of this currency. It should be how many 'base currency' it takes to equal 1 of this currency
/// </summary>
public int Value
public Int32 Value
{
get;
set;

View file

@ -17,7 +17,7 @@ namespace MudEngine.GameObjects.Environment
{
[Category("Door Settings")]
[DefaultValue(false)]
public bool IsLocked
public Boolean IsLocked
{
get;
set;
@ -33,7 +33,7 @@ namespace MudEngine.GameObjects.Environment
[Category("Door Settings")]
[DefaultValue(0)]
public int LevelRequirement
public Int32 LevelRequirement
{
get;
set;

View file

@ -23,7 +23,7 @@ namespace MudEngine.GameObjects.Environment
/// <summary>
/// Gets or Sets if this Realm is the starting realm for the game.
/// </summary>
public bool IsInitialRealm { get; set; }
public Boolean IsInitialRealm { get; set; }
/// <summary>
/// The Initial Starting Zone for this Realm.
@ -35,14 +35,24 @@ namespace MudEngine.GameObjects.Environment
ZoneCollection = new List<Zone>();
}
public override void Save(string path)
public override void Save(String path)
{
path = Path.Combine(path, Path.GetFileNameWithoutExtension(Filename));
base.Save(path);
//TODO: Save Realm collections and Zone to file.
String filename = Path.Combine(path, Filename);
FileManager.WriteLine(filename, this.IsInitialRealm.ToString(), "IsInitialRealm");
FileManager.WriteLine(filename, this.InitialZone.Filename, "InitialZone");
foreach (Zone z in ZoneCollection)
{
FileManager.WriteLine(filename, z.Filename, "ZoneCollection");
z.Save(path);
}
}
public List<Zone> GetZoneByFilename(string filename)
public List<Zone> GetZoneByFilename(String filename)
{
List<Zone> zones = new List<Zone>();

View file

@ -27,7 +27,7 @@ namespace MudEngine.GameObjects.Environment
[ReadOnly(true)]
[Description("This is the Zone that the Room is currently assigned to.")]
[Category("Environment Information")]
public string Zone
public String Zone
{
get;
set;
@ -36,7 +36,7 @@ namespace MudEngine.GameObjects.Environment
[ReadOnly(true)]
[Description("This is the Realm that the Room belongs to.")]
[Category("Environment Information")]
public string Realm
public String Realm
{
get;
set;
@ -45,18 +45,18 @@ namespace MudEngine.GameObjects.Environment
[Category("Environment Information")]
[DefaultValue(false)]
[Description("Determins if the Player can be attacked within this Room or not.")]
public bool IsSafe
public Boolean IsSafe
{
get;
set;
}
[Browsable(false)]
public string InstallPath
public String InstallPath
{
get
{
string zonePath = "";
String zonePath = "";
if (this.Realm == null || this.Realm == "No Realm Associated.")
{
zonePath = FileManager.GetDataPath(SaveDataTypes.Zones);
@ -65,8 +65,8 @@ namespace MudEngine.GameObjects.Environment
else
zonePath = FileManager.GetDataPath(this.Realm, this.Zone);
string roomPath = Path.Combine(zonePath, "Rooms");
string filename = Path.Combine(roomPath, this.Filename);
String roomPath = Path.Combine(zonePath, "Rooms");
String filename = Path.Combine(roomPath, this.Filename);
return filename;
}
}
@ -76,7 +76,7 @@ namespace MudEngine.GameObjects.Environment
/// </summary>
[Browsable(true)]
[Description("Sets if this is the starting room for the Zone that contains it.")]
public bool IsInitialRoom
public Boolean IsInitialRoom
{
get;
set;
@ -89,12 +89,19 @@ namespace MudEngine.GameObjects.Environment
IsSafe = false;
}
public override void Save(String path)
{
base.Save(path);
String filename = Path.Combine(path, Filename);
}
/// <summary>
/// Checks to see if a doorway in the travelDirection exists.
/// </summary>
/// <param name="travelDirection"></param>
/// <returns></returns>
public bool DoorwayExist(AvailableTravelDirections travelDirection)
public Boolean DoorwayExist(AvailableTravelDirections travelDirection)
{
foreach (Door door in Doorways)
{

View file

@ -1,4 +1,6 @@
//MUD Engine
using System;
//MUD Engine
using MudEngine.FileSystem;
using MudEngine.GameObjects;
using MudEngine.GameObjects.Environment;
@ -7,13 +9,13 @@ namespace MudEngine.GameObjects.Environment
{
public struct StartingLocation
{
public string Room;
public string Zone;
public string Realm;
public String Room;
public String Zone;
public String Realm;
public override string ToString()
public override String ToString()
{
if (string.IsNullOrEmpty(Room))
if (String.IsNullOrEmpty(Room))
return "No initial location defined.";
else
{

View file

@ -39,13 +39,13 @@ namespace MudEngine.GameObjects
}
}
public static AvailableTravelDirections GetTravelDirectionValue(string Direction)
public static AvailableTravelDirections GetTravelDirectionValue(String Direction)
{
Array values = Enum.GetValues(typeof(AvailableTravelDirections));
foreach (int value in values)
foreach (Int32 value in values)
{
string displayName = Enum.GetName(typeof(AvailableTravelDirections), value);
String displayName = Enum.GetName(typeof(AvailableTravelDirections), value);
if (displayName.ToLower() == Direction.ToLower())
return (AvailableTravelDirections)Enum.Parse(typeof(AvailableTravelDirections), displayName);

View file

@ -20,7 +20,7 @@ namespace MudEngine.GameObjects.Environment
[Category("Environment Information")]
[DefaultValue(0)]
[Description("The amount to drain each stat by if StatDrain is enabled.")]
public int StatDrainAmount
public Int32 StatDrainAmount
{
get;
set;
@ -29,7 +29,7 @@ namespace MudEngine.GameObjects.Environment
[Category("Environment Information")]
[Description("Enable or Disable the ability for draining stats while traversing.")]
[DefaultValue(false)]
public bool StatDrain
public Boolean StatDrain
{
get;
set;
@ -38,7 +38,7 @@ namespace MudEngine.GameObjects.Environment
[ReadOnly(true)]
[Category("Environment Information")]
[Description("The Realm that this Zone is assigned to. It is not required to be contained within a Realm.")]
public string Realm
public String Realm
{
get;
set;
@ -47,7 +47,7 @@ namespace MudEngine.GameObjects.Environment
[Category("Environment Information")]
[Description("Determins if the Player can be attacked within this Room or not.")]
[DefaultValue(false)]
public bool IsSafe
public Boolean IsSafe
{
get;
set;
@ -59,7 +59,7 @@ namespace MudEngine.GameObjects.Environment
[Category("Environment Information")]
[Description("Sets that this Zone is a starting Zone for the game.")]
[DefaultValue(false)]
public bool IsInitialZone
public Boolean IsInitialZone
{
get;
set;
@ -83,6 +83,28 @@ namespace MudEngine.GameObjects.Environment
Realm = "No Realm Associated.";
}
public override void Save(String path)
{
path = Path.Combine(path, Path.GetFileNameWithoutExtension(Filename));
base.Save(path);
String filename = Path.Combine(path, Filename);
FileManager.WriteLine(filename, this.IsInitialZone.ToString(), "IsInitialZone");
FileManager.WriteLine(filename, this.IsSafe.ToString(), "IsSafe");
FileManager.WriteLine(filename, this.Realm, "Realm");
FileManager.WriteLine(filename, this.StatDrain.ToString(), "StatDrain");
FileManager.WriteLine(filename, this.StatDrainAmount.ToString(), "StatDrainAmount");
FileManager.WriteLine(filename, this.InitialRoom.Filename, "InitialRoom");
foreach (Room r in RoomCollection)
{
FileManager.WriteLine(filename, r.Filename, "Room");
r.Save(path);
}
}
/// <summary>
/// Adds the supplied room into the Zones Room collection.
/// </summary>
@ -111,7 +133,7 @@ namespace MudEngine.GameObjects.Environment
room.Realm = Realm;
}
public List<Room> GetRoomByFilename(string filename)
public List<Room> GetRoomByFilename(String filename)
{
List<Room> rooms = new List<Room>();

View file

@ -59,6 +59,7 @@
<Compile Include="Commands\CommandLoad.cs" />
<Compile Include="Commands\CommandLogin.cs" />
<Compile Include="Commands\CommandClear.cs" />
<Compile Include="Commands\CommandSaveWorld.cs" />
<Compile Include="FileSystem\SaveDataPaths.cs" />
<Compile Include="GameManagement\CommandEngine.cs" />
<Compile Include="GameManagement\CommandResults.cs" />

View file

@ -24,7 +24,7 @@ namespace MudEngine.Networking
stage = 0;
port = 0;
}
public bool Initialize(int p, ref BaseCharacter[] pbs)
public Boolean Initialize(Int32 p, ref BaseCharacter[] pbs)
{
if (stage != 0)
return false;
@ -36,7 +36,7 @@ namespace MudEngine.Networking
stage++;
return true;
}
public bool Start()
public Boolean Start()
{
try
{
@ -65,10 +65,10 @@ namespace MudEngine.Networking
{
while (stage == 2)
{
int sub = -1;
Int32 sub = -1;
do
{
for (int i = 0; i < players.Length; i++)
for (Int32 i = 0; i < players.Length; i++)
{
if (!players[i].IsActive)
{
@ -86,14 +86,14 @@ namespace MudEngine.Networking
}
private void ReceiveThread(object obj)
{
int sub = (int)obj;
Int32 sub = (Int32)obj;
players[sub].Initialize();
while (stage == 2 && players[sub].IsActive)
{
players[sub].Receive(players[sub].ReadInput());
}
}
public void Disconnect(int sub)
public void Disconnect(Int32 sub)
{
if (sub > 0 && sub < players.Length)
{
@ -105,8 +105,8 @@ namespace MudEngine.Networking
private Thread serverThread;
private Socket server;
private int stage;
private int port;
private Int32 stage;
private Int32 port;
BaseCharacter[] players;

View file

@ -18,14 +18,14 @@ namespace MudEngine.Scripting
/// <summary>
/// The Type name for this object
/// </summary>
public string Name { get; set; }
public String Name { get; set; }
/// <summary>
/// Determins if this object will recieve Update/Draw calls from the ScriptEngine
/// </summary>
public bool IsActive { get; set; }
public Boolean IsActive { get; set; }
public GameObject(object instance, string name)
public GameObject(object instance, String name)
{
Instance = instance;
Name = name;
@ -36,27 +36,27 @@ namespace MudEngine.Scripting
return Instance;
}
public bool DeleteObject()
public Boolean DeleteObject()
{
return true;
}
public void SetProperty(string propertyName, object propertyValue)
public void SetProperty(String propertyName, object propertyValue)
{
PropertyInfo propertyInfo = Instance.GetType().GetProperty(propertyName);
if (propertyValue is string)
if (propertyValue is String)
{
if (propertyInfo.PropertyType.Name is string)
if (propertyInfo.PropertyType.Name is String)
{
propertyInfo.SetValue(Instance, propertyValue, null);
}
}
}
public object GetProperty(string propertyName)
public object GetProperty(String propertyName)
{
string[] tokens = propertyName.Split('.');
String[] tokens = propertyName.Split('.');
PropertyInfo previousProperty = Instance.GetType().GetProperty(tokens[0]);
return previousProperty.GetValue(Instance, null);
@ -67,7 +67,7 @@ namespace MudEngine.Scripting
return Instance;
}
public object InvokeMethod(string methodName, params object[] parameters)
public object InvokeMethod(String methodName, params object[] parameters)
{
MethodInfo method = Instance.GetType().GetMethod(methodName);

View file

@ -30,7 +30,7 @@ namespace MudEngine.Scripting
/// <summary>
/// Path to the the script files directory
/// </summary>
public string ScriptPath
public String ScriptPath
{
get
{
@ -41,9 +41,9 @@ namespace MudEngine.Scripting
_ScriptPath = Path.Combine(FileManager.GetDataPath(SaveDataTypes.Root), value);
}
}
string _ScriptPath;
String _ScriptPath;
public string InstallPath { get; private set; }
public String InstallPath { get; private set; }
public GameObjectCollection ObjectCollection { get; private set; }
/// <summary>
@ -58,33 +58,33 @@ namespace MudEngine.Scripting
/// <summary>
/// File Extension for the scripts
/// </summary>
public string ScriptExtension { get; set; }
public String ScriptExtension { get; set; }
/// <summary>
/// Error Messages logged during script compilation
/// </summary>
public string ErrorMessage
public String ErrorMessage
{
get
{
string errorMessages = "Script Compilation Failed!\n";
String errorMessages = "Script Compilation Failed!\n";
//Construct our error message.
foreach (string error in _ErrorMessages)
foreach (String error in _ErrorMessages)
errorMessages += error + "\n";
return errorMessages;
}
private set
{
_ErrorMessages = new string[] { value };
_ErrorMessages = new String[] { value };
}
}
internal ScriptTypes ScriptType { get; set; }
private Assembly _ScriptAssembly;
private List<Assembly> _AssemblyCollection;
private string[] _ErrorMessages;
private string _SettingsFile;
private String[] _ErrorMessages;
private String _SettingsFile;
Game _Game;
public ScriptEngine(Game game) : this(game, ScriptTypes.Assembly)
@ -123,7 +123,7 @@ namespace MudEngine.Scripting
/// Compiles a collection of scripts stored in ScriptEngine.ScriptPath. Not supported on XBox360.
/// </summary>
/// <returns></returns>
public bool CompileScripts()
public Boolean CompileScripts()
{
#if !MOBILE
//Ensure the script path exists.
@ -133,7 +133,7 @@ namespace MudEngine.Scripting
return false;
}
//Build an array of scripts
string[] scripts = System.IO.Directory.GetFiles(ScriptPath, "*" + ScriptExtension, System.IO.SearchOption.AllDirectories);
String[] scripts = System.IO.Directory.GetFiles(ScriptPath, "*" + ScriptExtension, System.IO.SearchOption.AllDirectories);
//Prepare the scripts. MUD Scripts are wrote without defining a namespace
if (Directory.Exists("temp"))
@ -142,20 +142,20 @@ 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 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)
foreach (String script in scripts)
{
string tempPath = "temp";
string source = "\nnamespace MudScripts{\n}";
String tempPath = "temp";
String source = "\nnamespace MudScripts{\n}";
FileStream fr = new FileStream(script, FileMode.Open, FileAccess.Read, FileShare.None);
FileStream fw = new FileStream(Path.Combine(tempPath, Path.GetFileName(script)), FileMode.Create, FileAccess.Write);
StreamWriter sw = new StreamWriter(fw, System.Text.Encoding.Default);
StreamReader sr = new StreamReader(fr, System.Text.Encoding.Default);
string content = sr.ReadToEnd();
foreach (string statement in usingStatements)
String content = sr.ReadToEnd();
foreach (String statement in usingStatements)
source = source.Insert(0, statement);
source = source.Insert(source.Length - 1, content);
@ -164,14 +164,14 @@ namespace MudEngine.Scripting
sw.Flush();
sw.Close();
}
string oldPath = ScriptPath;
String oldPath = ScriptPath;
ScriptPath = "temp";
//Prepare the compiler.
Dictionary<string, string> providerOptions = new Dictionary<string,string>();
Dictionary<String, String> providerOptions = new Dictionary<String,String>();
providerOptions.Add("CompilerVersion", "v3.5");
CompilerParameters param = new CompilerParameters(new string[] {"mscorlib.dll", "System.dll", "MudEngine.dll"});
CompilerParameters param = new CompilerParameters(new String[] {"mscorlib.dll", "System.dll", "MudEngine.dll"});
param.GenerateExecutable = false;
param.GenerateInMemory = true;
if (!param.GenerateInMemory)
@ -193,10 +193,10 @@ namespace MudEngine.Scripting
//if we encountered errors we need to log them to our ErrorMessages property
if (results.Errors.Count >= 1)
{
List<string> errorCollection = new List<string>();
List<String> errorCollection = new List<String>();
foreach (CompilerError error in results.Errors)
{
string prefix = "Error: ";
String prefix = "Error: ";
if (error.IsWarning)
prefix = "Warning: ";
@ -270,7 +270,7 @@ namespace MudEngine.Scripting
Log.Write("Supplied script path does not exist! No scripts loaded.");
return;
}
string[] libraries = Directory.GetFiles(ScriptPath, "*.dll", SearchOption.AllDirectories);
String[] libraries = Directory.GetFiles(ScriptPath, "*.dll", SearchOption.AllDirectories);
if (libraries.Length == 0)
{
@ -278,9 +278,9 @@ namespace MudEngine.Scripting
return;
}
foreach (string library in libraries)
foreach (String library in libraries)
{
bool isOK = true;
Boolean isOK = true;
foreach (Assembly assembly in _AssemblyCollection)
{
@ -304,7 +304,7 @@ namespace MudEngine.Scripting
if (!Directory.Exists(ScriptPath))
Directory.CreateDirectory(ScriptPath);
string[] scripts = Directory.GetFiles(ScriptPath, "*.cs", SearchOption.AllDirectories);
String[] scripts = Directory.GetFiles(ScriptPath, "*.cs", SearchOption.AllDirectories);
if (scripts.Length == 0)
{
@ -315,7 +315,7 @@ namespace MudEngine.Scripting
if (!CompileScripts())
{
Log.Write("Error Compiling Scripts:");
foreach (string error in _ErrorMessages)
foreach (String error in _ErrorMessages)
{
Log.Write("Error: " + error);
}
@ -324,7 +324,7 @@ namespace MudEngine.Scripting
_AssemblyCollection.Add(_ScriptAssembly);
}
public GameObject GetObject(string objectName)
public GameObject GetObject(String objectName)
{
IEnumerable<GameObject> objectQuery =
from gameObject in ObjectCollection._GameObjects
@ -340,7 +340,7 @@ namespace MudEngine.Scripting
return null;
}
public GameObject GetObjectOf(string baseTypeName)
public GameObject GetObjectOf(String baseTypeName)
{
foreach (GameObject obj in GameObjects)
{

View file

@ -14,10 +14,10 @@ namespace MudGame
{
static class Program
{
const string SettingsFile = "Settings.ini";
const String SettingsFile = "Settings.ini";
static Game game;
static void Main(string[] args)
static void Main(String[] args)
{
Log.Write("Launching...");
@ -61,7 +61,7 @@ namespace MudGame
}
else
{
Log.Write("Setting up " + obj.GetProperty().GameTitle + " Manager...");
Log.Write("Setting up " + obj.GetProperty("GameTitle") + " Manager...");
game = (Game)obj.Instance;
scriptEngine = new ScriptEngine(game, ScriptEngine.ScriptTypes.Both);
}
@ -109,10 +109,31 @@ namespace MudGame
}
}
Console.Title = game.GameTitle;
if (game.IsMultiplayer)
Console.Title += " server running.";
List<char> buf = new List<char>();
while (game.IsRunning)
{
game.Update();
System.Threading.Thread.Sleep(1);
StringBuilder sb = new StringBuilder();
ConsoleKeyInfo info = Console.ReadKey();
if (info.KeyChar == '\r')
{
foreach (char c in buf)
sb.Append(c);
game.PlayerCollection[0].ExecuteCommand(sb.ToString());
}
else
buf.Add(info.KeyChar);
}
}
}