comparison 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
comparison
equal deleted inserted replaced
95:6c6cfe5594fc 96:ced5a18d9f52
18 18
19 public override double TotalCost 19 public override double TotalCost
20 { 20 {
21 get 21 get
22 { 22 {
23 return AmountTaken * EquipmentItem.Cost; 23 return CalculateAmount() * EquipmentItem.Cost;
24 } 24 }
25 }
26
27 private double CalculateAmount()
28 {
29 return (AmountTaken == WarFoundryCore.INFINITY ? EquipmentForUnit.Size : AmountTaken);
25 } 30 }
26 31
27 protected override bool IsValidValue (double newValue) 32 protected override bool IsValidValue (double newValue)
28 { 33 {
29 return newValue = Math.Round(newValue); 34 return newValue == Math.Round(newValue);
30 } 35 }
31 } 36 }
32 } 37 }