changeset 327:1c32b8a1600e

Re #27: Define unit requirements * Add checking for passing requirements
author IBBoard <dev@ibboard.co.uk>
date Sat, 26 Mar 2011 21:02:55 +0000
parents 331995582990
children f8471453c3cb
files api/Objects/UnitRequiresAtLeastNUnitsRequirement.cs
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line diff
     1.1 --- a/api/Objects/UnitRequiresAtLeastNUnitsRequirement.cs	Sat Mar 26 17:03:00 2011 +0000
     1.2 +++ b/api/Objects/UnitRequiresAtLeastNUnitsRequirement.cs	Sat Mar 26 21:02:55 2011 +0000
     1.3 @@ -21,7 +21,18 @@
     1.4  
     1.5  		public bool CanAddToArmy(Unit unit, Army army)
     1.6  		{
     1.7 -			return false;
     1.8 +			bool canAdd = true;
     1.9 +
    1.10 +			foreach (UnitType type in requiredTypes)
    1.11 +			{
    1.12 +				if (army.GetUnitTypeCount(type) < 1)
    1.13 +				{
    1.14 +					canAdd = false;
    1.15 +					break;
    1.16 +				}
    1.17 +			}
    1.18 +
    1.19 +			return canAdd;
    1.20  		}
    1.21  	}
    1.22  }