Mercurial > repos > IBDev-IBBoard.WarFoundry.API
diff api/Objects/GameSystem.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/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<string, SystemStats> stats; private string defaultStats; private FileInfo sourceFile; public GameSystem(string systemID, string systemName) : base(systemID, systemName) { + stats = new Dictionary<string,SystemStats>(); } /*public void CompleteLoading(Category[] cats, Dictionary<string, SystemStats> sysStats, string defaultStatsID) @@ -48,16 +49,19 @@ } public Category GetCategory(string id) - { - for (int i = 0; i<categories.Length; i++) - { - if (categories[i].ID == id) + { + Category categoryForID = null; + + for (int i = 0; i<Categories.Length; i++) + { + Category cat = Categories[i]; + if (cat.ID == id) { - return categories[i]; + categoryForID = cat; } } - return null; + return categoryForID; } public Category[] Categories @@ -108,11 +112,16 @@ set { warnOnError = value; } } + public void AddSystemStats(SystemStats sysStats) + { + stats[sysStats.ID] = sysStats; + } + public SystemStats StandardSystemStats { get { - return SystemStats[defaultStats]; + return stats[defaultStats]; } } @@ -132,18 +141,23 @@ } } - public SystemStatsSet SystemStats + public SystemStats[] SystemStats { get - { - return stats; - } - set - { - stats = value; + { + SystemStats[] statsArray = new SystemStats[stats.Count]; + stats.Values.CopyTo(statsArray, 0); + return statsArray; } } + public SystemStats GetSystemStatsForID(string id) + { + SystemStats statsForID; + stats.TryGetValue(id, out statsForID); + return statsForID; + } + public Race SystemDefaultRace { get { return WarFoundryLoader.GetDefault().GetRace(this, Race.SYSTEM_DEFAULT_RACE_ID); }