Mercurial > repos > IBDev-IBBoard.WarFoundry.API
diff api/Objects/UnitEquipmentRatioSelection.cs @ 214:1b718b67f7f6
Re #179: Make sure that translations are used throughout UI
* Fix locations in the API that are used in the front-end
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 21 Nov 2009 21:27:07 +0000 |
parents | dce340f9cedc |
children | ece26f6a62f3 |
line wrap: on
line diff
--- a/api/Objects/UnitEquipmentRatioSelection.cs Sat Nov 21 20:06:36 2009 +0000 +++ b/api/Objects/UnitEquipmentRatioSelection.cs Sat Nov 21 21:27:07 2009 +0000 @@ -27,12 +27,17 @@ { get { - double exactNumberTaken = (AmountTaken / 100) * EquipmentForUnit.Size; - int wholeNumberTaken = (int) IBBMath.Round(exactNumberTaken, EquipmentItem.RoundNumberUp); - int maxTaken = UnitEquipmentUtil.GetMaxEquipmentCount(EquipmentForUnit, EquipmentItem); - int minTaken = UnitEquipmentUtil.GetMinEquipmentCount(EquipmentForUnit, EquipmentItem); - return Math.Min(Math.Max(wholeNumberTaken, minTaken), maxTaken); + return CalculateNumberTaken (EquipmentForUnit, EquipmentItem, AmountTaken); } + } + + internal static int CalculateNumberTaken (Unit unit, UnitEquipmentItem item, double ratioTaken) + { + double exactNumberTaken = (ratioTaken / 100) * unit.Size; + int wholeNumberTaken = (int)IBBMath.Round (exactNumberTaken, item.RoundNumberUp); + int maxTaken = UnitEquipmentUtil.GetMaxEquipmentCount (unit, item); + int minTaken = UnitEquipmentUtil.GetMinEquipmentCount (unit, item); + return Math.Min (Math.Max (wholeNumberTaken, minTaken), maxTaken); } [Obsolete("Implementation is down to the UI")]