changeset 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 44a6539fadf9
children 12a56786120c
files API/Objects/Army.cs API/Objects/UnitType.cs
diffstat 2 files changed, 14 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/API/Objects/Army.cs	Sat Apr 09 15:51:39 2011 +0000
+++ b/API/Objects/Army.cs	Sat Apr 09 16:01:02 2011 +0000
@@ -227,21 +227,25 @@
 			}
 		}
 
+		[Obsolete]
 		public List<FailedUnitRequirement> CanAddUnit(Unit unit)
 		{
 			return CanAddUnitType(unit.UnitType);
 		}
 
+		[Obsolete]
 		public List<FailedUnitRequirement> CanAddUnitType(UnitType unitType)
 		{
 			return unitType.CanAddToArmy(this);
 		}
 
+		[Obsolete]
 		public List<FailedUnitRequirement> CanRemoveUnit(Unit unit)
 		{
 			return CanRemoveUnitType(unit.UnitType);
 		}
 
+		[Obsolete]
 		public List<FailedUnitRequirement> CanRemoveUnitType(UnitType unitType)
 		{
 			return unitType.CanRemoveFromArmy(this);
--- 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;
 		}