Mercurial > repos > IBDev-IBBoard.WarFoundry.API
diff api/Factories/Xml/WarFoundryXmlFactory.cs @ 6:150a5669cd7b
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
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 04 Jan 2009 12:13:59 +0000 |
parents | 520818033bb6 |
children | 613bc5eaac59 |
line wrap: on
line diff
--- 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<string, SystemStats> 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<string, SystemStats> CreateSystemStatsSetFromElement(XmlElement elem) + private void LoadSystemStatsFromElement(XmlElement elem, GameSystem system) { - Dictionary<string, SystemStats> dict = new Dictionary<string,SystemStats>(); - 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)