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 diff
     1.1 --- a/API/Factories/Xml/WarFoundryXmlFactory.cs	Sat May 28 15:40:05 2011 +0000
     1.2 +++ b/API/Factories/Xml/WarFoundryXmlFactory.cs	Sat May 28 15:51:54 2011 +0000
     1.3 @@ -14,7 +14,6 @@
     1.4  using IBBoard.Lang;
     1.5  using IBBoard.Logging;
     1.6  using IBBoard.Xml;
     1.7 -using IBBoard.WarFoundry.API.Requirements;
     1.8  using IBBoard.WarFoundry.API.Objects;
     1.9  using ICSharpCode.SharpZipLib.Zip;
    1.10  using System.Text.RegularExpressions;
     2.1 --- a/API/Objects/Army.cs	Sat May 28 15:40:05 2011 +0000
     2.2 +++ b/API/Objects/Army.cs	Sat May 28 15:51:54 2011 +0000
     2.3 @@ -27,7 +27,6 @@
     2.4  
     2.5  		public event ObjectAddDelegate UnitAdded;
     2.6  		public event ObjectRemoveDelegate UnitRemoved;
     2.7 -		public event FailedUnitRequirementDelegate FailedRequirement;
     2.8  		public event DoubleValChangedDelegate PointsValueChanged;
     2.9  		private DoubleValChangedDelegate PointsValueChangedMethod;
    2.10  		
    2.11 @@ -69,7 +68,6 @@
    2.12  						cat.PointsValueChanged+= PointsValueChangedMethod;
    2.13  						cat.UnitAdded+=new ObjectAddDelegate(Army_UnitAdded);
    2.14  						cat.UnitRemoved+=new ObjectRemoveDelegate(Army_UnitRemoved);
    2.15 -						cat.FailedRequirement+=new FailedUnitRequirementDelegate(Army_FailedRequirement);
    2.16  					}
    2.17  				}
    2.18  				
    2.19 @@ -97,40 +95,18 @@
    2.20  
    2.21  		protected void OnUnitAdded(Unit unit)
    2.22  		{
    2.23 -			OnUnitAdded(unit, null);
    2.24 -		}
    2.25 -
    2.26 -		protected void OnUnitAdded(Unit unit, List<FailedUnitRequirement> failedReqs)
    2.27 -		{
    2.28  			if (UnitAdded != null)
    2.29  			{
    2.30  				UnitAdded(unit);
    2.31  			}
    2.32 -
    2.33 -			OnFailedRequirement(failedReqs);
    2.34  		}
    2.35  
    2.36  		protected void OnUnitRemoved(Unit unit)
    2.37  		{
    2.38 -			OnUnitRemoved(unit, null);
    2.39 -		}
    2.40 -
    2.41 -		protected void OnUnitRemoved(Unit unit, List<FailedUnitRequirement> failedReqs)
    2.42 -		{
    2.43  			if (UnitRemoved!=null)
    2.44  			{
    2.45  				UnitRemoved(unit);
    2.46  			}
    2.47 -
    2.48 -			OnFailedRequirement(failedReqs);
    2.49 -		}
    2.50 -
    2.51 -		protected void OnFailedRequirement(List<FailedUnitRequirement> failedReqs)
    2.52 -		{
    2.53 -			if (FailedRequirement != null && failedReqs != null && failedReqs.Count > 0)
    2.54 -			{
    2.55 -				FailedRequirement(failedReqs);
    2.56 -			}
    2.57  		}
    2.58  
    2.59  		private void OnPointsValueChanged(double oldValue, double newValue)
    2.60 @@ -227,30 +203,6 @@
    2.61  			}
    2.62  		}
    2.63  
    2.64 -		[Obsolete]
    2.65 -		public List<FailedUnitRequirement> CanAddUnit(Unit unit)
    2.66 -		{
    2.67 -			return CanAddUnitType(unit.UnitType);
    2.68 -		}
    2.69 -
    2.70 -		[Obsolete]
    2.71 -		public List<FailedUnitRequirement> CanAddUnitType(UnitType unitType)
    2.72 -		{
    2.73 -			return unitType.CanAddToArmy(this);
    2.74 -		}
    2.75 -
    2.76 -		[Obsolete]
    2.77 -		public List<FailedUnitRequirement> CanRemoveUnit(Unit unit)
    2.78 -		{
    2.79 -			return CanRemoveUnitType(unit.UnitType);
    2.80 -		}
    2.81 -
    2.82 -		[Obsolete]
    2.83 -		public List<FailedUnitRequirement> CanRemoveUnitType(UnitType unitType)
    2.84 -		{
    2.85 -			return unitType.CanRemoveFromArmy(this);
    2.86 -		}
    2.87 -
    2.88  		public int GetUnitTypeCount(UnitType unitType)
    2.89  		{
    2.90  			int count = 0;
    2.91 @@ -273,11 +225,6 @@
    2.92  			OnUnitRemoved((Unit)val);
    2.93  		}
    2.94  
    2.95 -		private void Army_FailedRequirement(List<FailedUnitRequirement> val)
    2.96 -		{
    2.97 -			OnFailedRequirement(val);
    2.98 -		}
    2.99 -
   2.100  		public ICollection<IRequirement> GetRequirements ()
   2.101  		{
   2.102  			return Race.GetRequirements();
     3.1 --- a/API/Objects/ArmyCategory.cs	Sat May 28 15:40:05 2011 +0000
     3.2 +++ b/API/Objects/ArmyCategory.cs	Sat May 28 15:51:54 2011 +0000
     3.3 @@ -4,7 +4,6 @@
     3.4  
     3.5  using System;
     3.6  using System.Collections.Generic;
     3.7 -using IBBoard.WarFoundry.API.Requirements;
     3.8  
     3.9  namespace IBBoard.WarFoundry.API.Objects
    3.10  {
    3.11 @@ -21,7 +20,6 @@
    3.12  		private DoubleValChangedDelegate PointsValueChangedMethod;
    3.13  		public event ObjectAddDelegate UnitAdded;
    3.14  		public event ObjectRemoveDelegate UnitRemoved;
    3.15 -		public event FailedUnitRequirementDelegate FailedRequirement;
    3.16  		public event DoubleValChangedDelegate PointsValueChanged;
    3.17  
    3.18  		public ArmyCategory(Army army, Category cat) : base()
    3.19 @@ -67,7 +65,8 @@
    3.20  
    3.21  		internal void AddUnit(Unit unit)
    3.22  		{
    3.23 -			List<FailedUnitRequirement> failedReqs = ParentArmy.CanAddUnit(unit);
    3.24 +			//TODO: Put back a similar check
    3.25 +			//List<FailedUnitRequirement> failedReqs = ParentArmy.CanAddUnit(unit);
    3.26  			units.Add(unit);
    3.27  			unit.Category = this;
    3.28  			unit.PointsValueChanged+= PointsValueChangedMethod;
    3.29 @@ -75,17 +74,18 @@
    3.30  			unitTypes.TryGetValue(unit.UnitType.ID, out unitTypeCount);
    3.31  			unitTypes[unit.UnitType.ID] = (int)unitTypeCount + 1;
    3.32  			TotalPoints+= unit.Points;
    3.33 -			OnUnitAdded(unit, failedReqs);
    3.34 +			OnUnitAdded(unit);
    3.35  		}
    3.36  
    3.37  		internal void RemoveUnit(Unit unit)
    3.38  		{
    3.39 -			List<FailedUnitRequirement> failedReqs = ParentArmy.CanRemoveUnit(unit);
    3.40 +			//TODO: Put back a similar check
    3.41 +			//List<FailedUnitRequirement> failedReqs = ParentArmy.CanRemoveUnit(unit);
    3.42  			units.Remove(unit);
    3.43  			unitTypes[unit.UnitType.ID] = ((int)unitTypes[unit.UnitType.ID])-1;
    3.44  			TotalPoints-= unit.Points;
    3.45  			unit.PointsValueChanged-= PointsValueChangedMethod;
    3.46 -			OnUnitRemoved(unit, failedReqs);
    3.47 +			OnUnitRemoved(unit);
    3.48  		}
    3.49  
    3.50  		public int GetUnitTypeCount(UnitType unitType)
    3.51 @@ -129,38 +129,18 @@
    3.52  
    3.53  		protected void OnUnitAdded(Unit unit)
    3.54  		{
    3.55 -			OnUnitAdded(unit, null);
    3.56 -		}
    3.57 -
    3.58 -		protected void OnUnitAdded(Unit unit, List<FailedUnitRequirement> failedReqs)
    3.59 -		{
    3.60  			if (UnitAdded != null)
    3.61  			{
    3.62  				UnitAdded(unit);
    3.63  			}
    3.64 -
    3.65 -			if (FailedRequirement != null && failedReqs != null && failedReqs.Count > 0)
    3.66 -			{
    3.67 -				FailedRequirement(failedReqs);
    3.68 -			}
    3.69  		}
    3.70  
    3.71  		protected void OnUnitRemoved(Unit unit)
    3.72  		{
    3.73 -			OnUnitRemoved(unit, null);
    3.74 -		}
    3.75 -
    3.76 -		protected void OnUnitRemoved(Unit unit, List<FailedUnitRequirement> failedReqs)
    3.77 -		{
    3.78  			if (UnitRemoved != null)
    3.79  			{
    3.80  				UnitRemoved(unit);
    3.81  			}
    3.82 -
    3.83 -			if (FailedRequirement != null && failedReqs != null && failedReqs.Count > 0)
    3.84 -			{
    3.85 -				FailedRequirement(failedReqs);
    3.86 -			}
    3.87  		}
    3.88  
    3.89  		protected virtual void OnPointsValueChanged(double oldValue, double newValue)
     4.1 --- a/API/Objects/UnitType.cs	Sat May 28 15:40:05 2011 +0000
     4.2 +++ b/API/Objects/UnitType.cs	Sat May 28 15:51:54 2011 +0000
     4.3 @@ -7,7 +7,6 @@
     4.4  using System.Xml;
     4.5  using IBBoard.Limits;
     4.6  using IBBoard.Logging;
     4.7 -using IBBoard.WarFoundry.API.Requirements;
     4.8  using IBBoard.WarFoundry.API.Objects.Requirement;
     4.9  
    4.10  namespace IBBoard.WarFoundry.API.Objects
    4.11 @@ -510,20 +509,6 @@
    4.12  
    4.13  			return reqs.ToArray();
    4.14  		}
    4.15 -
    4.16 -		[Obsolete]
    4.17 -		public List<FailedUnitRequirement> CanAddToArmy(Army army)
    4.18 -		{
    4.19 -			List<FailedUnitRequirement> failures = new List<FailedUnitRequirement>();
    4.20 -			return failures;
    4.21 -		}
    4.22 -
    4.23 -		[Obsolete]
    4.24 -		public List<FailedUnitRequirement> CanRemoveFromArmy(Army army)
    4.25 -		{
    4.26 -			List<FailedUnitRequirement> failures = new List<FailedUnitRequirement>();
    4.27 -			return failures;
    4.28 -		}
    4.29  		
    4.30  		public string Notes
    4.31  		{