Mercurial > repos > IBBoard.WarFoundry.API
diff api/Util/UnitEquipmentUtil.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 | 6fe336109128 |
children | 3577bfb7702b |
line wrap: on
line diff
--- a/api/Util/UnitEquipmentUtil.cs Sat Oct 24 18:59:04 2009 +0000 +++ b/api/Util/UnitEquipmentUtil.cs Mon Oct 26 20:55:04 2009 +0000 @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Text; +using IBBoard.Limits; using IBBoard.WarFoundry.API.Objects; namespace IBBoard.WarFoundry.API.Util @@ -101,7 +102,16 @@ public static int GetMaxEquipmentCount (Unit unit, UnitEquipmentItem equip) { - return equip.MaxNumber; + int max = equip.MaxLimit.GetLimit(unit.Size); + 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); + } + + return max; } } }