diff api/Requirements/UnitExcludesRequirement.cs @ 0:520818033bb6

Initial commit of WarFoundry code
author IBBoard <dev@ibboard.co.uk>
date Fri, 19 Dec 2008 15:57:51 +0000
parents
children 306558904c2a
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/api/Requirements/UnitExcludesRequirement.cs	Fri Dec 19 15:57:51 2008 +0000
@@ -0,0 +1,49 @@
+using System;
+using System.Collections.Generic;
+using IBBoard.WarFoundry.API.Objects;
+
+namespace IBBoard.WarFoundry.API.Requirements
+{
+	/// <summary>
+	/// Summary description for UnitExcludesRequirement.
+	/// </summary>
+	public class UnitExcludesRequirement : UnitRequirement
+	{
+		private UnitRequirementItem[] excludingTypes;
+
+		public UnitExcludesRequirement(UnitType type, UnitRequirementItem[] excludingUnitTypes) : base(type)
+		{
+			excludingTypes = excludingUnitTypes;
+		}
+
+		public override string Description
+		{
+			get 
+			{
+				return "Some units are already included that excluded this unit";
+			}
+		}
+
+		protected override AbstractFailedRequirement CanAddToArmy(Army army, UnitType type)
+		{		
+			FailedUnitRequirement failed = null;
+
+			for (int i = 0; i<excludingTypes.Length; i++)
+			{
+				if (army.GetUnitTypeCount(excludingTypes[i].UnitType) > 0)
+				{
+					failed = new FailedUnitRequirement(this);
+					break;
+				}
+			}
+			
+			return failed;
+		}
+
+		protected override AbstractFailedRequirement CanRemoveFromArmy(Army army, UnitType type)
+		{
+			return null;
+		}
+
+	}
+}