diff api/Objects/UnitType.cs @ 82:3ea0ab04352b

* Fix line terminators no-open-ticket
author IBBoard <dev@ibboard.co.uk>
date Sat, 27 Jun 2009 18:59:49 +0000
parents 032b174fc17a
children 46ad6f478203
line wrap: on
line diff
--- a/api/Objects/UnitType.cs	Wed May 27 19:43:09 2009 +0000
+++ b/api/Objects/UnitType.cs	Sat Jun 27 18:59:49 2009 +0000
@@ -3,41 +3,41 @@
 // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license.
 
 using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
 using System.Xml;
 using IBBoard.Logging;
-using IBBoard.WarFoundry.API.Requirements;
-
-namespace IBBoard.WarFoundry.API.Objects
-{
-	/// <summary>
-	/// A UnitType is a type for a <see cref=" Unit"/>, normally relating to an entry in an army list. The UnitType defines the name, cost, minimum and maximum limits of a unit, and the equipment units of the type can take.
-	/// </summary>
-	public class UnitType : WarFoundryObject
+using IBBoard.WarFoundry.API.Requirements;
+
+namespace IBBoard.WarFoundry.API.Objects
+{
+	/// <summary>
+	/// A UnitType is a type for a <see cref=" Unit"/>, normally relating to an entry in an army list. The UnitType defines the name, cost, minimum and maximum limits of a unit, and the equipment units of the type can take.
+	/// </summary>
+	public class UnitType : WarFoundryObject
 	{
 		private Category mainCat;
-		private Race race;
-		private int min, max, baseSize = 0;
+		private Race race;
+		private int min, max, baseSize = 0;
 		private int minSize, maxSize;
-		private double baseUnitCost;
-		private double costPerTrooper;
-		private Stats stats;
-		private List<UnitRequirement> requirements = new List<UnitRequirement>();
-		private Dictionary<string, UnitEquipmentItem> equipment = new Dictionary<string, UnitEquipmentItem>();
-		private Dictionary<string, List<UnitEquipmentItem>> equipmentExclusionGroups = new Dictionary<string, List<UnitEquipmentItem>>();
+		private double baseUnitCost;
+		private double costPerTrooper;
+		private Stats stats;
+		private List<UnitRequirement> requirements = new List<UnitRequirement>();
+		private Dictionary<string, UnitEquipmentItem> equipment = new Dictionary<string, UnitEquipmentItem>();
+		private Dictionary<string, List<UnitEquipmentItem>> equipmentExclusionGroups = new Dictionary<string, List<UnitEquipmentItem>>();
 		private List<string> equipmentKeyOrder = new List<string>();
 		private Dictionary<string, Ability> requiredAbilities = new Dictionary<string, Ability>();
 		private Dictionary<string, Ability> optionalAbilities = new Dictionary<string, Ability>();
 		private String notes = "";
 		private List<UnitType> containedTypes = new List<UnitType>();
-		private Dictionary<string, string> extraData = new Dictionary<string, string>();
-
-
-		public UnitType(string id, string typeName, Race parentRace) : base(id, typeName)
-		{
-			race = parentRace;
-		}
-
+		private Dictionary<string, string> extraData = new Dictionary<string, string>();
+
+
+		public UnitType(string id, string typeName, Race parentRace) : base(id, typeName)
+		{
+			race = parentRace;
+		}
+
 		[Obsolete("Use three parameter constructor and setters")]
 		public UnitType(string id, string typeName, string mainCategoryID, string[] allCategoryIDs, int minNum, int maxNum, int minimumSize, int maximumSize, double unitCost, double trooperCost, Stats unitStats, UnitRequirement[] unitRequirements, Race parentRace) : this (id, typeName, parentRace)
 		{
@@ -48,13 +48,13 @@
 			MaxSize = maximumSize;
 			BaseUnitCost = unitCost;
 			CostPerTrooper = trooperCost;
-			SetUnitStats(unitStats);
-
-			foreach (UnitRequirement requirement in requirements)
-			{
-				AddRequirement(requirement);
+			SetUnitStats(unitStats);
+
+			foreach (UnitRequirement requirement in requirements)
+			{
+				AddRequirement(requirement);
 			}
-		}
+		}
 
 		public GameSystem GameSystem
 		{
@@ -63,101 +63,101 @@
 		
 		/// <value>
 		/// Gets the <see cref=" Race"/> that this unit belongs to.
-		/// </value>
-		public Race Race
-		{
-			get { return race; }
-		}
+		/// </value>
+		public Race Race
+		{
+			get { return race; }
+		}
 
 		/// <value>
 		/// Gets or sets the <see cref=" Category"/> that this unit type is a member of.
-		/// </value>
-		public virtual Category MainCategory
-		{
+		/// </value>
+		public virtual Category MainCategory
+		{
 			get
 			{					
 				return mainCat;
-			}
-			set
-			{
-				mainCat = value;
-			}
-		}
+			}
+			set
+			{
+				mainCat = value;
+			}
+		}
 
 		/// <value>
 		/// Gets or sets the minimum size of each unit of this type. Note: This should be set AFTER MaxSize, otherwise an unintended default value may be set for the minimum
-		/// </value>
-		public int MinSize
-		{
-			get { return minSize; }
-			set
+		/// </value>
+		public int MinSize
+		{
+			get { return minSize; }
+			set
 			{
-				minSize = (value >= 0 ? value : 0);
-				CheckMinimumSize();
-			}
-		}
+				minSize = (value >= 0 ? value : 0);
+				CheckMinimumSize();
+			}
+		}
 
 		/// <value>
 		/// Gets or sets the maximum size of each unit of this type. Note: This should be set BEFORE MinSize, otherwise an unintended default value may be set for the minimum
-		/// </value>
-		public int MaxSize
-		{
-			get { return maxSize; }
-			set
-			{
-				maxSize = (value >= 0 ? value : WarFoundryCore.INFINITY);
-				CheckMinimumSize();
-			}
+		/// </value>
+		public int MaxSize
+		{
+			get { return maxSize; }
+			set
+			{
+				maxSize = (value >= 0 ? value : WarFoundryCore.INFINITY);
+				CheckMinimumSize();
+			}
 		}
-		
+		
 		/// <value>
 		/// Gets or sets the minimum number of units of this type that must be taken in an army. Note: This should be set AFTER MaxNumber, otherwise an unintended default value may be set for the minimum
-		/// </value>
-		public int MinNumber
-		{
-			get { return min; }
-			set
+		/// </value>
+		public int MinNumber
+		{
+			get { return min; }
+			set
 			{
-				min = (value >= 0 ? value : 0);
-				CheckMinimumNumber();
-			}
-		}
+				min = (value >= 0 ? value : 0);
+				CheckMinimumNumber();
+			}
+		}
 
 		/// <value>
 		/// Gets or sets the maximum number of units of this type that can be taken in an army. Note: This should be set BEFORE MinNumber, otherwise an unintended default value may be set for the minimum
-		/// </value>
-		public int MaxNumber
-		{
-			get { return max; }
-			set
-			{
-				max = (value >= 0 ? value : WarFoundryCore.INFINITY);
-				CheckMinimumNumber();
-			}
-		}
+		/// </value>
+		public int MaxNumber
+		{
+			get { return max; }
+			set
+			{
+				max = (value >= 0 ? value : WarFoundryCore.INFINITY);
+				CheckMinimumNumber();
+			}
+		}
 
 		/// <summary>
 		/// Makes sure that the minimum number isn't more than the maximum number, hence the warning on the properties
-		/// </summary>
-		private void CheckMinimumNumber()
-		{
+		/// </summary>
+		private void CheckMinimumNumber()
+		{
 			if (MinNumber > MaxNumber && MaxNumber!=WarFoundryCore.INFINITY)
 			{
 				MinNumber = MaxNumber;
 				LogNotifier.WarnFormat(GetType(), "Unit type {0} ({1}) had a minimum number greater than their maximum number.", Name, ID);
-			}
-		}
+			}
+		}
 
 		/// <summary>
 		/// Makes sure that the minimum unit size isn't more than the maximum unit size, hence the warning on the properties
-		/// </summary>
-		private void CheckMinimumSize()
-		{
+		/// </summary>
+		private void CheckMinimumSize()
+		{
 			if (MinSize > MaxSize && MaxSize!=WarFoundryCore.INFINITY)
 			{
 				MinSize = MaxSize;
 				LogNotifier.WarnFormat(GetType(), "Unit type {0} ({1}) had a minimum size greater than their maximum size.", Name, ID);
-			}
+			}
 		}
 		
 		//// <value>
@@ -174,33 +174,33 @@
 		/// </value>
 		public double BaseUnitCost
 		{
-			get { return baseUnitCost; }
+			get { return baseUnitCost; }
 			set { baseUnitCost = (value >= 0 ? value : 0); }
-		}
+		}
 
 		//// <value>
 		/// The cost of an individual trooper. This value is the cost for a basic trooper without weapons, which are added on top of the cost before calculating a unit cost.
