changeset 390:4e0031339bcb default-army-name

Re #97: Default army size papercut. Updated GameSystem.cs, system.xsd and Factories to accommodate default system size.
author snowblizz
date Sun, 12 Dec 2010 15:27:07 +0000
parents 121d9d1ba53c
children d051f8f44e6c
files api/Factories/Xml/WarFoundryXmlGameSystemFactory.cs api/Objects/GameSystem.cs schemas/system.xsd
diffstat 3 files changed, 370 insertions(+), 347 deletions(-) [+]
line diff
     1.1 --- a/api/Factories/Xml/WarFoundryXmlGameSystemFactory.cs	Sun Nov 21 21:53:16 2010 +0000
     1.2 +++ b/api/Factories/Xml/WarFoundryXmlGameSystemFactory.cs	Sun Dec 12 15:27:07 2010 +0000
     1.3 @@ -1,97 +1,100 @@
     1.4 -//  This file (WarFoundryXmlGameSystemFactory.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard
     1.5 -// 
     1.6 -// The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
     1.7 -
     1.8 -using System;
     1.9 -using System.Collections.Generic;
    1.10 -using System.IO;
    1.11 -using System.Xml;
    1.12 -using ICSharpCode.SharpZipLib.Zip;
    1.13 -using IBBoard.Xml;
    1.14 -using IBBoard.WarFoundry.API.Objects;
    1.15 -
    1.16 -namespace IBBoard.WarFoundry.API.Factories.Xml
    1.17 -{
    1.18 -	/// <summary>
    1.19 -	/// A sub-factory specifically for loading GameSystems from WarFoundry XML files
    1.20 -	/// </summary>
    1.21 -	public class WarFoundryXmlGameSystemFactory : AbstractStagedLoadedSubFactory
    1.22 -	{	
    1.23 -		private Dictionary<GameSystem, XmlDocument> extraData = new Dictionary<GameSystem, XmlDocument>();
    1.24 -		
    1.25 -		public WarFoundryXmlGameSystemFactory(WarFoundryXmlFactory factory) : base(factory)
    1.26 -		{
    1.27 -		}
    1.28 -		
    1.29 -		private void StoreExtraData(GameSystem wfObject, XmlElement elem)
    1.30 -		{
    1.31 -			extraData[wfObject] = elem.OwnerDocument;
    1.32 -		}
    1.33 -	
    1.34 -		private XmlDocument GetExtraData(GameSystem obj)
    1.35 -		{
    1.36 -			XmlDocument extra = null;
    1.37 -			extraData.TryGetValue(obj, out extra);			
    1.38 -			return extra;
    1.39 -		}
    1.40 -		
    1.41 -		public GameSystem CreateSystemFromElement(ZipFile file, XmlElement elem)
    1.42 -		{
    1.43 -			string id = elem.GetAttribute("id");
    1.44 -			string name = elem.GetAttribute("name");
    1.45 -			GameSystem system = new GameSystem(id, name, mainFactory);
    1.46 -			StoreExtraData(system, elem);
    1.47 -			return system;
    1.48 -		}		
    1.49 -		
    1.50 -		public void CompleteLoading(GameSystem system)
    1.51 -		{
    1.52 -			if (!WarFoundryXmlFactoryUtils.CanCompleteLoading(system))
    1.53 -			{
    1.54 -				return;
    1.55 -			}
    1.56 -			
    1.57 -			system.SetAsLoading();			
    1.58 -			XmlDocument extraData = GetExtraData(system);
    1.59 -			LoadCategoriesForSystem(system, extraData);
    1.60 -			XmlElement statsElem = WarFoundryXmlFactoryUtils.SelectSingleElement(extraData, "/system:system/system:sysStatsList");
    1.61 -			string defaultStatsID = statsElem.GetAttribute("defaultStats");
    1.62 -			LoadSystemStatsForSystem(system, extraData);
    1.63 -			system.StandardSystemStatsID = defaultStatsID;
    1.64 -			XmlElement systemElement = WarFoundryXmlFactoryUtils.SelectSingleElement(extraData, "/system:system");
    1.65 -			system.WarnOnError = XmlTools.GetBoolValueFromAttribute(systemElement, "warn");
    1.66 -			system.AllowAllies = XmlTools.GetBoolValueFromAttribute(systemElement, "allowAllies");
    1.67 -			system.SetAsFullyLoaded();
    1.68 -		}
    1.69 -
    1.70 -		
    1.71 -		private void LoadCategoriesForSystem(GameSystem system, XmlNode elem)
    1.72 -		{
    1.73 -			foreach (XmlElement cat in WarFoundryXmlFactoryUtils.SelectNodes(elem, "/system:system/system:categories/cat:cat"))
    1.74 -			{
    1.75 -				system.AddCategory(CreateCategoryFromElement(cat));
    1.76 -			}
    1.77 -		}	
    1.78 -		
    1.79 -		private void LoadSystemStatsForSystem(GameSystem system, XmlNode elem)
    1.80 -		{
    1.81 -			foreach (XmlElement stats in WarFoundryXmlFactoryUtils.SelectNodes(elem, "/system:system/system:sysStatsList/system:sysStats"))
    1.82 -			{
    1.83 -				SystemStats sysStats = CreateSystemStatsFromElement(stats);
    1.84 -				system.AddSystemStats(sysStats);
    1.85 -			}
    1.86 -		}
    1.87 -		
    1.88 -		private SystemStats CreateSystemStatsFromElement(XmlElement elem)
    1.89 -		{
    1.90 -			SystemStats sysStats = new SystemStats(elem.GetAttribute("id"));
    1.91 -			
    1.92 -			foreach (XmlElement slot in WarFoundryXmlFactoryUtils.SelectNodes(elem, "system:sysStat"))
    1.93 -			{
    1.94 -				sysStats.AddStatSlot(slot.GetAttribute("name"));
    1.95 -			}
    1.96 -
    1.97 -			return sysStats;
    1.98 -		}	
    1.99 -	}
   1.100 -}
   1.101 +//  This file (WarFoundryXmlGameSystemFactory.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard
   1.102 +// 
   1.103 +// The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
   1.104 +
   1.105 +using System;
   1.106 +using System.Collections.Generic;
   1.107 +using System.IO;
   1.108 +using System.Xml;
   1.109 +using ICSharpCode.SharpZipLib.Zip;
   1.110 +using IBBoard.Xml;
   1.111 +using IBBoard.WarFoundry.API.Objects;
   1.112 +
   1.113 +namespace IBBoard.WarFoundry.API.Factories.Xml
   1.114 +{
   1.115 +	/// <summary>
   1.116 +	/// A sub-factory specifically for loading GameSystems from WarFoundry XML files
   1.117 +	/// </summary>
   1.118 +	public class WarFoundryXmlGameSystemFactory : AbstractStagedLoadedSubFactory
   1.119 +	{	
   1.120 +		private Dictionary<GameSystem, XmlDocument> extraData = new Dictionary<GameSystem, XmlDocument>();
   1.121 +		
   1.122 +		public WarFoundryXmlGameSystemFactory(WarFoundryXmlFactory factory) : base(factory)
   1.123 +		{
   1.124 +		}
   1.125 +		
   1.126 +		private void StoreExtraData(GameSystem wfObject, XmlElement elem)
   1.127 +		{
   1.128 +			extraData[wfObject] = elem.OwnerDocument;
   1.129 +		}
   1.130 +	
   1.131 +		private XmlDocument GetExtraData(GameSystem obj)
   1.132 +		{
   1.133 +			XmlDocument extra = null;
   1.134 +			extraData.TryGetValue(obj, out extra);			
   1.135 +			return extra;
   1.136 +		}
   1.137 +		
   1.138 +		public GameSystem CreateSystemFromElement(ZipFile file, XmlElement elem)
   1.139 +		{
   1.140 +			string id = elem.GetAttribute("id");
   1.141 +			string name = elem.GetAttribute("name");
   1.142 +            GameSystem system = new GameSystem(id, name, mainFactory);
   1.143 +            int defaultarmysize = XmlTools.GetIntValueFromAttribute(elem,"defaultArmySize");
   1.144 +            system.SystemArmyDefaultSize = defaultarmysize;
   1.145 +			StoreExtraData(system, elem);
   1.146 +			return system;
   1.147 +            
   1.148 +		}		
   1.149 +		
   1.150 +		public void CompleteLoading(GameSystem system)
   1.151 +        {
   1.152 +			if (!WarFoundryXmlFactoryUtils.CanCompleteLoading(system))
   1.153 +			{
   1.154 +				return;
   1.155 +			}
   1.156 +			
   1.157 +			system.SetAsLoading();			
   1.158 +			XmlDocument extraData = GetExtraData(system);
   1.159 +			LoadCategoriesForSystem(system, extraData);
   1.160 +			XmlElement statsElem = WarFoundryXmlFactoryUtils.SelectSingleElement(extraData, "/system:system/system:sysStatsList");
   1.161 +			string defaultStatsID = statsElem.GetAttribute("defaultStats");
   1.162 +			LoadSystemStatsForSystem(system, extraData);
   1.163 +			system.StandardSystemStatsID = defaultStatsID;
   1.164 +			XmlElement systemElement = WarFoundryXmlFactoryUtils.SelectSingleElement(extraData, "/system:system");
   1.165 +			system.WarnOnError = XmlTools.GetBoolValueFromAttribute(systemElement, "warn");
   1.166 +			system.AllowAllies = XmlTools.GetBoolValueFromAttribute(systemElement, "allowAllies");
   1.167 +			system.SetAsFullyLoaded();
   1.168 +		}
   1.169 +
   1.170 +		
   1.171 +		private void LoadCategoriesForSystem(GameSystem system, XmlNode elem)
   1.172 +		{
   1.173 +			foreach (XmlElement cat in WarFoundryXmlFactoryUtils.SelectNodes(elem, "/system:system/system:categories/cat:cat"))
   1.174 +			{
   1.175 +				system.AddCategory(CreateCategoryFromElement(cat));
   1.176 +			}
   1.177 +		}	
   1.178 +		
   1.179 +		private void LoadSystemStatsForSystem(GameSystem system, XmlNode elem)
   1.180 +		{
   1.181 +			foreach (XmlElement stats in WarFoundryXmlFactoryUtils.SelectNodes(elem, "/system:system/system:sysStatsList/system:sysStats"))
   1.182 +			{
   1.183 +				SystemStats sysStats = CreateSystemStatsFromElement(stats);
   1.184 +				system.AddSystemStats(sysStats);
   1.185 +			}
   1.186 +		}
   1.187 +		
   1.188 +		private SystemStats CreateSystemStatsFromElement(XmlElement elem)
   1.189 +		{
   1.190 +			SystemStats sysStats = new SystemStats(elem.GetAttribute("id"));
   1.191 +			
   1.192 +			foreach (XmlElement slot in WarFoundryXmlFactoryUtils.SelectNodes(elem, "system:sysStat"))
   1.193 +			{
   1.194 +				sysStats.AddStatSlot(slot.GetAttribute("name"));
   1.195 +			}
   1.196 +
   1.197 +			return sysStats;
   1.198 +		}	
   1.199 +	}
   1.200 +}
     2.1 --- a/api/Objects/GameSystem.cs	Sun Nov 21 21:53:16 2010 +0000
     2.2 +++ b/api/Objects/GameSystem.cs	Sun Dec 12 15:27:07 2010 +0000
     2.3 @@ -1,250 +1,269 @@
     2.4 -// This file (GameSystem.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2007, 2008, 2009 IBBoard.
     2.5 -//
     2.6 -// The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
     2.7 -
     2.8 -using System;
     2.9 -using System.Collections.Generic;
    2.10 -using System.Xml;
    2.11 -using System.IO;
    2.12 -using IBBoard.Logging;
    2.13 -using IBBoard.WarFoundry.API.Factories;
    2.14 -using ICSharpCode.SharpZipLib.Zip;
    2.15 -
    2.16 -namespace IBBoard.WarFoundry.API.Objects
    2.17 -{
    2.18 -	/// <summary>
    2.19 -	/// Summary description for GameSystem.
    2.20 -	/// </summary>
    2.21 -	public class GameSystem : WarFoundryStagedLoadingObject
    2.22 -	{
    2.23 -		private bool warnOnError;
    2.24 -		private bool allowAllies;
    2.25 -		private Dictionary<string, Category> categories = new Dictionary<string,Category>();
    2.26 -		private Dictionary<string, SystemStats> stats = new Dictionary<string,SystemStats>();
    2.27 -		private string defaultStats;
    2.28 -
    2.29 -		public GameSystem(string systemID, string systemName, IWarFoundryFactory creatingFactory) : base(systemID, systemName, creatingFactory)
    2.30 -		{
    2.31 -			stats = new Dictionary<string,SystemStats>();
    2.32 -		}
    2.33 -		
    2.34 -		public bool AllowAllies
    2.35 -		{
    2.36 -			get { return allowAllies; }
    2.37 -			set { allowAllies = value; }
    2.38 -		}
    2.39 -		
    2.40 -		public void AddCategory(Category cat)
    2.41 -		{
    2.42 -			RawCategories[cat.ID] = cat;
    2.43 -		}
    2.44 -
    2.45 -		public Category GetCategory(string id)
    2.46 -		{
    2.47 -			EnsureFullyLoaded();
    2.48 -			Category cat = null;
    2.49 -			RawCategories.TryGetValue(id, out cat);
    2.50 -			return cat;
    2.51 -		}
    2.52 -
    2.53 -		public Category[] Categories
    2.54 -		{
    2.55 -			get 
    2.56 -			{ 
    2.57 -				EnsureFullyLoaded();
    2.58 -				return DictionaryUtils.ToArray<string, Category>(RawCategories); 
    2.59 -			}
    2.60 -		}
    2.61 -		
    2.62 -		protected Dictionary<string, Category> RawCategories
    2.63 -		{
    2.64 -			get { return categories; }
    2.65 -		}
    2.66 -
    2.67 -		public bool WarnOnError
    2.68 -		{
    2.69 -			get
    2.70 -			{
    2.71 -				return warnOnError;
    2.72 -			}
    2.73 -			set { warnOnError = value; }
    2.74 -		}
    2.75 -		
    2.76 -		public void AddSystemStats(SystemStats sysStats)
    2.77 -		{
    2.78 -			stats[sysStats.ID] = sysStats;
    2.79 -		}
    2.80 -		
    2.81 -		public SystemStats StandardSystemStats
    2.82 -		{
    2.83 -			get
    2.84 -			{
    2.85 -				EnsureFullyLoaded();
    2.86 -				return stats[defaultStats];
    2.87 -			}
    2.88 -		}
    2.89 -		
    2.90 -		public string StandardSystemStatsID
    2.91 -		{
    2.92 -			get
    2.93 -			{
    2.94 -				EnsureFullyLoaded();
    2.95 -				return defaultStats;
    2.96 -			}
    2.97 -			
    2.98 -			set
    2.99 -			{
   2.100 -				if (value != null && value.Trim().Length > 0)
   2.101 -				{
   2.102 -					defaultStats = value;
   2.103 -				}
   2.104 -			}
   2.105 -		}
   2.106 -
   2.107 -		public SystemStats[] SystemStats
   2.108 -		{
   2.109 -			get 
   2.110 -			{ 
   2.111 -				EnsureFullyLoaded();
   2.112 -				SystemStats[] statsArray = new SystemStats[stats.Count];
   2.113 -				stats.Values.CopyTo(statsArray, 0);
   2.114 -				return statsArray;
   2.115 -			}
   2.116 -		}
   2.117 -		
   2.118 -		public SystemStats GetSystemStatsForID(string id)
   2.119 -		{
   2.120 -			EnsureFullyLoaded();
   2.121 -			SystemStats statsForID;
   2.122 -			stats.TryGetValue(id, out statsForID);
   2.123 -			return statsForID;
   2.124 -		}
   2.125 -		
   2.126 -		public Race SystemDefaultRace
   2.127 -		{
   2.128 -			get { return WarFoundryLoader.GetDefault().GetRace(this, Race.SYSTEM_DEFAULT_RACE_ID); }
   2.129 -		}
   2.130 -
   2.131 -		public bool Matches(GameSystem otherSystem)
   2.132 -		{
   2.133 -			if (otherSystem==null)
   2.134 -			{
   2.135 -				return false;
   2.136 -			}
   2.137 -
   2.138 -			return this.ID == otherSystem.ID;
   2.139 -		}
   2.140 -
   2.141 -		public override bool Equals(object obj)
   2.142 -		{
   2.143 -			if (obj == null)
   2.144 -			{
   2.145 -				return false;		
   2.146 -			}
   2.147 -			
   2.148 -			if (obj.GetType().Equals(this.GetType()))
   2.149 -			{
   2.150 -				GameSystem otherSystem = (GameSystem)obj;
   2.151 -
   2.152 -				return this.ID == otherSystem.ID && this.Name == otherSystem.Name && ((this.RawCategories == null && otherSystem.RawCategories == null) || this.RawCategories.Equals(otherSystem.RawCategories));
   2.153 -			}
   2.154 -			else
   2.155 -			{
   2.156 -				return false;
   2.157 -			}
   2.158 -		}
   2.159 -
   2.160 -		public override int GetHashCode()
   2.161 -		{
   2.162 -			return ID.GetHashCode() + Name.GetHashCode() + (RawCategories!=null ? RawCategories.GetHashCode() : 0) + warnOnError.GetHashCode();
   2.163 -		}
   2.164 -
   2.165 -		public bool UnitTypeMaxed(UnitType unitType, Army army)
   2.166 -		{
   2.167 -			return unitType.MaxNumber!=WarFoundryCore.INFINITY && army.GetUnitTypeCount(unitType) >= unitType.MaxNumber;
   2.168 -		}
   2.169 -
   2.170 -		public bool UnitTypeMinned(UnitType unitType, Army army)
   2.171 -		{
   2.172 -			return army.GetUnitTypeCount(unitType) <= unitType.MinNumber;
   2.173 -		}
   2.174 -		
   2.175 -		public List<EquipmentItem> GetSystemEquipmentList()
   2.176 -		{
   2.177 -			List<EquipmentItem> items = new List<EquipmentItem>();
   2.178 -			Race defaultRace = SystemDefaultRace;
   2.179 -			
   2.180 -			if (defaultRace!=null)
   2.181 -			{				
   2.182 -				items = defaultRace.GetEquipmentList();
   2.183 -			}
   2.184 -			
   2.185 -			return items;
   2.186 -		}
   2.187 -				
   2.188 -		public EquipmentItem GetSystemEquipmentItem(string id)
   2.189 -		{
   2.190 -			EquipmentItem item = null;
   2.191 -			Race defaultRace = SystemDefaultRace;
   2.192 -			
   2.193 -			if (defaultRace!=null)
   2.194 -			{				
   2.195 -				item = defaultRace.GetEquipmentItem(id);
   2.196 -			}
   2.197 -			
   2.198 -			return item;
   2.199 -		}
   2.200 -		
   2.201 -		public UnitType[] GetSystemUnitTypes(Category cat)
   2.202 -		{
   2.203 -			UnitType[] items = new UnitType[0];
   2.204 -			Race defaultRace = SystemDefaultRace;
   2.205 -			
   2.206 -			if (defaultRace!=null)
   2.207 -			{				
   2.208 -				items = defaultRace.GetUnitTypes(cat);
   2.209 -			}
   2.210 -			
   2.211 -			return items;
   2.212 -		}
   2.213 -				
   2.214 -		public UnitType GetSystemUnitType(string id)
   2.215 -		{
   2.216 -			UnitType unit = null;
   2.217 -			Race defaultRace = SystemDefaultRace;
   2.218 -			
   2.219 -			if (defaultRace!=null)
   2.220 -			{				
   2.221 -				unit = defaultRace.GetUnitType(id);
   2.222 -			}
   2.223 -			
   2.224 -			return unit;
   2.225 -		}
   2.226 -		
   2.227 -		public List<Ability> GetSystemAbilityList()
   2.228 -		{
   2.229 -			List<Ability> items = new List<Ability>();
   2.230 -			Race defaultRace = SystemDefaultRace;
   2.231 -			
   2.232 -			if (defaultRace!=null)
   2.233 -			{				
   2.234 -				items = defaultRace.GetAbilityList();
   2.235 -			}
   2.236 -			
   2.237 -			return items;
   2.238 -		}
   2.239 -				
   2.240 -		public Ability GetSystemAbility(string id)
   2.241 -		{
   2.242 -			Ability ability = null;
   2.243 -			Race defaultRace = SystemDefaultRace;
   2.244 -			
   2.245 -			if (defaultRace!=null)
   2.246 -			{				
   2.247 -				ability = defaultRace.GetAbility(id);
   2.248 -			}
   2.249 -			
   2.250 -			return ability;
   2.251 -		}
   2.252 -	}
   2.253 -}
   2.254 +// This file (GameSystem.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2007, 2008, 2009 IBBoard.
   2.255 +//
   2.256 +// The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
   2.257 +
   2.258 +using System;
   2.259 +using System.Collections.Generic;
   2.260 +using System.Xml;
   2.261 +using System.IO;
   2.262 +using IBBoard.Logging;
   2.263 +using IBBoard.WarFoundry.API.Factories;
   2.264 +using ICSharpCode.SharpZipLib.Zip;
   2.265 +
   2.266 +namespace IBBoard.WarFoundry.API.Objects
   2.267 +{
   2.268 +	/// <summary>
   2.269 +	/// Summary description for GameSystem.
   2.270 +	/// </summary>
   2.271 +	public class GameSystem : WarFoundryStagedLoadingObject
   2.272 +	{
   2.273 +        private static int SYSTEM_DEFAULT_ARMY_SIZE = 1000;
   2.274 +        private bool warnOnError;
   2.275 +		private bool allowAllies;
   2.276 +		private Dictionary<string, Category> categories = new Dictionary<string,Category>();
   2.277 +		private Dictionary<string, SystemStats> stats = new Dictionary<string,SystemStats>();
   2.278 +		private string defaultStats;
   2.279 +        private int defaultArmySize;
   2.280 +
   2.281 +        public GameSystem(string systemID, string systemName, IWarFoundryFactory creatingFactory)
   2.282 +            : base(systemID, systemName, creatingFactory)
   2.283 +		{
   2.284 +			stats = new Dictionary<string,SystemStats>();
   2.285 +		}
   2.286 +
   2.287 +        public int SystemArmyDefaultSize
   2.288 +        {
   2.289 +            get { return  defaultArmySize; }
   2.290 +            set
   2.291 +            {
   2.292 +                if (value == 0)
   2.293 +                {
   2.294 +                    defaultArmySize = SYSTEM_DEFAULT_ARMY_SIZE;
   2.295 +                }
   2.296 +                else
   2.297 +                {
   2.298 +                    defaultArmySize = value;
   2.299 +                }
   2.300 +            }
   2.301 +        }
   2.302 +		
   2.303 +		public bool AllowAllies
   2.304 +		{
   2.305 +			get { return allowAllies; }
   2.306 +			set { allowAllies = value; }
   2.307 +		}
   2.308 +		
   2.309 +		public void AddCategory(Category cat)
   2.310 +		{
   2.311 +			RawCategories[cat.ID] = cat;
   2.312 +		}
   2.313 +
   2.314 +		public Category GetCategory(string id)
   2.315 +		{
   2.316 +			EnsureFullyLoaded();
   2.317 +			Category cat = null;
   2.318 +			RawCategories.TryGetValue(id, out cat);
   2.319 +			return cat;
   2.320 +		}
   2.321 +
   2.322 +		public Category[] Categories
   2.323 +		{
   2.324 +			get 
   2.325 +			{ 
   2.326 +				EnsureFullyLoaded();
   2.327 +				return DictionaryUtils.ToArray<string, Category>(RawCategories); 
   2.328 +			}
   2.329 +		}
   2.330 +		
   2.331 +		protected Dictionary<string, Category> RawCategories
   2.332 +		{
   2.333 +			get { return categories; }
   2.334 +		}
   2.335 +
   2.336 +		public bool WarnOnError
   2.337 +		{
   2.338 +			get
   2.339 +			{
   2.340 +				return warnOnError;
   2.341 +			}
   2.342 +			set { warnOnError = value; }
   2.343 +		}
   2.344 +		
   2.345 +		public void AddSystemStats(SystemStats sysStats)
   2.346 +		{
   2.347 +			stats[sysStats.ID] = sysStats;
   2.348 +		}
   2.349 +		
   2.350 +		public SystemStats StandardSystemStats
   2.351 +		{
   2.352 +			get
   2.353 +			{
   2.354 +				EnsureFullyLoaded();
   2.355 +				return stats[defaultStats];
   2.356 +			}
   2.357 +		}
   2.358 +		
   2.359 +		public string StandardSystemStatsID
   2.360 +		{
   2.361 +			get
   2.362 +			{
   2.363 +				EnsureFullyLoaded();
   2.364 +				return defaultStats;
   2.365 +			}
   2.366 +			
   2.367 +			set
   2.368 +			{
   2.369 +				if (value != null && value.Trim().Length > 0)
   2.370 +				{
   2.371 +					defaultStats = value;
   2.372 +				}
   2.373 +			}
   2.374 +		}
   2.375 +
   2.376 +		public SystemStats[] SystemStats
   2.377 +		{
   2.378 +			get 
   2.379 +			{ 
   2.380 +				EnsureFullyLoaded();
   2.381 +				SystemStats[] statsArray = new SystemStats[stats.Count];
   2.382 +				stats.Values.CopyTo(statsArray, 0);
   2.383 +				return statsArray;
   2.384 +			}
   2.385 +		}
   2.386 +		
   2.387 +		public SystemStats GetSystemStatsForID(string id)
   2.388 +		{
   2.389 +			EnsureFullyLoaded();
   2.390 +			SystemStats statsForID;
   2.391 +			stats.TryGetValue(id, out statsForID);
   2.392 +			return statsForID;
   2.393 +		}
   2.394 +		
   2.395 +		public Race SystemDefaultRace
   2.396 +		{
   2.397 +			get { return WarFoundryLoader.GetDefault().GetRace(this, Race.SYSTEM_DEFAULT_RACE_ID); }
   2.398 +		}
   2.399 +
   2.400 +		public bool Matches(GameSystem otherSystem)
   2.401 +		{
   2.402 +			if (otherSystem==null)
   2.403 +			{
   2.404 +				return false;
   2.405 +			}
   2.406 +
   2.407 +			return this.ID == otherSystem.ID;
   2.408 +		}
   2.409 +
   2.410 +		public override bool Equals(object obj)
   2.411 +		{
   2.412 +			if (obj == null)
   2.413 +			{
   2.414 +				return false;		
   2.415 +			}
   2.416 +			
   2.417 +			if (obj.GetType().Equals(this.GetType()))
   2.418 +			{
   2.419 +				GameSystem otherSystem = (GameSystem)obj;
   2.420 +
   2.421 +				return this.ID == otherSystem.ID && this.Name == otherSystem.Name && ((this.RawCategories == null && otherSystem.RawCategories == null) || this.RawCategories.Equals(otherSystem.RawCategories));
   2.422 +			}
   2.423 +			else
   2.424 +			{
   2.425 +				return false;
   2.426 +			}
   2.427 +		}
   2.428 +
   2.429 +		public override int GetHashCode()
   2.430 +		{
   2.431 +			return ID.GetHashCode() + Name.GetHashCode() + (RawCategories!=null ? RawCategories.GetHashCode() : 0) + warnOnError.GetHashCode();
   2.432 +		}
   2.433 +
   2.434 +		public bool UnitTypeMaxed(UnitType unitType, Army army)
   2.435 +		{
   2.436 +			return unitType.MaxNumber!=WarFoundryCore.INFINITY && army.GetUnitTypeCount(unitType) >= unitType.MaxNumber;
   2.437 +		}
   2.438 +
   2.439 +		public bool UnitTypeMinned(UnitType unitType, Army army)
   2.440 +		{
   2.441 +			return army.GetUnitTypeCount(unitType) <= unitType.MinNumber;
   2.442 +		}
   2.443 +		
   2.444 +		public List<EquipmentItem> GetSystemEquipmentList()
   2.445 +		{
   2.446 +			List<EquipmentItem> items = new List<EquipmentItem>();
   2.447 +			Race defaultRace = SystemDefaultRace;
   2.448 +			
   2.449 +			if (defaultRace!=null)
   2.450 +			{				
   2.451 +				items = defaultRace.GetEquipmentList();
   2.452 +			}
   2.453 +			
   2.454 +			return items;
   2.455 +		}
   2.456 +				
   2.457 +		public EquipmentItem GetSystemEquipmentItem(string id)
   2.458 +		{
   2.459 +			EquipmentItem item = null;
   2.460 +			Race defaultRace = SystemDefaultRace;
   2.461 +			
   2.462 +			if (defaultRace!=null)
   2.463 +			{				
   2.464 +				item = defaultRace.GetEquipmentItem(id);
   2.465 +			}
   2.466 +			
   2.467 +			return item;
   2.468 +		}
   2.469 +		
   2.470 +		public UnitType[] GetSystemUnitTypes(Category cat)
   2.471 +		{
   2.472 +			UnitType[] items = new UnitType[0];
   2.473 +			Race defaultRace = SystemDefaultRace;
   2.474 +			
   2.475 +			if (defaultRace!=null)
   2.476 +			{				
   2.477 +				items = defaultRace.GetUnitTypes(cat);
   2.478 +			}
   2.479 +			
   2.480 +			return items;
   2.481 +		}
   2.482 +				
   2.483 +		public UnitType GetSystemUnitType(string id)
   2.484 +		{
   2.485 +			UnitType unit = null;
   2.486 +			Race defaultRace = SystemDefaultRace;
   2.487 +			
   2.488 +			if (defaultRace!=null)
   2.489 +			{				
   2.490 +				unit = defaultRace.GetUnitType(id);
   2.491 +			}
   2.492 +			
   2.493 +			return unit;
   2.494 +		}
   2.495 +		
   2.496 +		public List<Ability> GetSystemAbilityList()
   2.497 +		{
   2.498 +			List<Ability> items = new List<Ability>();
   2.499 +			Race defaultRace = SystemDefaultRace;
   2.500 +			
   2.501 +			if (defaultRace!=null)
   2.502 +			{				
   2.503 +				items = defaultRace.GetAbilityList();
   2.504 +			}
   2.505 +			
   2.506 +			return items;
   2.507 +		}
   2.508 +				
   2.509 +		public Ability GetSystemAbility(string id)
   2.510 +		{
   2.511 +			Ability ability = null;
   2.512 +			Race defaultRace = SystemDefaultRace;
   2.513 +			
   2.514 +			if (defaultRace!=null)
   2.515 +			{				
   2.516 +				ability = defaultRace.GetAbility(id);
   2.517 +			}
   2.518 +			
   2.519 +			return ability;
   2.520 +		}
   2.521 +	}
   2.522 +}
     3.1 --- a/schemas/system.xsd	Sun Nov 21 21:53:16 2010 +0000
     3.2 +++ b/schemas/system.xsd	Sun Dec 12 15:27:07 2010 +0000
     3.3 @@ -39,6 +39,7 @@
     3.4  		</xs:sequence>
     3.5  		<xs:attribute name="id" type="xs:string" />
     3.6  		<xs:attribute name="name" type="xs:string" use="required"/>
     3.7 +    <xs:attribute name="defaultArmySize" type="xs:integer" default="0"/>
     3.8  		<xs:attribute name="warn" type="xs:boolean" default="false"/>
     3.9  		<xs:attribute name="allowAllies" type="xs:boolean" default="true"/>
    3.10  		<xs:anyAttribute processContents="lax"/>