changeset 329:a5b34ca10d80

Re #27: Define unit requirements * Update method name for a more "natural language" approach of "if (req.AllowsAdding(...))"
author IBBoard <dev@ibboard.co.uk>
date Sun, 27 Mar 2011 19:15:31 +0000
parents f8471453c3cb
children 8ca5dd75d5b8
files api/Objects/UnitRequiresAtLeastNUnitsRequirement.cs
diffstat 1 files changed, 14 insertions(+), 2 deletions(-) [+]
line diff
     1.1 --- a/api/Objects/UnitRequiresAtLeastNUnitsRequirement.cs	Sun Mar 27 19:09:27 2011 +0000
     1.2 +++ b/api/Objects/UnitRequiresAtLeastNUnitsRequirement.cs	Sun Mar 27 19:15:31 2011 +0000
     1.3 @@ -19,13 +19,25 @@
     1.4  			requiredTypes = new List<UnitType>(requiredUnitTypes);
     1.5  		}
     1.6  
     1.7 -		public bool CanAddToArmy(WarFoundryObject unit, Army army)
     1.8 +		/// <summary>
     1.9 +		/// Checks whether the supplied WarFoundryObject can be added to the supplied army.
    1.10 +		/// </summary>
    1.11 +		/// <returns>
    1.12 +		/// <c>true</c> if the object can be added, else <c>false</c>
    1.13 +		/// </returns>
    1.14 +		/// <param name='wfObject'>
    1.15 +		/// The object that we want to add. This may be involved in the check, or it may not affect the evaluation of the requirement
    1.16 +		/// </param>
    1.17 +		/// <param name='toArmy'>
    1.18 +		/// The army to add the object to.
    1.19 +		/// </param>
    1.20 +		public bool AllowsAdding(WarFoundryObject wfObject, Army toArmy)
    1.21  		{
    1.22  			bool canAdd = true;
    1.23  
    1.24  			foreach (UnitType type in requiredTypes)
    1.25  			{
    1.26 -				if (army.GetUnitTypeCount(type) < 1)
    1.27 +				if (toArmy.GetUnitTypeCount(type) < 1)
    1.28  				{
    1.29  					canAdd = false;
    1.30  					break;