comparison api/Objects/UnitEquipmentNumericForRatioSelection.cs @ 136:413a7a049e41

Fixes #146: Incorrect logic in Unit.AddEquipmentAmount() * Logic error was in UnitEquipmentNumericForRatioSelection where we didn't treat percentages as decimal numbers and got ranges of "125 to 500" for a unit of 5!
author IBBoard <dev@ibboard.co.uk>
date Tue, 08 Sep 2009 19:27:51 +0000
parents 2f3cafb69799
children 70808ff799e6
comparison
equal deleted inserted replaced
135:a37cdcbcad14 136:413a7a049e41
21 { 21 {
22 } 22 }
23 23
24 protected override bool IsInRange (double newValue) 24 protected override bool IsInRange (double newValue)
25 { 25 {
26 int minLimit = (int) IBBMath.Round(EquipmentForUnit.Size * EquipmentItem.MinPercentage, EquipmentItem.RoundNumberUp); 26 int minLimit = (int) IBBMath.Round(EquipmentForUnit.Size * EquipmentItem.MinPercentage / 100, EquipmentItem.RoundNumberUp);
27 int maxLimit = (int) IBBMath.Round(EquipmentForUnit.Size * EquipmentItem.MaxPercentage, EquipmentItem.RoundNumberUp); 27 int maxLimit = (int)IBBMath.Round(EquipmentForUnit.Size * EquipmentItem.MaxPercentage / 100, EquipmentItem.RoundNumberUp);
28 newValue = (newValue == WarFoundryCore.INFINITY ? EquipmentForUnit.Size : newValue);
28 bool isInRange = (minLimit <= newValue) && (newValue <= maxLimit); 29 bool isInRange = (minLimit <= newValue) && (newValue <= maxLimit);
29 newValue = (newValue == WarFoundryCore.INFINITY ? EquipmentForUnit.Size : newValue);
30 return isInRange && IsWholeNumber(newValue); 30 return isInRange && IsWholeNumber(newValue);
31 } 31 }
32 } 32 }
33 } 33 }