CharacterStats.ToString() now returns a formatted string with all of the stats.
StandardGame and it's Child Classes display the name of the game when ToString() is invoked. Realm and Zone save/load code is completed.
This commit is contained in:
parent
ee3cd897f2
commit
706c770dd7
6 changed files with 133 additions and 15 deletions
|
@ -17,7 +17,7 @@ namespace MudEngine.Game.Environment
|
|||
{
|
||||
get
|
||||
{
|
||||
String path = Path.Combine(this.Game.SavePaths.GetPath(DAL.DataTypes.Environments), this.Realm.Name, "Zones", this.Name + "." + this.GetType().Name);
|
||||
String path = Path.Combine(Path.GetDirectoryName(this.Realm.Filename), "Zones", this.Name + "." + this.GetType().Name);
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
@ -31,8 +31,9 @@ namespace MudEngine.Game.Environment
|
|||
|
||||
public Realm Realm { get; set; }
|
||||
|
||||
public Zone(StandardGame game, String name, String description) : base(game, name, description)
|
||||
public Zone(StandardGame game, String name, String description, Realm realm) : base(game, name, description)
|
||||
{
|
||||
this.Realm = realm;
|
||||
this._RoomCollection = new List<Room>();
|
||||
}
|
||||
|
||||
|
@ -42,8 +43,59 @@ namespace MudEngine.Game.Environment
|
|||
return false;
|
||||
|
||||
this.SaveData.AddSaveData("Safe", this.Safe.ToString());
|
||||
this.SaveData.Save(this.Filename);
|
||||
return true;
|
||||
this.SaveData.AddSaveData("CharacterStats", this.StatDrain.ToString());
|
||||
|
||||
return this.SaveData.Save(this.Filename);
|
||||
}
|
||||
|
||||
public override void Load(string filename)
|
||||
{
|
||||
String path = Path.GetDirectoryName(filename);
|
||||
if (!Directory.Exists(path))
|
||||
return;
|
||||
|
||||
base.Load(filename);
|
||||
|
||||
try { this.Safe = Convert.ToBoolean(this.SaveData.GetData("Safe")); }
|
||||
catch { this.LoadFailedMessage("Safe"); }
|
||||
|
||||
try
|
||||
{
|
||||
String data = this.SaveData.GetData("CharacterStats");
|
||||
String[] stats = data.Split('.');
|
||||
CharacterStats charStats = new CharacterStats();
|
||||
|
||||
foreach (String stat in stats)
|
||||
{
|
||||
String[] value = stat.Split(':');
|
||||
|
||||
switch (value[0])
|
||||
{
|
||||
case "Strength":
|
||||
charStats.Strength = Convert.ToInt32(value[1]);
|
||||
break;
|
||||
case "Dexterity":
|
||||
charStats.Dexterity = Convert.ToInt32(value[1]);
|
||||
break;
|
||||
case "Constitution":
|
||||
charStats.Constitution = Convert.ToInt32(value[1]);
|
||||
break;
|
||||
case "Wisdom":
|
||||
charStats.Wisdom = Convert.ToInt32(value[1]);
|
||||
break;
|
||||
case "Charisma":
|
||||
charStats.Charisma = Convert.ToInt32(value[1]);
|
||||
break;
|
||||
case "Experience":
|
||||
charStats.Experience = Convert.ToInt32(value[1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
this.LoadFailedMessage("CharacterStats");
|
||||
}
|
||||
}
|
||||
|
||||
public Room CreateRoom(String name, String description)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue