diff api/Objects/UnitType.cs @ 167:9ba56a8e5096

Re #198: Add slots with counts to units * Add initial API methods * Add value loading
author IBBoard <dev@ibboard.co.uk>
date Tue, 06 Oct 2009 14:59:54 +0000
parents 4a02c07278e7
children 3045a168714a
line wrap: on
line diff
--- a/api/Objects/UnitType.cs	Tue Oct 06 14:47:06 2009 +0000
+++ b/api/Objects/UnitType.cs	Tue Oct 06 14:59:54 2009 +0000
@@ -29,8 +29,9 @@
 		private Dictionary<string, Ability> requiredAbilities = new Dictionary<string, Ability>();
 		private Dictionary<string, Ability> optionalAbilities = new Dictionary<string, Ability>();
 		private String notes = "";
-		private List<UnitType> containedTypes = new List<UnitType>();
-		private Dictionary<string, string> extraData = new Dictionary<string, string>();
+		private List<UnitType> containedTypes = new List<UnitType>();
+		private Dictionary<string, string> extraData = new Dictionary<string, string>();
+		private Dictionary<string, int> slotLimits = new Dictionary<string, int>();
 
 
 		public UnitType(string id, string typeName, Race parentRace) : base(id, typeName)
@@ -446,7 +447,34 @@
 			get
 			{
 				return stats.StatsID;
-			}
+			}
+		}
+
+		public void AddEquipmentSlot(string slotName, int slotLimit)
+		{
+			slotLimits.Add(slotName, slotLimit);
+		}
+
+		public bool HasEquipmentSlot(string slotName)
+		{
+			return slotLimits.ContainsKey(slotName);
+		}
+
+		/// <summary>
+		/// Gets the maximum number of items allowed in a single slot
+		/// </summary>
+		/// <param name="slotName">The name of the equipment slot to get the limit for the named slot</param>
+		/// <returns>The maximum number of items allowed in a slot, or <code>-1</code> if the slot is the default one or has not been specified</returns>
+		public int GetEquipmentSlotLimit(string slotName)
+		{
+			int slotLimit = -1;
+
+			if (HasEquipmentSlot(slotName))
+			{
+				slotLimit = DictionaryUtils.GetValue(slotLimits, slotName);
+			}
+
+			return slotLimit;
 		}
 	}
 }
\ No newline at end of file