annotate api/Objects/UnitEquipmentItem.cs @ 211:1f39e325deee

Fixes #219: Units can only have one contained type * Commit Snowblizz's schema fix that makes the contained unit type list "unbounded"
author IBBoard <dev@ibboard.co.uk>
date Sat, 21 Nov 2009 11:50:48 +0000
parents 3ef067225dc3
children 7933d852181e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
104
2f3cafb69799 Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents: 101
diff changeset
1 // This file (UnitEquipmentItem.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2007, 2008, 2009 IBBoard.
15
306558904c2a Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
2 //
104
2f3cafb69799 Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents: 101
diff changeset
3 // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
15
306558904c2a Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
4
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
5 using System;
171
85dc413279a4 * Change imports to stop references to deprecated code
IBBoard <dev@ibboard.co.uk>
parents: 170
diff changeset
6 using IBBoard.CustomMath;
183
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 173
diff changeset
7 using IBBoard.Limits;
161
81abc04b3dbe Re #192: Improve "clean coding" practice
IBBoard <dev@ibboard.co.uk>
parents: 157
diff changeset
8 using IBBoard.WarFoundry.API.Util;
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
9
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
10 namespace IBBoard.WarFoundry.API.Objects
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
11 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
12 /// <summary>
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
13 /// Summary description for UnitEquipmentItem.
170
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
14 /// </summary>
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
15 public class UnitEquipmentItem : WarFoundryObject
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
16 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
17 private EquipmentItem item;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
18 private bool required;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
19 private bool roundUp;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
20 private double costMultiplier;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
21 private RoundType roundType;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
22 private string[] mutexGroups;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
23 private UnitType unitType;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
24 private string slotName = "";
183
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 173
diff changeset
25 private AbstractLimit minLimit;
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 173
diff changeset
26 private AbstractLimit maxLimit;
170
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
27
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
28 public UnitEquipmentItem(EquipmentItem equipmentItem, UnitType equipmentFor)
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
29 : this(equipmentItem, equipmentFor, new string[0])
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
30 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
31 //Do nothing extra
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
32 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
33
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
34 public UnitEquipmentItem(EquipmentItem equipmentItem, UnitType equipmentFor, params string[] mutexGroups)
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
35 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
36 item = equipmentItem;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
37 unitType = equipmentFor;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
38 this.mutexGroups = mutexGroups;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
39 unitType.AddEquipmentItem(this);
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
40 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
41
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
42 public override string Name
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
43 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
44 get
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
45 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
46 return item.Name;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
47 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
48 set
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
49 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
50 base.Name = value;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
51 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
52 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
53
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
54 public override string ID
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
55 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
56 get
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
57 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
58 return (EquipmentForUnit == null ? base.ID : EquipmentForUnit.ID) + EquipmentItemID;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
59 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
60 set
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
61 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
62 base.ID = value;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
63 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
64 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
65
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
66
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
67 public string EquipmentItemID
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
68 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
69 get { return item.ID; }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
70 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
71
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
72 public double Cost
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
73 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
74 get
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
75 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
76 return IBBMath.Round(EquipmentItem.Cost * CostMultiplier, CostRoundType);
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
77 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
78 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
79
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
80 public double CostMultiplier
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
81 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
82 get { return costMultiplier; }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
83 set
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
84 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
85 costMultiplier = value;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
86 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
87 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
88
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
89 public RoundType CostRoundType
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
90 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
91 get { return roundType; }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
92 set
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
93 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
94 roundType = value;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
95 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
96 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
97
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
98 public bool IsRequired
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
99 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
100 get { return required; }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
101 set { required = value; }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
102 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
103
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
104 public bool RoundNumberUp
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
105 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
106 get { return roundUp; }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
107 set { roundUp = value; }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
108 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
109
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
110 [Obsolete("Use MutexGroups instead for greater flexibility")]
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
111 public string MutexGroup
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
112 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
113 get { return (mutexGroups.Length == 0 ? "" : mutexGroups[0]); }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
114 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
115
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
116 public String[] MutexGroups
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
117 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
118 get { return (string[]) mutexGroups.Clone(); }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
119 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
120
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
121 public UnitType EquipmentForUnit
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
122 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
123 get { return unitType; }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
124 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
125
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
126 public bool IsRatioLimit
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
127 {
183
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 173
diff changeset
128 get { return MinLimit is IPercentageLimit && MaxLimit is IPercentageLimit; }
170
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
129 }
183
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 173
diff changeset
130
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 173
diff changeset
131 /// <summary>
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 173
diff changeset
132 /// Gets the Limit object for the minimum number of items that can be taken
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 173
diff changeset
133 /// </summary>
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 173
diff changeset
134 public AbstractLimit MinLimit
170
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
135 {
183
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 173
diff changeset
136 get
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 173
diff changeset
137 {
184
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
138 AbstractLimit limit = minLimit;
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
139
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
140 if (limit == null)
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
141 {
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
142 if (maxLimit != null)
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
143 {
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
144 limit = maxLimit;
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
145 }
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
146 else
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
147 {
193
12aa4b76d24e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 184
diff changeset
148 limit = new SimpleRoundedPercentageLimit(100, false);
184
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
149 }
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
150 }
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
151
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
152 return limit;
183
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 173
diff changeset
153 }
170
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
154 set
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
155 {
183
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 173
diff changeset
156 if (value != null)
170
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
157 {
184
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
158 minLimit = value;
170
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
159 }
172
f364a9e5463e Fixes #195: Setting max equipment without min may not function correctly
IBBoard <dev@ibboard.co.uk>
parents: 171
diff changeset
160 }
f364a9e5463e Fixes #195: Setting max equipment without min may not function correctly
IBBoard <dev@ibboard.co.uk>
parents: 171
diff changeset
161 }
f364a9e5463e Fixes #195: Setting max equipment without min may not function correctly
IBBoard <dev@ibboard.co.uk>
parents: 171
diff changeset
162
183
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 173
diff changeset
163 /// <summary>
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 173
diff changeset
164 /// Gets the Limit object for the maximum number of items that can be taken
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 173
diff changeset
165 /// </summary>
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 173
diff changeset
166 public AbstractLimit MaxLimit
172
f364a9e5463e Fixes #195: Setting max equipment without min may not function correctly
IBBoard <dev@ibboard.co.uk>
parents: 171
diff changeset
167 {
183
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 173
diff changeset
168 get
170
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
169 {
184
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
170 AbstractLimit limit = maxLimit;
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
171
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
172 if (limit == null)
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
173 {
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
174 if (minLimit != null)
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
175 {
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
176 limit = minLimit;
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
177 }
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
178 else
204
3ef067225dc3 Fixes #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents: 193
diff changeset
179 {
193
12aa4b76d24e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 184
diff changeset
180 limit = new SimpleRoundedPercentageLimit(100, false);
184
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
181 }
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
182 }
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
183
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
184 return limit;
172
f364a9e5463e Fixes #195: Setting max equipment without min may not function correctly
IBBoard <dev@ibboard.co.uk>
parents: 171
diff changeset
185 }
170
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
186 set
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
187 {
183
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 173
diff changeset
188 if (value != null)
170
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
189 {
184
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
190 maxLimit = value;
170
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
191 }
172
f364a9e5463e Fixes #195: Setting max equipment without min may not function correctly
IBBoard <dev@ibboard.co.uk>
parents: 171
diff changeset
192 }
f364a9e5463e Fixes #195: Setting max equipment without min may not function correctly
IBBoard <dev@ibboard.co.uk>
parents: 171
diff changeset
193 }
170
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
194
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
195 public EquipmentItem EquipmentItem
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
196 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
197 get { return item; }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
198 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
199
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
200 public override string ToString()
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
201 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
202 return EquipmentItem.Name + " (" + Cost + "pts each)";
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
203 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
204
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
205 public bool HasAlternatives()
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
206 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
207 if (MutexGroups.Length == 0)
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
208 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
209 return false;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
210 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
211 else if (EquipmentForUnit == null)
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
212 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
213 return false;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
214 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
215 else
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
216 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
217 //If the number of items in the MutEx group is greater than one then it must be this item plus another
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
218 return EquipmentForUnit.GetEquipmentItemsByExclusionGroups(MutexGroups).Length > 1;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
219 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
220 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
221
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
222 public ArmourType ItemArmourType
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
223 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
224 get { return EquipmentItem.ItemArmourType; }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
225 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
226
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
227 public string Description
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
228 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
229 get { return EquipmentItem.Description; }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
230 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
231
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
232 public Race EquipmentForRace
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
233 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
234 get { return EquipmentItem.EquipmentForRace; }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
235 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
236
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
237 public bool CanBeUsedWithItem(EquipmentItem item)
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
238 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
239 return EquipmentItem.CanBeUsedWithItem(item);
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
240 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
241
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
242 public bool CanBeUsedWithArmourType(ArmourType otherItemType)
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
243 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
244 return EquipmentItem.CanBeUsedWithArmourType(otherItemType);
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
245 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
246
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
247 [Obsolete("Use UnitEquipmentUtil method instead")]
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
248 public bool IsMutuallyExclusive(UnitEquipmentItem item)
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
249 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
250 return UnitEquipmentUtil.ItemsAreMutuallyExclusive(this, item);
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
251 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
252
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
253 public string SlotName
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
254 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
255 get { return slotName; }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
256 set
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
257 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
258 if (value != null && value != "")
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
259 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
260 slotName = value;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
261 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
262 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
263 }
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
264 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
265 }