changeset 367:1a70ca80ef41

Re #27: Define unit requirements * Remove remaining references to old Requirements namespace
author IBBoard <dev@ibboard.co.uk>
date Sat, 28 May 2011 15:51:54 +0000
parents 4993e6f7c509
children 8cfb1818823d
files API/Factories/Xml/WarFoundryXmlFactory.cs API/Objects/Army.cs API/Objects/ArmyCategory.cs API/Objects/UnitType.cs
diffstat 4 files changed, 6 insertions(+), 95 deletions(-) [+]
line wrap: on
line diff
--- a/API/Factories/Xml/WarFoundryXmlFactory.cs	Sat May 28 15:40:05 2011 +0000
+++ b/API/Factories/Xml/WarFoundryXmlFactory.cs	Sat May 28 15:51:54 2011 +0000
@@ -14,7 +14,6 @@
 using IBBoard.Lang;
 using IBBoard.Logging;
 using IBBoard.Xml;
-using IBBoard.WarFoundry.API.Requirements;
 using IBBoard.WarFoundry.API.Objects;
 using ICSharpCode.SharpZipLib.Zip;
 using System.Text.RegularExpressions;
--- a/API/Objects/Army.cs	Sat May 28 15:40:05 2011 +0000
+++ b/API/Objects/Army.cs	Sat May 28 15:51:54 2011 +0000
@@ -27,7 +27,6 @@
 
 		public event ObjectAddDelegate UnitAdded;
 		public event ObjectRemoveDelegate UnitRemoved;
-		public event FailedUnitRequirementDelegate FailedRequirement;
 		public event DoubleValChangedDelegate PointsValueChanged;
 		private DoubleValChangedDelegate PointsValueChangedMethod;
 		
@@ -69,7 +68,6 @@
 						cat.PointsValueChanged+= PointsValueChangedMethod;
 						cat.UnitAdded+=new ObjectAddDelegate(Army_UnitAdded);
 						cat.UnitRemoved+=new ObjectRemoveDelegate(Army_UnitRemoved);
-						cat.FailedRequirement+=new FailedUnitRequirementDelegate(Army_FailedRequirement);
 					}
 				}
 				
@@ -97,40 +95,18 @@
 
 		protected void OnUnitAdded(Unit unit)
 		{
-			OnUnitAdded(unit, null);
-		}
-
-		protected void OnUnitAdded(Unit unit, List<FailedUnitRequirement> failedReqs)
-		{
 			if (UnitAdded != null)
 			{
 				UnitAdded(unit);
 			}
-
-			OnFailedRequirement(failedReqs);
 		}
 
 		protected void OnUnitRemoved(Unit unit)
 		{
-			OnUnitRemoved(unit, null);
-		}
-
-		protected void OnUnitRemoved(Unit unit, List<FailedUnitRequirement> failedReqs)
-		{
 			if (UnitRemoved!=null)
 			{
 				UnitRemoved(unit);
 			}
-
-			OnFailedRequirement(failedReqs);
-		}
-
-		protected void OnFailedRequirement(List<FailedUnitRequirement> failedReqs)
-		{
-			if (FailedRequirement != null && failedReqs != null && failedReqs.Count > 0)
-			{
-				FailedRequirement(failedReqs);
-			}
 		}
 
 		private void OnPointsValueChanged(double oldValue, double newValue)
@@ -227,30 +203,6 @@
 			}
 		}
 
-		[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);
-		}
-
 		public int GetUnitTypeCount(UnitType unitType)
 		{
 			int count = 0;
@@ -273,11 +225,6 @@
 			OnUnitRemoved((Unit)val);
 		}
 
