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 diff
     1.1 --- a/API/Objects/Army.cs	Sat Apr 09 15:51:39 2011 +0000
     1.2 +++ b/API/Objects/Army.cs	Sat Apr 09 16:01:02 2011 +0000
     1.3 @@ -227,21 +227,25 @@
     1.4  			}
     1.5  		}
     1.6  
     1.7 +		[Obsolete]
     1.8  		public List<FailedUnitRequirement> CanAddUnit(Unit unit)
     1.9  		{
    1.10  			return CanAddUnitType(unit.UnitType);
    1.11  		}
    1.12  
    1.13 +		[Obsolete]
    1.14  		public List<FailedUnitRequirement> CanAddUnitType(UnitType unitType)
    1.15  		{
    1.16  			return unitType.CanAddToArmy(this);
    1.17  		}
    1.18  
    1.19 +		[Obsolete]
    1.20  		public List<FailedUnitRequirement> CanRemoveUnit(Unit unit)
    1.21  		{
    1.22  			return CanRemoveUnitType(unit.UnitType);
    1.23  		}
    1.24  
    1.25 +		[Obsolete]
    1.26  		public List<FailedUnitRequirement> CanRemoveUnitType(UnitType unitType)
    1.27  		{
    1.28  			return unitType.CanRemoveFromArmy(this);
     2.1 --- a/API/Objects/UnitType.cs	Sat Apr 09 15:51:39 2011 +0000
     2.2 +++ b/API/Objects/UnitType.cs	Sat Apr 09 16:01:02 2011 +0000
     2.3 @@ -8,6 +8,7 @@
     2.4  using IBBoard.Limits;
     2.5  using IBBoard.Logging;
     2.6  using IBBoard.WarFoundry.API.Requirements;
     2.7 +using IBBoard.WarFoundry.API.Objects.Requirement;
     2.8  
     2.9  namespace IBBoard.WarFoundry.API.Objects
    2.10  {
    2.11 @@ -23,7 +24,7 @@
    2.12  		private double baseUnitCost;
    2.13  		private double costPerTrooper;
    2.14  		private Stats stats;
    2.15 -		private List<UnitRequirement> requirements = new List<UnitRequirement>();
    2.16 +		private List<IRequirement> requirements = new List<IRequirement>();
    2.17  		private Dictionary<string, UnitEquipmentItem> equipment = new Dictionary<string, UnitEquipmentItem>();
    2.18  		private Dictionary<string, List<UnitEquipmentItem>> equipmentExclusionGroups = new Dictionary<string, List<UnitEquipmentItem>>();
    2.19  		private List<string> equipmentKeyOrder = new List<string>();
    2.20 @@ -457,53 +458,27 @@
    2.21  			}
    2.22  		}
    2.23  
    2.24 -		public void AddRequirement(UnitRequirement requirement)
    2.25 +		public void AddRequirement(IRequirement requirement)
    2.26  		{
    2.27  			requirements.Add(requirement);
    2.28  		}
    2.29 -		
    2.30 -		public UnitRequirement[] Requirements
    2.31 +
    2.32 +		public IRequirement[] GetRequirements()
    2.33  		{
    2.34 -			get { return requirements.ToArray(); }
    2.35 +			return requirements.ToArray();
    2.36  		}
    2.37 -		
    2.38 +
    2.39 +		[Obsolete]
    2.40  		public List<FailedUnitRequirement> CanAddToArmy(Army army)
    2.41  		{
    2.42  			List<FailedUnitRequirement> failures = new List<FailedUnitRequirement>();
    2.43 -			
    2.44 -			if (requirements!=null && requirements.Count > 0)
    2.45 -			{
    2.46 -				foreach (UnitRequirement requirement in requirements)
    2.47 -				{
    2.48 -					FailedUnitRequirement failure = (FailedUnitRequirement)requirement.CanAddToWarFoundryObject(army);
    2.49 -					
    2.50 -					if (failure!=null)
    2.51 -					{
    2.52 -						failures.Add(failure);
    2.53 -					}
    2.54 -				}
    2.55 -			}
    2.56 -			
    2.57  			return failures;
    2.58  		}
    2.59 -		
    2.60 +
    2.61 +		[Obsolete]
    2.62  		public List<FailedUnitRequirement> CanRemoveFromArmy(Army army)
    2.63  		{
    2.64  			List<FailedUnitRequirement> failures = new List<FailedUnitRequirement>();
    2.65 -			
    2.66 -			if (requirements!=null && requirements.Count > 0)
    2.67 -			{
    2.68 -				foreach (UnitRequirement requirement in requirements)
    2.69 -				{
    2.70 -					FailedUnitRequirement failure = (FailedUnitRequirement)requirement.CanRemoveFromWarFoundryObject(army);
    2.71 -					
    2.72 -					if (failure!=null)
    2.73 -					{
    2.74 -						failures.Add(failure);
    2.75 -					}
    2.76 -				}
    2.77 -			}
    2.78 -			
    2.79  			return failures;
    2.80  		}
    2.81