comparison api/Objects/UnitEquipmentNumericSelection.cs @ 95:6c6cfe5594fc

Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts * Create new "equipment selection" objects to track equipment selection amounts and cost * Create ratio version * Creat absolute amount version
author IBBoard <dev@ibboard.co.uk>
date Sun, 09 Aug 2009 10:34:09 +0000
parents
children ced5a18d9f52
comparison
equal deleted inserted replaced
94:49a83020174e 95:6c6cfe5594fc
1 // This file (UnitEquipmentNumericSelection.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard
2 //
3 // 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.
4
5 using System;
6
7 namespace IBBoard.WarFoundry.API.Objects
8 {
9 public class UnitEquipmentNumericSelection : AbstractUnitEquipmentItemSelection
10 {
11 public UnitEquipmentNumericSelection(Unit unit, UnitEquipmentItem item, double amount) : base(unit, item, amount)
12 {
13 }
14
15 public UnitEquipmentNumericSelection(Unit unit, UnitEquipmentItem item) : base(unit, item, item.MinNumber)
16 {
17 }
18
19 public override double TotalCost
20 {
21 get
22 {
23 return AmountTaken * EquipmentItem.Cost;
24 }
25 }
26
27 protected override bool IsValidValue (double newValue)
28 {
29 return newValue = Math.Round(newValue);
30 }
31 }
32 }