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 wrap: on
line diff
--- a/API/Objects/Requirement/RequiresAtLeastNUnitsRequirement.cs	Sun Apr 03 19:40:42 2011 +0000
+++ b/API/Objects/Requirement/RequiresAtLeastNUnitsRequirement.cs	Mon Apr 04 19:06:01 2011 +0000
@@ -28,7 +28,7 @@
 		/// Checks whether the supplied WarFoundryObject can be added to the supplied army.
 		/// </summary>
 		/// <returns>
-		/// <c>true</c> if the object can be added, else <c>false</c>
+		/// A <code>Validation</code> enum to show the result of the validation
 		/// </returns>
 		/// <param name='wfObject'>
 		/// The object that we want to add. This may be involved in the check, or it may not affect the evaluation of the requirement
@@ -36,7 +36,7 @@
 		/// <param name='toArmy'>
 		/// The army to add the object to.
 		/// </param>
-		public virtual bool AllowsAdding(WarFoundryObject wfObject, Army toArmy)
+		public virtual Validation AllowsAdding(WarFoundryObject wfObject, Army toArmy)
 		{
 			return this.ValidatesArmy(toArmy);
 		}
@@ -70,25 +70,25 @@
 		/// Checks whether the supplied army is currently valid according to this requirement.
 		/// </summary>
 		/// <returns>
-		/// <c>true</c> if the army is valid, else <c>false</c>
+		/// A <code>Validation</code> enum to show the result of the validation
 		/// </returns>
 		/// <param name='toValidate'>
 		/// The army to validate
 		/// </param>
-		public virtual bool ValidatesArmy(Army toValidate)
+		public virtual Validation ValidatesArmy(Army toValidate)
 		{
-			bool canAdd = true;
+			Validation isValid = Validation.Passed;
 
 			foreach (UnitCountRequirementData requirement in requiredTypes)
 			{
 				if (toValidate.GetUnitTypeCount(requirement.UnitType) < requirement.Count)
 				{
-					canAdd = false;
+					isValid = Validation.Failed;
 					break;
 				}
 			}
 
-			return canAdd;
+			return isValid;
 		}
 	}
 }
--- a/API/Objects/Requirement/UnitRequiresAtLeastNUnitsRequirement.cs	Sun Apr 03 19:40:42 2011 +0000
+++ b/API/Objects/Requirement/UnitRequiresAtLeastNUnitsRequirement.cs	Mon Apr 04 19:06:01 2011 +0000
@@ -23,7 +23,7 @@
 		/// Checks whether the supplied WarFoundryObject can be added to the supplied army.
 		/// </summary>
 		/// <returns>
-		/// <c>true</c> if the object can be added, else <c>false</c>
+		/// A <code>Validation</code> enum to show the result of the validation
 		/// </returns>
 		/// <param name='wfObject'>
 		/// The object that we want to add. This may be involved in the check, or it may not affect the evaluation of the requirement
@@ -31,9 +31,9 @@
 		/// <param name='toArmy'>
 		/// The army to add the object to.
 		/// </param>
-		public override bool AllowsAdding(WarFoundryObject wfObject, Army toArmy)
+		public override Validation AllowsAdding(WarFoundryObject wfObject, Army toArmy)
 		{
-			return IsApplicable(wfObject, toArmy) ? base.ValidatesArmy(toArmy) : true;
+			return IsApplicable(wfObject, toArmy) ? base.ValidatesArmy(toArmy) : Validation.NotApplicable;
 		}
 
 
@@ -55,9 +55,9 @@
 		}
 
 
-		public override bool ValidatesArmy(Army toArmy)
+		public override Validation ValidatesArmy(Army toArmy)
 		{
-			return IsApplicable(toArmy) ? base.ValidatesArmy(toArmy) : true;
+			return IsApplicable(toArmy) ? base.ValidatesArmy(toArmy) : Validation.NotApplicable;
 		}
 	}
 }