# HG changeset patch # User Tsudico # Date 1292540630 0 # Node ID 4dcb038e4f5543d4c1f60c2927b9dc66d1efd048 # Parent 24e7b571f50f507e52ca3db4080ae42310a7c0a8 Re #320: WarFoundry.API - GameSystem cannot remove or set categories and stat lines * Update GameSystem * Categories * SetCategory added * RemoveCategory added * SystemStats * SetSystemStats added * RemoveSystemStats added diff -r 24e7b571f50f -r 4dcb038e4f55 api/Objects/GameSystem.cs --- a/api/Objects/GameSystem.cs Tue Dec 14 20:17:07 2010 +0000 +++ b/api/Objects/GameSystem.cs Thu Dec 16 23:03:50 2010 +0000 @@ -64,6 +64,29 @@ RawCategories.TryGetValue(id, out cat); return cat; } + + public void SetCategory(Category cat) + { + Category old; + RawCategories.TryGetValue(cat.ID, out old); + + if(old == null) + { + AddCategory(cat); + } + else + { + if(!old.Equals(cat)) + { + RawCategories[old.ID] = cat; + } + } + } + + public void RemoveCategory(string id) + { + RawCategories.Remove(id); + } public Category[] Categories { @@ -138,6 +161,29 @@ return statsForID; } + public void SetSystemStats(SystemStats newStats) + { + SystemStats old; + stats.TryGetValue(newStats.ID, out old); + + if(old == null) + { + AddSystemStats(newStats); + } + else + { + if(!old.Equals(newStats)) + { + stats[old.ID] = newStats; + } + } + } + + public void RemoveSystemStats(string id) + { + stats.Remove(id); + } + public Race SystemDefaultRace { get { return WarFoundryLoader.GetDefault().GetRace(this, Race.SYSTEM_DEFAULT_RACE_ID); }