changeset 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 a37cdcbcad14
children f58051572ec7
files api/Objects/UnitEquipmentNumericForRatioSelection.cs
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line diff
     1.1 --- a/api/Objects/UnitEquipmentNumericForRatioSelection.cs	Fri Sep 04 18:43:52 2009 +0000
     1.2 +++ b/api/Objects/UnitEquipmentNumericForRatioSelection.cs	Tue Sep 08 19:27:51 2009 +0000
     1.3 @@ -23,10 +23,10 @@
     1.4  		
     1.5  		protected override bool IsInRange (double newValue)
     1.6  		{
     1.7 -			int minLimit = (int) IBBMath.Round(EquipmentForUnit.Size * EquipmentItem.MinPercentage, EquipmentItem.RoundNumberUp);
     1.8 -			int maxLimit = (int) IBBMath.Round(EquipmentForUnit.Size * EquipmentItem.MaxPercentage, EquipmentItem.RoundNumberUp);
     1.9 +			int minLimit = (int) IBBMath.Round(EquipmentForUnit.Size * EquipmentItem.MinPercentage / 100, EquipmentItem.RoundNumberUp);
    1.10 +			int maxLimit = (int)IBBMath.Round(EquipmentForUnit.Size * EquipmentItem.MaxPercentage / 100, EquipmentItem.RoundNumberUp);
    1.11 +			newValue = (newValue == WarFoundryCore.INFINITY ? EquipmentForUnit.Size : newValue);
    1.12  			bool isInRange = (minLimit <= newValue) && (newValue <= maxLimit);
    1.13 -			newValue = (newValue == WarFoundryCore.INFINITY ? EquipmentForUnit.Size : newValue);
    1.14  			return isInRange && IsWholeNumber(newValue);
    1.15  		}
    1.16  	}