annotate api/Objects/UnitEquipmentItem.cs @ 306:886d28c1b6e5

Re #99: Define points systems * Simplify the code and leave translations until we support them Re #329 and re #327: Use "points" in UI * Use new method in UnitEquipmentItem object's ToString() method
author IBBoard <dev@ibboard.co.uk>
date Sun, 13 Feb 2011 16:24:12 +0000
parents 92d10b06ab0f
children
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;
306
886d28c1b6e5 Re #99: Define points systems
IBBoard <dev@ibboard.co.uk>
parents: 305
diff changeset
8 using IBBoard.WarFoundry.API.Util;
886d28c1b6e5 Re #99: Define points systems
IBBoard <dev@ibboard.co.uk>
parents: 305
diff changeset
9 using IBBoard.Lang;
299
25c47b7ecc99 Re #99: added points name system to GameSystem
snowblizz
parents: 265
diff changeset
10 //using IBBoard.WarFoundry.API.Objects;
82
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 namespace IBBoard.WarFoundry.API.Objects
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
13 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
14 /// <summary>
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
15 /// Summary description for UnitEquipmentItem.
170
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
16 /// </summary>
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
17 public class UnitEquipmentItem : WarFoundryObject
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
18 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
19 private EquipmentItem item;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
20 private bool required;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
21 private bool roundUp;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
22 private double costMultiplier;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
23 private RoundType roundType;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
24 private string[] mutexGroups;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
25 private UnitType unitType;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
26 private string slotName = "";
265
6fe0cb1bf74f Re #279: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents: 263
diff changeset
27 private ILimit minLimit;
306
886d28c1b6e5 Re #99: Define points systems
IBBoard <dev@ibboard.co.uk>
parents: 305
diff changeset
28 private ILimit maxLimit;
170
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
29 public UnitEquipmentItem(EquipmentItem equipmentItem, UnitType equipmentFor)
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
30 : this(equipmentItem, equipmentFor, new string[0])
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
31 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
32 //Do nothing extra
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
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
35 public UnitEquipmentItem(EquipmentItem equipmentItem, UnitType equipmentFor, params string[] mutexGroups)
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
36 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
37 item = equipmentItem;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
38 unitType = equipmentFor;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
39 this.mutexGroups = mutexGroups;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
40 unitType.AddEquipmentItem(this);
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
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
43 public override string Name
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
44 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
45 get
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
46 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
47 return item.Name;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
48 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
49 set
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
50 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
51 base.Name = value;
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
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
55 public override string ID
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
56 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
57 get
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
58 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
59 return (EquipmentForUnit == null ? base.ID : EquipmentForUnit.ID) + EquipmentItemID;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
60 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
61 set
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
62 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
63 base.ID = value;
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 }
306
886d28c1b6e5 Re #99: Define points systems
IBBoard <dev@ibboard.co.uk>
parents: 305
diff changeset
109
886d28c1b6e5 Re #99: Define points systems
IBBoard <dev@ibboard.co.uk>
parents: 305
diff changeset
110 public GameSystem GameSystem
886d28c1b6e5 Re #99: Define points systems
IBBoard <dev@ibboard.co.uk>
parents: 305
diff changeset
111 {
886d28c1b6e5 Re #99: Define points systems
IBBoard <dev@ibboard.co.uk>
parents: 305
diff changeset
112 get { return EquipmentItem.GameSystem; }
886d28c1b6e5 Re #99: Define points systems
IBBoard <dev@ibboard.co.uk>
parents: 305
diff changeset
113 }
170
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 public String[] MutexGroups
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
116 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
117 get { return (string[]) mutexGroups.Clone(); }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
118 }
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 public UnitType EquipmentForUnit
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
121 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
122 get { return unitType; }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
123 }
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 public bool IsRatioLimit
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
126 {
183
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 173
diff changeset
127 get { return MinLimit is IPercentageLimit && MaxLimit is IPercentageLimit; }
170
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
128 }
183
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 173
diff changeset
129
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 173
diff changeset
130 /// <summary>
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 173
diff changeset
131 /// 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
132 /// </summary>
265
6fe0cb1bf74f Re #279: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents: 263
diff changeset
133 public ILimit MinLimit
170
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
134 {
183
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 173
diff changeset
135 get
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 173
diff changeset
136 {
265
6fe0cb1bf74f Re #279: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents: 263
diff changeset
137 ILimit limit = minLimit;
184
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
138
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
139 if (limit == null)
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
140 {
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
141 if (maxLimit != null)
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
142 {
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
143 limit = maxLimit;
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
144 }
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
145 else
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
146 {
193
12aa4b76d24e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 184
diff changeset
147 limit = new SimpleRoundedPercentageLimit(100, false);
184
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
148 }
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 return limit;
183
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 173
diff changeset
152 }
170
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
153 set
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
154 {
183
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 173
diff changeset
155 if (value != null)
170
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
156 {
184
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
157 minLimit = value;
170
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
158 }
172
f364a9e5463e Fixes #195: Setting max equipment without min may not function correctly
IBBoard <dev@ibboard.co.uk>
parents: 171
diff changeset
159 }
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
183
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 173
diff changeset
162 /// <summary>
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 173
diff changeset
163 /// 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
164 /// </summary>
265
6fe0cb1bf74f Re #279: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents: 263
diff changeset
165 public ILimit MaxLimit
172
f364a9e5463e Fixes #195: Setting max equipment without min may not function correctly
IBBoard <dev@ibboard.co.uk>
parents: 171
diff changeset
166 {
183
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 173
diff changeset
167 get
170
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
168 {
265
6fe0cb1bf74f Re #279: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents: 263
diff changeset
169 ILimit limit = maxLimit;
184
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
170
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
171 if (limit == null)
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
172 {
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
173 if (minLimit != null)
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
174 {
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
175 limit = minLimit;
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
176 }
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
177 else
204
3ef067225dc3 Fixes #208: equipmentslot limit issues
IBBoard <dev@ibboard.co.uk>
parents: 193
diff changeset
178 {
193
12aa4b76d24e Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 184
diff changeset
179 limit = new SimpleRoundedPercentageLimit(100, false);
184
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
180 }
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 return limit;
172
f364a9e5463e Fixes #195: Setting max equipment without min may not function correctly
IBBoard <dev@ibboard.co.uk>
parents: 171
diff changeset
184 }
170
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
185 set
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
186 {
183
36adabb1c3ea Re #198: Add slots with counts to units
IBBoard <dev@ibboard.co.uk>
parents: 173
diff changeset
187 if (value != null)
170
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
188 {
184
cedf8bba1d52 Re #198: Add equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 183
diff changeset
189 maxLimit = value;
170
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
190 }
172
f364a9e5463e Fixes #195: Setting max equipment without min may not function correctly
IBBoard <dev@ibboard.co.uk>
parents: 171
diff changeset
191 }
f364a9e5463e Fixes #195: Setting max equipment without min may not function correctly
IBBoard <dev@ibboard.co.uk>
parents: 171
diff changeset
192 }
170
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
193
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
194 public EquipmentItem EquipmentItem
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
195 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
196 get { return item; }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
197 }
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 public override string ToString()
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
200 {
306
886d28c1b6e5 Re #99: Define points systems
IBBoard <dev@ibboard.co.uk>
parents: 305
diff changeset
201 return Translation.GetTranslation("UnitEquipmentItemName", "{0} ({1}{2} each)", Name, Cost, GameSystem.GetPointsAbbrev(Cost));
170
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
202 }
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 public bool HasAlternatives()
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
205 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
206 if (MutexGroups.Length == 0)
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
207 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
208 return false;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
209 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
210 else if (EquipmentForUnit == null)
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
211 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
212 return false;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
213 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
214 else
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
215 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
216 //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
217 return EquipmentForUnit.GetEquipmentItemsByExclusionGroups(MutexGroups).Length > 1;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
218 }
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 public string Description
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
222 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
223 get { return EquipmentItem.Description; }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
224 }
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 public Race EquipmentForRace
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
227 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
228 get { return EquipmentItem.EquipmentForRace; }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
229 }
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 public bool CanBeUsedWithItem(EquipmentItem item)
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
232 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
233 return EquipmentItem.CanBeUsedWithItem(item);
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
234 }
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 public string SlotName
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
237 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
238 get { return slotName; }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
239 set
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 if (value != null && value != "")
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
242 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
243 slotName = value;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
244 }
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 }
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
247 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
248 }