-		private void Army_FailedRequirement(List<FailedUnitRequirement> val)
-		{
-			OnFailedRequirement(val);
-		}
-
 		public ICollection<IRequirement> GetRequirements ()
 		{
 			return Race.GetRequirements();
--- a/API/Objects/ArmyCategory.cs	Sat May 28 15:40:05 2011 +0000
+++ b/API/Objects/ArmyCategory.cs	Sat May 28 15:51:54 2011 +0000
@@ -4,7 +4,6 @@
 
 using System;
 using System.Collections.Generic;
-using IBBoard.WarFoundry.API.Requirements;
 
 namespace IBBoard.WarFoundry.API.Objects
 {
@@ -21,7 +20,6 @@
 		private DoubleValChangedDelegate PointsValueChangedMethod;
 		public event ObjectAddDelegate UnitAdded;
 		public event ObjectRemoveDelegate UnitRemoved;
-		public event FailedUnitRequirementDelegate FailedRequirement;
 		public event DoubleValChangedDelegate PointsValueChanged;
 
 		public ArmyCategory(Army army, Category cat) : base()
@@ -67,7 +65,8 @@
 
 		internal void AddUnit(Unit unit)
 		{
-			List<FailedUnitRequirement> failedReqs = ParentArmy.CanAddUnit(unit);
+			//TODO: Put back a similar check
+			//List<FailedUnitRequirement> failedReqs = ParentArmy.CanAddUnit(unit);
 			units.Add(unit);
 			unit.Category = this;
 			unit.PointsValueChanged+= PointsValueChangedMethod;
@@ -75,17 +74,18 @@
 			unitTypes.TryGetValue(unit.UnitType.ID, out unitTypeCount);
 			unitTypes[unit.UnitType.ID] = (int)unitTypeCount + 1;
 			TotalPoints+= unit.Points;
-			OnUnitAdded(unit, failedReqs);
+			OnUnitAdded(unit);
 		}
 
 		internal void RemoveUnit(Unit unit)
 		{
-			List<FailedUnitRequirement> failedReqs = ParentArmy.CanRemoveUnit(unit);
+			//TODO: Put back a similar check
+			//List<FailedUnitRequirement> failedReqs = ParentArmy.CanRemoveUnit(unit);
 			units.Remove(unit);
 			unitTypes[unit.UnitType.ID] = ((int)unitTypes[unit.UnitType.ID])-1;
 			TotalPoints-= unit.Points;
 			unit.PointsValueChanged-= PointsValueChangedMethod;
-			OnUnitRemoved(unit, failedReqs);
+			OnUnitRemoved(unit);
 		}
 
 		public int GetUnitTypeCount(UnitType unitType)
@@ -129,38 +129,18 @@
 
 		protected void OnUnitAdded(Unit unit)
 		{
-			OnUnitAdded(unit, null);
-		}
-
-		protected void OnUnitAdded(Unit unit, List<FailedUnitRequirement> failedReqs)
-		{
 			if (UnitAdded != null)
 			{
 				UnitAdded(unit);
 			}
-
-			if (FailedRequirement != null && failedReqs != null && failedReqs.Count > 0)
-			{
-				FailedRequirement(failedReqs);
-			}
 		}
 
 		protected void OnUnitRemoved(Unit unit)
 		{
-			OnUnitRemoved(unit, null);
-		}
-
-		protected void OnUnitRemoved(Unit unit, List<FailedUnitRequirement> failedReqs)
-		{
 			if (UnitRemoved != null)
 			{
 				UnitRemoved(unit);
 			}
-
-			if (FailedRequirement != null && failedReqs != null && failedReqs.Count > 0)
-			{
-				FailedRequirement(failedReqs);
-			}
 		}
 
 		protected virtual void OnPointsValueChanged(double oldValue, double newValue)
--- a/API/Objects/UnitType.cs	Sat May 28 15:40:05 2011 +0000
+++ b/API/Objects/UnitType.cs	Sat May 28 15:51:54 2011 +0000
@@ -7,7 +7,6 @@
 using System.Xml;
 using IBBoard.Limits;
 using IBBoard.Logging;
-using IBBoard.WarFoundry.API.Requirements;
 using IBBoard.WarFoundry.API.Objects.Requirement;
 
 namespace IBBoard.WarFoundry.API.Objects
@@ -510,20 +509,6 @@
 
 			return reqs.ToArray();
 		}
-
-		[Obsolete]
-		public List<FailedUnitRequirement> CanAddToArmy(Army army)
-		{
-			List<FailedUnitRequirement> failures = new List<FailedUnitRequirement>();
-			return failures;
-		}
-
-		[Obsolete]
-		public List<FailedUnitRequirement> CanRemoveFromArmy(Army army)
-		{
-			List<FailedUnitRequirement> failures = new List<FailedUnitRequirement>();
-			return failures;
-		}
 		
 		public string Notes
 		{