diff API/Objects/UnitType.cs @ 348:d34ae0057a39

Re #27: Unit requirements * Obsolete methods using the old requirements system * Switch to new IRequirement objects
author IBBoard <dev@ibboard.co.uk>
date Sat, 09 Apr 2011 16:01:02 +0000
parents 3c4a6403a88c
children 51cccccf3669
line wrap: on
line diff
--- a/API/Objects/UnitType.cs	Sat Apr 09 15:51:39 2011 +0000
+++ b/API/Objects/UnitType.cs	Sat Apr 09 16:01:02 2011 +0000
@@ -8,6 +8,7 @@
 using IBBoard.Limits;
 using IBBoard.Logging;
 using IBBoard.WarFoundry.API.Requirements;
+using IBBoard.WarFoundry.API.Objects.Requirement;
 
 namespace IBBoard.WarFoundry.API.Objects
 {
@@ -23,7 +24,7 @@
 		private double baseUnitCost;
 		private double costPerTrooper;
 		private Stats stats;
-		private List<UnitRequirement> requirements = new List<UnitRequirement>();
+		private List<IRequirement> requirements = new List<IRequirement>();
 		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>();
@@ -457,53 +458,27 @@
 			}
 		}
 
-		public void AddRequirement(UnitRequirement requirement)
+		public void AddRequirement(IRequirement requirement)
 		{
 			requirements.Add(requirement);
 		}
-		
-		public UnitRequirement[] Requirements
+
+		public IRequirement[] GetRequirements()
 		{
-			get { return requirements.ToArray(); }
+			return requirements.ToArray();
 		}
-		
+
+		[Obsolete]
 		public List<FailedUnitRequirement> CanAddToArmy(Army army)
 		{
 			List<FailedUnitRequirement> failures = new List<FailedUnitRequirement>();
-			
-			if (requirements!=null && requirements.Count > 0)
-			{
-				foreach (UnitRequirement requirement in requirements)
-				{
-					FailedUnitRequirement failure = (FailedUnitRequirement)requirement.CanAddToWarFoundryObject(army);
-					
-					if (failure!=null)
-					{
-						failures.Add(failure);
-					}
-				}
-			}
-			
 			return failures;
 		}
-		
+
+		[Obsolete]
 		public List<FailedUnitRequirement> CanRemoveFromArmy(Army army)
 		{
 			List<FailedUnitRequirement> failures = new List<FailedUnitRequirement>();
-			
-			if (requirements!=null && requirements.Count > 0)
-			{
-				foreach (UnitRequirement requirement in requirements)
-				{
-					FailedUnitRequirement failure = (FailedUnitRequirement)requirement.CanRemoveFromWarFoundryObject(army);
-					
-					if (failure!=null)
-					{
-						failures.Add(failure);
-					}
-				}
-			}
-			
 			return failures;
 		}