changeset 327:1c32b8a1600e

Re #27: Define unit requirements * Add checking for passing requirements
author IBBoard <dev@ibboard.co.uk>
date Sat, 26 Mar 2011 21:02:55 +0000
parents 331995582990
children f8471453c3cb
files api/Objects/UnitRequiresAtLeastNUnitsRequirement.cs
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/api/Objects/UnitRequiresAtLeastNUnitsRequirement.cs	Sat Mar 26 17:03:00 2011 +0000
+++ b/api/Objects/UnitRequiresAtLeastNUnitsRequirement.cs	Sat Mar 26 21:02:55 2011 +0000
@@ -21,7 +21,18 @@
 
 		public bool CanAddToArmy(Unit unit, Army army)
 		{
-			return false;
+			bool canAdd = true;
+
+			foreach (UnitType type in requiredTypes)
+			{
+				if (army.GetUnitTypeCount(type) < 1)
+				{
+					canAdd = false;
+					break;
+				}
+			}
+
+			return canAdd;
 		}
 	}
 }