# HG changeset patch # User IBBoard # Date 1231071239 0 # Node ID 150a5669cd7b4656fbd58f5797fbc859d279f666 # Parent b9346894319c47cfd5a4054d5cfcc347a5479f95 Re #9 - more granular loading * Remove SystemStatsSet class so that other classes don't know the internals of how GameSystem stores its stats (cleaner code principle) * Make XML loader each stats set and add to the game system * Add methods to GameSystem to remove use of SystemStatsSet and hide internal handling * Add methods to add SystemStats to GameSystem diff -r b9346894319c -r 150a5669cd7b IBBoard.WarFoundry.API.mdp --- a/IBBoard.WarFoundry.API.mdp Fri Dec 26 12:45:32 2008 +0000 +++ b/IBBoard.WarFoundry.API.mdp Sun Jan 04 12:13:59 2009 +0000 @@ -62,7 +62,6 @@ - @@ -89,7 +88,6 @@ - diff -r b9346894319c -r 150a5669cd7b api/Factories/Xml/WarFoundryXmlFactory.cs --- a/api/Factories/Xml/WarFoundryXmlFactory.cs Fri Dec 26 12:45:32 2008 +0000 +++ b/api/Factories/Xml/WarFoundryXmlFactory.cs Sun Jan 04 12:13:59 2009 +0000 @@ -242,12 +242,11 @@ LogNotifier.DebugFormat(GetType(), "Found {0} categories", cats.Length); XmlElement statsElem = (XmlElement)catsElem.NextSibling; - Dictionary sysStats = CreateSystemStatsSetFromElement(statsElem); + LoadSystemStatsFromElement(statsElem, system); string defaultStatsID = statsElem.GetAttribute("defaultStats"); LogNotifier.DebugFormat(GetType(), "Complete loading of {0}", system.Name); system.Categories = cats; - system.SystemStats = new SystemStatsSet(sysStats); system.StandardSystemStatsID = defaultStatsID; } else if (obj is Race) @@ -583,7 +582,7 @@ } else { - statsSet = system.SystemStats[statsID]; + statsSet = system.GetSystemStatsForID(statsID); } Stats stats = new Stats(statsSet); @@ -608,17 +607,13 @@ return stats; } - private Dictionary CreateSystemStatsSetFromElement(XmlElement elem) + private void LoadSystemStatsFromElement(XmlElement elem, GameSystem system) { - Dictionary dict = new Dictionary(); - foreach (XmlElement stats in elem.ChildNodes) { SystemStats sysStats = CreateSystemStatsFromElement(stats); - dict.Add(sysStats.ID, sysStats); + system.AddSystemStats(sysStats); } - - return dict; } private SystemStats CreateSystemStatsFromElement(XmlElement elem) diff -r b9346894319c -r 150a5669cd7b api/Objects/GameSystem.cs --- a/api/Objects/GameSystem.cs Fri Dec 26 12:45:32 2008 +0000 +++ b/api/Objects/GameSystem.cs Sun Jan 04 12:13:59 2009 +0000 @@ -15,12 +15,13 @@ { private bool warnOnError; private Category[] categories; - private SystemStatsSet stats; + private Dictionary stats; private string defaultStats; private FileInfo sourceFile; public GameSystem(string systemID, string systemName) : base(systemID, systemName) { + stats = new Dictionary(); } /*public void CompleteLoading(Category[] cats, Dictionary sysStats, string defaultStatsID) @@ -48,16 +49,19 @@ } public Category GetCategory(string id) - { - for (int i = 0; i statsMap; - public SystemStatsSet(Dictionary stats) - { - statsMap = stats; - } - - public SystemStats this[string key] - { - get { return statsMap[key]; } - - set - { - if (statsMap.ContainsKey(key)) - { - statsMap[key] = value; - } - else - { - throw new ArgumentException("Key must already exist for values to be set"); - } - } - } - - public string[] GetSystemStatsIDs() - { - string[] ids = new string[statsMap.Count]; - statsMap.Keys.CopyTo(ids, 0); - return ids; - } - } -} diff -r b9346894319c -r 150a5669cd7b dtds/translation.dtd --- a/dtds/translation.dtd Fri Dec 26 12:45:32 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ - - - - \ No newline at end of file