-		/// </value>
-		public double CostPerTrooper
-		{
-			get { return costPerTrooper; }
-			set { costPerTrooper = (value >= 0 ? value : 0); }
-		}
-
-		protected override string DefaultName()
-		{
-			throw new InvalidOperationException("Unit type with id "+id+" did not have a name specified");
-		}
+		/// </value>
+		public double CostPerTrooper
+		{
+			get { return costPerTrooper; }
+			set { costPerTrooper = (value >= 0 ? value : 0); }
+		}
+
+		protected override string DefaultName()
+		{
+			throw new InvalidOperationException("Unit type with id "+id+" did not have a name specified");
+		}
 
 		/// <value>
 		/// The set of <see cref="Stat"/>s for the unit in a format that is valid for the game system.
-		/// </value>
-		public Stat[] UnitStatsArray
-		{
-			get 
-			{
-				return stats.StatsArray;
-			}
+		/// </value>
+		public Stat[] UnitStatsArray
+		{
+			get 
+			{
+				return stats.StatsArray;
+			}
 		}
 
 		//// <value>
@@ -250,7 +250,7 @@
 				
 				items.Add(item);
 			}
-		}
+		}
 
 		/// <summary>
 		/// Gets a <see cref="UnitEquipmentItem"/> for the given ID string, or <code>null</code> if nothing exists for that ID
