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 wrap: on
line diff
--- a/api/Objects/UnitRequiresAtLeastNUnitsRequirement.cs	Sun Mar 27 19:09:27 2011 +0000
+++ b/api/Objects/UnitRequiresAtLeastNUnitsRequirement.cs	Sun Mar 27 19:15:31 2011 +0000
@@ -19,13 +19,25 @@
 			requiredTypes = new List<UnitType>(requiredUnitTypes);
 		}
 
-		public bool CanAddToArmy(WarFoundryObject unit, Army army)
+		/// <summary>
+		/// 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>
+		/// </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
+		/// </param>
+		/// <param name='toArmy'>
+		/// The army to add the object to.
+		/// </param>
+		public bool AllowsAdding(WarFoundryObject wfObject, Army toArmy)
 		{
 			bool canAdd = true;
 
 			foreach (UnitType type in requiredTypes)
 			{
-				if (army.GetUnitTypeCount(type) < 1)
+				if (toArmy.GetUnitTypeCount(type) < 1)
 				{
 					canAdd = false;
 					break;