annotate api/Objects/UnitEquipmentItem.cs @ 171:85dc413279a4

* Change imports to stop references to deprecated code no-open-ticket
author IBBoard <dev@ibboard.co.uk>
date Mon, 12 Oct 2009 18:41:17 +0000
parents 3045a168714a
children f364a9e5463e
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;
161
81abc04b3dbe Re #192: Improve "clean coding" practice
IBBoard <dev@ibboard.co.uk>
parents: 157
diff changeset
7 using IBBoard.WarFoundry.API.Util;
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
8
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
9 namespace IBBoard.WarFoundry.API.Objects
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
10 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
11 /// <summary>
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
12 /// Summary description for UnitEquipmentItem.
170
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
13 /// </summary>
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
14 public class UnitEquipmentItem : WarFoundryObject
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
15 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
16 private EquipmentItem item;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
17 private bool required;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
18 private bool roundUp;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
19 private int minNum;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
20 private int maxNum;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
21 private double minPercentage;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
22 private double maxPercentage;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
23 private double costMultiplier;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
24 private RoundType roundType;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
25 private string[] mutexGroups;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
26 private UnitType unitType;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
27 private string slotName = "";
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
28
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
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
68 public string EquipmentItemID
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
69 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
70 get { return item.ID; }
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
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
73 public double Cost
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
74 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
75 get
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
76 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
77 return IBBMath.Round(EquipmentItem.Cost * CostMultiplier, CostRoundType);
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
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
81 public double CostMultiplier
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
82 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
83 get { return costMultiplier; }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
84 set
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
85 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
86 costMultiplier = value;
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
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
90 public RoundType CostRoundType
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
91 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
92 get { return roundType; }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
93 set
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
94 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
95 roundType = value;
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
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
99 public bool IsRequired
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
100 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
101 get { return required; }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
102 set { required = value; }
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
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
105 public bool RoundNumberUp
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
106 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
107 get { return roundUp; }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
108 set { roundUp = value; }
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
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
111 [Obsolete("Use MutexGroups instead for greater flexibility")]
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
112 public string MutexGroup
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
113 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
114 get { return (mutexGroups.Length == 0 ? "" : mutexGroups[0]); }
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
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
117 public String[] MutexGroups
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 get { return (string[]) mutexGroups.Clone(); }
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
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
122 public UnitType EquipmentForUnit
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 get { return unitType; }
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
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
127 public bool IsRatioLimit
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
128 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
129 get { return minPercentage != 100 || maxPercentage != 100; }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
130 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
131
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
132 public int MinNumber
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
133 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
134 get { return minNum; }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
135 set
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
136 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
137 if (value >= 0 || value == WarFoundryCore.INFINITY)
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
138 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
139 minNum = value;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
140 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
141 //TODO: Check Min<Max
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
142 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
143 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
144
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
145 public int MaxNumber
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
146 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
147 get { return maxNum; }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
148 set
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
149 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
150 if (value >= 0 || value == WarFoundryCore.INFINITY)
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
151 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
152 maxNum = value;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
153 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
154 //TODO: Check Min<Max
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
155 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
156 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
157
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
158 public double MinPercentage
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
159 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
160 get { return minPercentage; }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
161 set
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
162 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
163 if (value >= 0 && value <= 100)
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
164 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
165 minPercentage = value;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
166 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
167 //TODO: Check Min<Max
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
168 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
169 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
170
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
171 public double MaxPercentage
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
172 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
173 get { return maxPercentage; }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
174 set
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
175 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
176 if (value >= 0 && value <= 100)
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
177 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
178 maxPercentage = value;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
179 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
180 //TODO: Check Min<Max
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
181 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
182 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
183
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
184 public EquipmentItem EquipmentItem
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
185 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
186 get { return item; }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
187 }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
188
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
189 public override string ToString()
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
190 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
191 return EquipmentItem.Name + " (" + Cost + "pts each)";
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
192 }
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 bool HasAlternatives()
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 if (MutexGroups.Length == 0)
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 return false;
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 else if (EquipmentForUnit == null)
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 false;
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 else
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 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
207 return EquipmentForUnit.GetEquipmentItemsByExclusionGroups(MutexGroups).Length > 1;
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 }
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 public ArmourType ItemArmourType
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 get { return EquipmentItem.ItemArmourType; }
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
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
216 public string Description
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
217 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
218 get { return EquipmentItem.Description; }
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 Race EquipmentForRace
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.EquipmentForRace; }
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 bool CanBeUsedWithItem(EquipmentItem item)
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 return EquipmentItem.CanBeUsedWithItem(item);
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 CanBeUsedWithArmourType(ArmourType otherItemType)
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.CanBeUsedWithArmourType(otherItemType);
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 [Obsolete("Use UnitEquipmentUtil method instead")]
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
237 public bool IsMutuallyExclusive(UnitEquipmentItem 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 UnitEquipmentUtil.ItemsAreMutuallyExclusive(this, 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 string SlotName
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 get { return slotName; }
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
245 set
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 if (value != null && value != "")
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
248 {
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
249 slotName = value;
3045a168714a * Line ending clean-up
IBBoard <dev@ibboard.co.uk>
parents: 167
diff changeset
250 }
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 }
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
253 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
254 }