Mercurial > repos > IBDev-IBBoard.WarFoundry.API
diff api/Objects/UnitType.cs @ 176:22429737cd77
Re #198: Add slots with counts to units
* Migrate to using new Limit objects from ibboard:ticket:24
* Parse new objects
* Move more data type definitions in to Core schema for re-use
* Make UnitType just return limit objects
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Thu, 22 Oct 2009 19:51:42 +0000 |
parents | 3045a168714a |
children | 8c6f55d289b0 |
line wrap: on
line diff
--- a/api/Objects/UnitType.cs Wed Oct 21 19:01:13 2009 +0000 +++ b/api/Objects/UnitType.cs Thu Oct 22 19:51:42 2009 +0000 @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Xml; +using IBBoard.Limits; using IBBoard.Logging; using IBBoard.WarFoundry.API.Requirements; @@ -31,7 +32,7 @@ private String notes = ""; 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>(); + private Dictionary<string, AbstractLimit> slotLimits = new Dictionary<string, AbstractLimit>(); public UnitType(string id, string typeName, Race parentRace) : base(id, typeName) @@ -450,7 +451,7 @@ } } - public void AddEquipmentSlot(string slotName, int slotLimit) + public void AddEquipmentSlot(string slotName, AbstractLimit slotLimit) { slotLimits.Add(slotName, slotLimit); } @@ -461,18 +462,23 @@ } /// <summary> - /// Gets the maximum number of items allowed in a single slot + /// Gets the maximum limit on the 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) + /// <param name="slotName">The name of the equipment slot to get the limit for</param> + /// <returns>The limit of the number of items allowed in a slot, or an infinite limit if the slot is the default one or has not been specified</returns> + public AbstractLimit GetEquipmentSlotLimit(string slotName) { - int slotLimit = -1; + AbstractLimit slotLimit = null; if (HasEquipmentSlot(slotName)) { slotLimit = DictionaryUtils.GetValue(slotLimits, slotName); } + + if (slotLimit == null) + { + slotLimit = new UnlimitedLimit(); + } return slotLimit; }