changeset 340:7bd2a7cdbfbd

Re #27: Unit requirements * Update "Requires at least" requirements to use new enum
author IBBoard <dev@ibboard.co.uk>
date Mon, 04 Apr 2011 19:06:01 +0000
parents 50cd43bf51b3
children 5f94b8a40876
files API/Objects/Requirement/RequiresAtLeastNUnitsRequirement.cs API/Objects/Requirement/UnitRequiresAtLeastNUnitsRequirement.cs
diffstat 2 files changed, 12 insertions(+), 12 deletions(-) [+]
line diff
     1.1 --- a/API/Objects/Requirement/RequiresAtLeastNUnitsRequirement.cs	Sun Apr 03 19:40:42 2011 +0000
     1.2 +++ b/API/Objects/Requirement/RequiresAtLeastNUnitsRequirement.cs	Mon Apr 04 19:06:01 2011 +0000
     1.3 @@ -28,7 +28,7 @@
     1.4  		/// Checks whether the supplied WarFoundryObject can be added to the supplied army.
     1.5  		/// </summary>
     1.6  		/// <returns>
     1.7 -		/// <c>true</c> if the object can be added, else <c>false</c>
     1.8 +		/// A <code>Validation</code> enum to show the result of the validation
     1.9  		/// </returns>
    1.10  		/// <param name='wfObject'>
    1.11  		/// 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.12 @@ -36,7 +36,7 @@
    1.13  		/// <param name='toArmy'>
    1.14  		/// The army to add the object to.
    1.15  		/// </param>
    1.16 -		public virtual bool AllowsAdding(WarFoundryObject wfObject, Army toArmy)
    1.17 +		public virtual Validation AllowsAdding(WarFoundryObject wfObject, Army toArmy)
    1.18  		{
    1.19  			return this.ValidatesArmy(toArmy);
    1.20  		}
    1.21 @@ -70,25 +70,25 @@
    1.22  		/// Checks whether the supplied army is currently valid according to this requirement.
    1.23  		/// </summary>
    1.24  		/// <returns>
    1.25 -		/// <c>true</c> if the army is valid, else <c>false</c>
    1.26 +		/// A <code>Validation</code> enum to show the result of the validation
    1.27  		/// </returns>
    1.28  		/// <param name='toValidate'>
    1.29  		/// The army to validate
    1.30  		/// </param>
    1.31 -		public virtual bool ValidatesArmy(Army toValidate)
    1.32 +		public virtual Validation ValidatesArmy(Army toValidate)
    1.33  		{
    1.34 -			bool canAdd = true;
    1.35 +			Validation isValid = Validation.Passed;
    1.36  
    1.37  			foreach (UnitCountRequirementData requirement in requiredTypes)
    1.38  			{
    1.39  				if (toValidate.GetUnitTypeCount(requirement.UnitType) < requirement.Count)
    1.40  				{
    1.41 -					canAdd = false;
    1.42 +					isValid = Validation.Failed;
    1.43  					break;
    1.44  				}
    1.45  			}
    1.46  
    1.47 -			return canAdd;
    1.48 +			return isValid;
    1.49  		}
    1.50  	}
    1.51  }
     2.1 --- a/API/Objects/Requirement/UnitRequiresAtLeastNUnitsRequirement.cs	Sun Apr 03 19:40:42 2011 +0000
     2.2 +++ b/API/Objects/Requirement/UnitRequiresAtLeastNUnitsRequirement.cs	Mon Apr 04 19:06:01 2011 +0000
     2.3 @@ -23,7 +23,7 @@
     2.4  		/// Checks whether the supplied WarFoundryObject can be added to the supplied army.
     2.5  		/// </summary>
     2.6  		/// <returns>
     2.7 -		/// <c>true</c> if the object can be added, else <c>false</c>
     2.8 +		/// A <code>Validation</code> enum to show the result of the validation
     2.9  		/// </returns>
    2.10  		/// <param name='wfObject'>
    2.11  		/// The object that we want to add. This may be involved in the check, or it may not affect the evaluation of the requirement
    2.12 @@ -31,9 +31,9 @@
    2.13  		/// <param name='toArmy'>
    2.14  		/// The army to add the object to.
    2.15  		/// </param>
    2.16 -		public override bool AllowsAdding(WarFoundryObject wfObject, Army toArmy)
    2.17 +		public override Validation AllowsAdding(WarFoundryObject wfObject, Army toArmy)
    2.18  		{
    2.19 -			return IsApplicable(wfObject, toArmy) ? base.ValidatesArmy(toArmy) : true;
    2.20 +			return IsApplicable(wfObject, toArmy) ? base.ValidatesArmy(toArmy) : Validation.NotApplicable;
    2.21  		}
    2.22  
    2.23  
    2.24 @@ -55,9 +55,9 @@
    2.25  		}
    2.26  
    2.27  
    2.28 -		public override bool ValidatesArmy(Army toArmy)
    2.29 +		public override Validation ValidatesArmy(Army toArmy)
    2.30  		{
    2.31 -			return IsApplicable(toArmy) ? base.ValidatesArmy(toArmy) : true;
    2.32 +			return IsApplicable(toArmy) ? base.ValidatesArmy(toArmy) : Validation.NotApplicable;
    2.33  		}
    2.34  	}
    2.35  }