diff API/Objects/Requirement/UnitRequiresAtLeastNUnitsRequirement.cs @ 479:f48c49b53738

Re #410: "N units per M models in parent" requirement * Add a "context" object that will hold the parent unit (or possibly other stuff) * Update all method signatures and calls
author IBBoard <dev@ibboard.co.uk>
date Wed, 23 May 2012 20:56:27 +0100
parents 680db2462e34
children e0641e0eb86c
line wrap: on
line diff
--- a/API/Objects/Requirement/UnitRequiresAtLeastNUnitsRequirement.cs	Wed May 23 20:37:23 2012 +0100
+++ b/API/Objects/Requirement/UnitRequiresAtLeastNUnitsRequirement.cs	Wed May 23 20:56:27 2012 +0100
@@ -16,17 +16,12 @@
 		{
 		}
 
-		public override Validation AllowsAdding(IWarFoundryObject wfObject, Army toArmy)
+		protected override bool IsApplicable(IWarFoundryObject toObject, Army toArmy, AddingContext context)
 		{
-			return IsApplicable(wfObject, toArmy) ? base.AllowsAdding(wfObject, toArmy) : Validation.NotApplicable;
+			return IsApplicable(toObject, context) || IsApplicableForRequiredType(toObject, toArmy);
 		}
 
-		protected override bool IsApplicable(IWarFoundryObject toObject, Army toArmy)
-		{
-			return IsApplicable(toObject) || IsApplicableForRequiredType(toObject, toArmy);
-		}
-
-		protected override bool IsApplicable(IWarFoundryObject toObject)
+		protected override bool IsApplicable(IWarFoundryObject toObject, AddingContext context)
 		{
 			return AllowedObject.Equals(toObject) || (toObject is Unit && AllowedObject.Equals(((Unit)toObject).UnitType));
 		}