Mercurial > repos > IBDev-IBBoard.WarFoundry.API
view 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 source
// This file (UnitEquipmentNumericSelection.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard // // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license. using System; namespace IBBoard.WarFoundry.API.Objects { public class UnitEquipmentNumericSelection : AbstractUnitEquipmentItemSelection { public UnitEquipmentNumericSelection(Unit unit, UnitEquipmentItem item, double amount) : base(unit, item, amount) { } public UnitEquipmentNumericSelection(Unit unit, UnitEquipmentItem item) : base(unit, item, item.MinNumber) { } public override double TotalCost { get { 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); } } }