diff api/Objects/UnitEquipmentNumericSelection.cs @ 96:ced5a18d9f52

Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts * Rework Unit's internals on how it stores equipment selection amounts * Fix logic error in "IsValidValue()" for absolute equipment selections * Fix calculation error when using "equip all" for absolute equipment selections * Make abstract equipment selection object set amount taken using property to trigger value checking Also: * Line ending cleanup in UnitEquipmentItem
author IBBoard <dev@ibboard.co.uk>
date Sun, 09 Aug 2009 11:09:12 +0000
parents 6c6cfe5594fc
children 95746083d037
line wrap: on
line diff
--- a/api/Objects/UnitEquipmentNumericSelection.cs	Sun Aug 09 10:34:09 2009 +0000
+++ b/api/Objects/UnitEquipmentNumericSelection.cs	Sun Aug 09 11:09:12 2009 +0000
@@ -20,13 +20,18 @@
 		{
 			get
 			{
-				return AmountTaken * EquipmentItem.Cost;
+				return CalculateAmount() * EquipmentItem.Cost;
 			}
 		}
+					
+		private double CalculateAmount()
+		{
+			return (AmountTaken == WarFoundryCore.INFINITY ? EquipmentForUnit.Size : AmountTaken);
+		}
 		
 		protected override bool IsValidValue (double newValue)
 		{
-			return newValue = Math.Round(newValue);
+			return newValue == Math.Round(newValue);
 		}
 	}
 }