Mercurial > repos > IBDev-IBBoard.WarFoundry.API
comparison api/Objects/UnitEquipmentItem.cs @ 79:284ebe05158c
Re #61 - Complete structure of API objects
* Add methods for new cost multiplier and rounding
* Reduce "train wreck" code by making some EquipmentItem properties visible on the UnitEquipmentItem
no-open-ticket
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 19 May 2009 14:40:10 +0000 |
parents | 3a90f70dac73 |
children | 3ea0ab04352b |
comparison
equal
deleted
inserted
replaced
78:f70c709dad8b | 79:284ebe05158c |
---|---|
2 // | 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. | 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 | 4 |
5 using System; | 5 using System; |
6 using System.Xml; | 6 using System.Xml; |
7 using IBBoard.Lang; | |
7 | 8 |
8 namespace IBBoard.WarFoundry.API.Objects | 9 namespace IBBoard.WarFoundry.API.Objects |
9 { | 10 { |
10 /// <summary> | 11 /// <summary> |
11 /// Summary description for UnitEquipmentItem. | 12 /// Summary description for UnitEquipmentItem. |
17 private bool roundUp; | 18 private bool roundUp; |
18 private int minNum; | 19 private int minNum; |
19 private int maxNum; | 20 private int maxNum; |
20 private double minPercentage; | 21 private double minPercentage; |
21 private double maxPercentage; | 22 private double maxPercentage; |
23 private double costMultiplier; | |
24 private RoundType roundType; | |
22 private string mutexGroup; | 25 private string mutexGroup; |
23 private UnitType unitType; | 26 private UnitType unitType; |
24 | 27 |
25 protected UnitEquipmentItem(EquipmentItem equipmentItem, UnitType equipForType) | 28 protected UnitEquipmentItem(EquipmentItem equipmentItem, UnitType equipForType) |
26 { | 29 { |
43 get { return item.ID; } | 46 get { return item.ID; } |
44 } | 47 } |
45 | 48 |
46 public double Cost | 49 public double Cost |
47 { | 50 { |
48 get { return item.Cost; } | 51 get |
52 { | |
53 return IBBMath.Round(EquipmentItem.Cost * CostMultiplier, CostRoundType); | |
54 } | |
49 } | 55 } |
56 | |
57 public double CostMultiplier | |
58 { | |
59 get { return costMultiplier; } | |
60 set | |
61 { | |
62 costMultiplier = value; | |
63 } | |
64 } | |
65 | |
66 public RoundType CostRoundType | |
67 { | |
68 get { return roundType; } | |
69 set | |
70 { | |
71 roundType = value; | |
72 } | |
73 } | |
50 | 74 |
51 public bool IsRequired | 75 public bool IsRequired |
52 { | 76 { |
53 get { return required; } | 77 get { return required; } |
54 set { required = value; } | 78 set { required = value; } |
155 { | 179 { |
156 //If the number of items in the MutEx group is greater than one then it must be this item plus another | 180 //If the number of items in the MutEx group is greater than one then it must be this item plus another |
157 return EquipmentForUnit.GetEquipmentItemsByExclusionGroup(MutexGroup).Length > 1; | 181 return EquipmentForUnit.GetEquipmentItemsByExclusionGroup(MutexGroup).Length > 1; |
158 } | 182 } |
159 } | 183 } |
184 | |
185 public ArmourType ItemArmourType | |
186 { | |
187 get { return EquipmentItem.ItemArmourType; } | |
188 } | |
189 | |
190 public string Description | |
191 { | |
192 get { return EquipmentItem.Description; } | |
193 } | |
194 | |
195 public Race EquipmentForRace | |
196 { | |
197 get { return EquipmentItem.EquipmentForRace; } | |
198 } | |
199 | |
200 public bool CanBeUsedWithItem(EquipmentItem item) | |
201 { | |
202 return EquipmentItem.CanBeUsedWithItem(item); | |
203 } | |
204 | |
205 public bool CanBeUsedWithArmourType(ArmourType otherItemType) | |
206 { | |
207 return EquipmentItem.CanBeUsedWithArmourType(otherItemType); | |
208 } | |
160 | 209 |
161 public static string FormatEquipmentAmount(UnitEquipmentItem item, double amount) | 210 public static string FormatEquipmentAmount(UnitEquipmentItem item, double amount) |
162 { | 211 { |
163 if (item.IsRatioLimit) | 212 if (item.IsRatioLimit) |
164 { | 213 { |