diff api/Objects/UnitType.cs @ 34:b28be912adab

Re #32 - Migrate to schema * Remove use of Categories (now just has a single category) * Fix infinite loop of trying to load files by adding a "is loading" flag * Fix invalid setting of MinSize to MaxNumber when we're testing if MinSize > MaxSize
author IBBoard <dev@ibboard.co.uk>
date Sun, 15 Mar 2009 16:07:52 +0000
parents 306558904c2a
children 548cfc776f54
line wrap: on
line diff
--- a/api/Objects/UnitType.cs	Sun Mar 15 15:10:02 2009 +0000
+++ b/api/Objects/UnitType.cs	Sun Mar 15 16:07:52 2009 +0000
@@ -16,8 +16,7 @@
 	/// </summary>
 	public class UnitType : WarFoundryObject
 	{
-		protected Category mainCat;
-		protected List<Category> categories = new List<Category>();
+		protected Category mainCat;
 		protected Race race;
 		protected int min, max, baseSize = 0;
 		protected int minSize, maxSize;
@@ -39,13 +38,7 @@
 		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) : base(id, typeName)
 		{
 			race = parentRace;
-			mainCat = race.GetCategory(mainCategoryID);
-
-			foreach (string catID in allCategoryIDs)
-			{
-				categories.Add(race.GetCategory(catID));
-			}
-			
+			mainCat = race.GetCategory(mainCategoryID);			
 			MinNumber = minNum;			
 			MaxNumber = maxNum;
 			MinSize = minimumSize;			
@@ -73,30 +66,7 @@
 			}
 			set
 			{
-				if (value!=null && categories.Contains(value))
-				{
-					mainCat = value;
-				}
-				else
-				{
-					throw new ArgumentException("MainCategory must exist in list of Categories");
-				}	
-			}
-		}
-		
-		public virtual Category[] Categories
-		{
-			get 
-			{				
-				return categories.ToArray();
-			}
-		}
-
-		public void AddCategory(Category cat)
-		{
-			if (!categories.Contains(cat))
-			{
-				categories.Add(cat);
+				mainCat = value;
 			}
 		}
 
@@ -158,7 +128,7 @@
 		{
 			if (MinSize > MaxSize && MaxSize!=-1)
 			{
-				MinSize = MaxNumber;
+				MinSize = MaxSize;
 				LogNotifier.WarnFormat(GetType(), "Unit type {0} ({1}) had a minimum size greater than their maximum size.", Name, ID);
 			}
 		}