Mercurial > repos > IBDev-IBBoard.WarFoundry.API
diff api/Objects/Unit.cs @ 183:36adabb1c3ea
Re #198: Add slots with counts to units
* Remove old Min/MaxNumber/Percentage for equipment and replace with limits
* Refactor equipment selections and remove "numeric for ratio" as the limits handle the upper/lower limit differences
* Stop equipment selections taking an amount of 0 for out of range amounts
* Add "IsValid" property for selections
* Removed use of "-1" as an 'infinity' limit - now use 100% as a more correct value
* Change "unlimitedSize" limit in schema to "unitSizeLimit"
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 26 Oct 2009 20:55:04 +0000 |
parents | 55dc7c97fcfe |
children | ec1cfe3ef94e |
line wrap: on
line diff
--- a/api/Objects/Unit.cs Sat Oct 24 18:59:04 2009 +0000 +++ b/api/Objects/Unit.cs Mon Oct 26 20:55:04 2009 +0000 @@ -7,6 +7,7 @@ using System.Text; using System.Xml; using IBBoard.Lang; +using IBBoard.Limits; using IBBoard.WarFoundry.API.Util; namespace IBBoard.WarFoundry.API.Objects @@ -87,13 +88,15 @@ { if (CanEquipWithItem(unitEquip)) { - if (unitEquip.IsRatioLimit) + AbstractLimit minLimit = unitEquip.MinLimit; + + if (minLimit is IPercentageLimit) { - SetEquipmentRatio(unitEquip, unitEquip.MinPercentage); + SetEquipmentRatio(unitEquip, ((IPercentageLimit)minLimit).Percentage); } else { - SetEquipmentAmount(unitEquip, unitEquip.MinNumber); + SetEquipmentAmount(unitEquip, minLimit.GetLimit(this.Size)); } } } @@ -348,17 +351,7 @@ private void AddEquipmentAmount(UnitEquipmentItem equip, int amount) { - AbstractUnitEquipmentItemSelection newItem = null; - - if (equip.IsRatioLimit) - { - newItem = new UnitEquipmentNumericForRatioSelection(this, equip, amount); - } - else - { - newItem = new UnitEquipmentNumericSelection(this, equip, amount); - } - + AbstractUnitEquipmentItemSelection newItem = new UnitEquipmentNumericSelection(this, equip, amount); equipment[equip] = newItem; List<AbstractUnitEquipmentItemSelection> selections = DictionaryUtils.GetValue(equipmentSlots, equip.SlotName);