@@ -260,10 +260,10 @@
 		/// </param>
 		/// <returns>
 		/// The <see cref="UnitEquipmentItem"/> for the given ID string, or <code>null</code> if nothing exists for that ID
-		/// </returns>
-		public UnitEquipmentItem GetEquipmentItem(string id)
+		/// </returns>
+		public UnitEquipmentItem GetEquipmentItem(string id)
 		{
-			return DictionaryUtils.GetValue(equipment, id);
+			return DictionaryUtils.GetValue(equipment, id);
 		}
 		
 		/// <summary>
@@ -278,17 +278,17 @@
 		public UnitEquipmentItem GetEquipmentItem(EquipmentItem item)
 		{
 			return GetEquipmentItem(item.ID);
-		}
+		}
 
 		/// <summary>
 		/// Gets an array of all available <see cref="UnitEquipmentItem"/>s for this UnitType
 		/// </summary>
 		/// <returns>
 		/// An array of all available <see cref="UnitEquipmentItem"/>s for this UnitType
-		/// </returns>
-		public UnitEquipmentItem[] GetEquipmentItems()
-		{
-			return DictionaryUtils.ToArray<string, UnitEquipmentItem>(equipment);
+		/// </returns>
+		public UnitEquipmentItem[] GetEquipmentItems()
+		{
+			return DictionaryUtils.ToArray<string, UnitEquipmentItem>(equipment);
 		}
 
 		public UnitEquipmentItem[] GetEquipmentItemsByExclusionGroup(string group)
@@ -342,23 +342,23 @@
 					optionalAbilities[id] = ability;
 				}
 			}
-		}
-
-		public void AddRequirement(UnitRequirement requirement)
-		{
-			requirements.Add(requirement);
+		}
+
+		public void AddRequirement(UnitRequirement requirement)
+		{
+			requirements.Add(requirement);
 		}
 		
 		public UnitRequirement[] Requirements
 		{
 			get { return requirements.ToArray(); }
-		}
+		}
 		
 		public List<FailedUnitRequirement> CanAddToArmy(Army army)
 		{
 			List<FailedUnitRequirement> failures = new List<FailedUnitRequirement>();
 			
-			if (requirements!=null && requirements.Count > 0)
+			if (requirements!=null && requirements.Count > 0)
 			{
 				foreach (UnitRequirement requirement in requirements)
 				{
@@ -378,7 +378,7 @@
 		{
 			List<FailedUnitRequirement> failures = new List<FailedUnitRequirement>();
 			
-			if (requirements!=null && requirements.Count > 0)
+			if (requirements!=null && requirements.Count > 0)
 			{
 				foreach (UnitRequirement requirement in requirements)
 				{
@@ -428,6 +428,6 @@
 		public string GetExtraData(string id)
 		{
 			return DictionaryUtils.GetValue(extraData, id);
-		}
-	}
+		}
+	}
 }
\ No newline at end of file