Mercurial > repos > snowblizz-super-API-ideas
annotate api/Objects/UnitEquipmentItem.cs @ 92:729d9e54162c
Re #111: "Replace" button doesn't always enable
* Implement better fix:
* Make UnitEquipmentItem ID based on unit type ID and equipment item ID
* Make UnitEquipmentItem require UnitType at construction again
* Remove setter from EquipmentItemForUnit
* Make AddEquipmentItem method internal so that the UnitEquipmentItem and not the factory is responsible for setting up the reverse link
no-open-ticket
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Fri, 07 Aug 2009 19:49:21 +0000 |
parents | 46ad6f478203 |
children | 49a83020174e |
rev | line source |
---|---|
15 | 1 // This file (UnitEquipmentItem.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 | |
82 | 5 using System; |
79
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
6 using System.Xml; |
82 | 7 using IBBoard.Lang; |
8 | |
9 namespace IBBoard.WarFoundry.API.Objects | |
10 { | |
11 /// <summary> | |
12 /// Summary description for UnitEquipmentItem. | |
13 /// </summary> | |
14 public class UnitEquipmentItem : WarFoundryObject | |
54
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
15 { |
82 | 16 private EquipmentItem item; |
54
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
17 private bool required; |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
18 private bool roundUp; |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
19 private int minNum; |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
20 private int maxNum; |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
21 private double minPercentage; |
79
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
22 private double maxPercentage; |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
23 private double costMultiplier; |
82 | 24 private RoundType roundType; |
25 private string mutexGroup; | |
26 private UnitType unitType; | |
54
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
27 |
92
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
28 public UnitEquipmentItem(EquipmentItem equipmentItem, UnitType equipmentFor) |
54
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
29 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
30 item = equipmentItem; |
92
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
31 unitType = equipmentFor; |
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
32 unitType.AddEquipmentItem(this); |
54
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
33 } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
34 |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
35 public override string Name |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
36 { |
92
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
37 get |
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
38 { |
54
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
39 return item.Name; |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
40 } |
92
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
41 set |
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
42 { |
54
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
43 base.Name = value; |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
44 } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
45 } |
92
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
46 |
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
47 public override string ID { |
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
48 get |
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
49 { |
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
50 return (EquipmentForUnit == null ? base.ID : EquipmentForUnit.ID) + EquipmentItemID; |
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
51 } |
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
52 set |
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
53 { |
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
54 base.ID = value; |
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
55 } |
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
56 } |
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
57 |
54
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
58 |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
59 public string EquipmentItemID |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
60 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
61 get { return item.ID; } |
82 | 62 } |
63 | |
64 public double Cost | |
65 { | |
79
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
66 get |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
67 { |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
68 return IBBMath.Round(EquipmentItem.Cost * CostMultiplier, CostRoundType); |
82 | 69 } |
79
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
70 } |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
71 |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
72 public double CostMultiplier |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
73 { |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
74 get { return costMultiplier; } |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
75 set |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
76 { |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
77 costMultiplier = value; |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
78 } |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
79 } |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
80 |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
81 public RoundType CostRoundType |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
82 { |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
83 get { return roundType; } |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
84 set |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
85 { |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
86 roundType = value; |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
87 } |
82 | 88 } |
89 | |
90 public bool IsRequired | |
91 { | |
92 get { return required; } | |
93 set { required = value; } | |
94 } | |
95 | |
96 public bool RoundNumberUp | |
97 { | |
98 get { return roundUp; } | |
99 set { roundUp = value; } | |
100 } | |
101 | |
102 public string MutexGroup | |
103 { | |
104 get { return mutexGroup; } | |
105 set { mutexGroup = (value == null ? "" : value.Trim()); } | |
106 } | |
107 | |
108 public UnitType EquipmentForUnit | |
109 { | |
110 get { return unitType; } | |
54
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
111 } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
112 |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
113 public bool IsRatioLimit |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
114 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
115 get { return minPercentage!=100 || maxPercentage!=100; } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
116 } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
117 |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
118 public int MinNumber |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
119 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
120 get { return minNum; } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
121 set |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
122 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
123 if (value >=0 || value == WarFoundryCore.INFINITY) |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
124 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
125 minNum = value; |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
126 } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
127 //TODO: Check Min<Max |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
128 } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
129 } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
130 |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
131 public int MaxNumber |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
132 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
133 get { return maxNum; } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
134 set |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
135 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
136 if (value >=0 || value == WarFoundryCore.INFINITY) |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
137 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
138 maxNum = value; |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
139 } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
140 //TODO: Check Min<Max |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
141 } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
142 } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
143 |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
144 public double MinPercentage |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
145 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
146 get { return minPercentage; } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
147 set |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
148 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
149 if (value >=0 && value <= 100) |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
150 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
151 minPercentage = value; |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
152 } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
153 //TODO: Check Min<Max |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
154 } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
155 } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
156 |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
157 public double MaxPercentage |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
158 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
159 get { return maxPercentage; } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
160 set |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
161 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
162 if (value >=0 && value <= 100) |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
163 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
164 maxPercentage = value; |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
165 } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
166 //TODO: Check Min<Max |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
167 } |
82 | 168 } |
169 | |
170 public EquipmentItem EquipmentItem | |
171 { | |
172 get { return item; } | |
173 } | |
174 | |
175 public override string ToString() | |
176 { | |
177 return EquipmentItem.Name+ " ("+EquipmentItem.Cost+"pts each)"; | |
178 } | |
179 | |
180 public bool HasAlternatives() | |
181 { | |
182 if (MutexGroup=="") | |
183 { | |
184 return false; | |
185 } | |
85
46ad6f478203
Re #50: Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
186 else if (EquipmentForUnit == null) |
46ad6f478203
Re #50: Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
187 { |
46ad6f478203
Re #50: Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
188 return false; |
46ad6f478203
Re #50: Complete core loading of WarFoundry XML files
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
189 } |
82 | 190 else |
191 { | |
192 //If the number of items in the MutEx group is greater than one then it must be this item plus another | |
193 return EquipmentForUnit.GetEquipmentItemsByExclusionGroup(MutexGroup).Length > 1; | |
194 } | |
54
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
195 } |
79
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
196 |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
197 public ArmourType ItemArmourType |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
198 { |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
199 get { return EquipmentItem.ItemArmourType; } |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
200 } |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
201 |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
202 public string Description |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
203 { |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
204 get { return EquipmentItem.Description; } |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
205 } |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
206 |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
207 public Race EquipmentForRace |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
208 { |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
209 get { return EquipmentItem.EquipmentForRace; } |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
210 } |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
211 |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
212 public bool CanBeUsedWithItem(EquipmentItem item) |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
213 { |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
214 return EquipmentItem.CanBeUsedWithItem(item); |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
215 } |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
216 |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
217 public bool CanBeUsedWithArmourType(ArmourType otherItemType) |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
218 { |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
219 return EquipmentItem.CanBeUsedWithArmourType(otherItemType); |
284ebe05158c
Re #61 - Complete structure of API objects
IBBoard <dev@ibboard.co.uk>
parents:
54
diff
changeset
|
220 } |
54
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
221 |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
222 public static string FormatEquipmentAmount(UnitEquipmentItem item, double amount) |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
223 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
224 if (item.IsRatioLimit) |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
225 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
226 return Math.Round(amount * 100) + "%"; |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
227 } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
228 else |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
229 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
230 if (amount == WarFoundryCore.INFINITY) |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
231 { |
92
729d9e54162c
Re #111: "Replace" button doesn't always enable
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
232 return "all"; //TODO: Translate |
54
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
233 } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
234 else |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
235 { |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
236 return amount.ToString(); |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
237 } |
3a90f70dac73
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
238 } |
82 | 239 } |
240 } | |
241 } |