Mercurial > repos > IBBoard.WarFoundry.API
changeset 185:3577bfb7702b
Re #198: Add equipment slots
* Add GetMinEquipmentAmount method
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 27 Oct 2009 20:17:40 +0000 |
parents | cedf8bba1d52 |
children | c8682d206a73 |
files | api/Util/UnitEquipmentUtil.cs |
diffstat | 1 files changed, 16 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/api/Util/UnitEquipmentUtil.cs Tue Oct 27 20:09:40 2009 +0000 +++ b/api/Util/UnitEquipmentUtil.cs Tue Oct 27 20:17:40 2009 +0000 @@ -102,16 +102,28 @@ public static int GetMaxEquipmentCount (Unit unit, UnitEquipmentItem equip) { - int max = equip.MaxLimit.GetLimit(unit.Size); - AbstractLimit limit = unit.UnitType.GetEquipmentSlotLimit(equip.SlotName); + return GetEquipmentCountLimit (unit, equip); + } + + private static int GetEquipmentCountLimit (Unit unit, UnitEquipmentItem equip) + { + int unitSize = unit.Size; + int max = Math.Min (equip.MinLimit.GetLimit (unitSize), equip.MaxLimit.GetLimit (unitSize)); + AbstractLimit limit = unit.UnitType.GetEquipmentSlotLimit (equip.SlotName); if (!(limit is UnlimitedLimit)) { - int slotMax = limit.GetLimit(unit.Size) - unit.GetEquipmentAmountInSlot(equip.SlotName); - max = Math.Min(slotMax, max); + int slotMax = limit.GetLimit (unitSize) - unit.GetEquipmentAmountInSlot (equip.SlotName); + max = Math.Min (slotMax, max); } return max; } + + + public static int GetMinEquipmentCount (Unit unit, UnitEquipmentItem equip) + { + return GetEquipmentCountLimit (unit, equip); + } } }