Mercurial > repos > snowblizz-super-API-ideas
comparison api/Objects/AbstractUnitEquipmentItemSelection.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 (AbstractUnitEquipmentItemSelection.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 /// <summary> | |
10 /// An abstract class that defines a selection of equipment for a unit | |
11 /// </summary> | |
12 public abstract class AbstractUnitEquipmentItemSelection | |
13 { | |
14 private Unit selectionForUnit; | |
15 private UnitEquipmentItem selectedItem; | |
16 private double amountTaken; | |
17 | |
18 public AbstractUnitEquipmentItemSelection(Unit unit, UnitEquipmentItem item, double amount) | |
19 { | |
20 selectionForUnit = unit; | |
21 selectedItem = item; | |
22 amountTaken = amount; | |
23 } | |
24 | |
25 public Unit EquipmentForUnit | |
26 { | |
27 get | |
28 { | |
29 return selectionForUnit; | |
30 } | |
31 } | |
32 | |
33 public UnitEquipmentItem EquipmentItem | |
34 { | |
35 get | |
36 { | |
37 return selectedItem; | |
38 } | |
39 } | |
40 | |
41 public abstract double TotalCost | |
42 { | |
43 get; | |
44 } | |
45 | |
46 public double AmountTaken | |
47 { | |
48 get | |
49 { | |
50 return amountTaken; | |
51 } | |
52 set | |
53 { | |
54 if (IsValidValue(value)) | |
55 { | |
56 amountTaken = value; | |
57 } | |
58 else | |
59 { | |
60 //Fire validation failed event (once we have one) | |
61 } | |
62 } | |
63 } | |
64 | |
65 protected abstract bool IsValidValue(double newValue); | |
66 } | |
67 } |