diff api/Objects/UnitType.cs @ 64:2094bd0ba652

Re #61 - Complete structure of WarFoundry API objects * Make Unit work with EquipmentItem objects as it doesn't need to know about the limits * Add methods to UnitType to check limits on an EquipmentItem Also: * Remove some unnecessary casting now that we're using genericed lists
author IBBoard <dev@ibboard.co.uk>
date Thu, 09 Apr 2009 15:36:22 +0000
parents 3c77722a02b5
children d100ca4bd0c1
line wrap: on
line diff
--- a/api/Objects/UnitType.cs	Thu Apr 09 15:05:38 2009 +0000
+++ b/api/Objects/UnitType.cs	Thu Apr 09 15:36:22 2009 +0000
@@ -244,6 +244,20 @@
 			UnitEquipmentItem equipItem = null;
 			equipment.TryGetValue(id, out equipItem);
 			return equipItem;
+		}
+		
+		/// <summary>
+		/// Gets a <see cref=" UnitEquipmentItem"/> for the given <see cref=" EquipmentItem"/>, or <code>null</code> if the unit can't take that <code>EquipmentItem</code>
+		/// </summary>
+		/// <param name="item">
+		/// The <see cref="EquipmentItem"/> to get the <see cref=" UnitEquipmentItem"/>
+		/// </param>
+		/// <returns>
+		/// The <see cref="UnitEquipmentItem"/> that definies the UnitType's restrictions for taking the <see cref=" EquipmentItem"/>
+		/// </returns>
+		public UnitEquipmentItem GetEquipmentItem(EquipmentItem item)
+		{
+			return GetEquipmentItem(item.ID);
 		}
 
 		/// <summary>
@@ -272,6 +286,18 @@
 			}
 		}
 		
+		public bool IsRatioLimitedEquipmentItem(EquipmentItem item)
+		{
+			UnitEquipmentItem equip = GetEquipmentItem(item);
+			return equip != null && equip.IsRatioLimit;
+		}
+		
+		public bool IsAbsoluteLimitedEquipmentItem(EquipmentItem item)
+		{
+			UnitEquipmentItem equip = GetEquipmentItem(item);
+			return equip != null && !equip.IsRatioLimit;
+		}
+		
 		public ICollection<Ability> GetRequiredAbilities()
 		{
 			return requiredAbilities.Values;