comparison api/Objects/UnitEquipmentItem.cs @ 167:9ba56a8e5096

Re #198: Add slots with counts to units * Add initial API methods * Add value loading
author IBBoard <dev@ibboard.co.uk>
date Tue, 06 Oct 2009 14:59:54 +0000
parents 91f7b8da0b53
children 3045a168714a
comparison
equal deleted inserted replaced
166:6902f49e16e0 167:9ba56a8e5096
22 private double maxPercentage; 22 private double maxPercentage;
23 private double costMultiplier; 23 private double costMultiplier;
24 private RoundType roundType; 24 private RoundType roundType;
25 private string[] mutexGroups; 25 private string[] mutexGroups;
26 private UnitType unitType; 26 private UnitType unitType;
27 27 private string slotName = "";
28 public UnitEquipmentItem(EquipmentItem equipmentItem, UnitType equipmentFor) : this(equipmentItem, equipmentFor, new string[0]) 28
29 public UnitEquipmentItem(EquipmentItem equipmentItem, UnitType equipmentFor)
30 : this(equipmentItem, equipmentFor, new string[0])
29 { 31 {
30 //Do nothing extra 32 //Do nothing extra
31 } 33 }
32 34
33 public UnitEquipmentItem(EquipmentItem equipmentItem, UnitType equipmentFor, params string[] mutexGroups) 35 public UnitEquipmentItem(EquipmentItem equipmentItem, UnitType equipmentFor, params string[] mutexGroups)
34 { 36 {
35 item = equipmentItem; 37 item = equipmentItem;
36 unitType = equipmentFor; 38 unitType = equipmentFor;
37 this.mutexGroups = mutexGroups; 39 this.mutexGroups = mutexGroups;
38 unitType.AddEquipmentItem(this); 40 unitType.AddEquipmentItem(this);
39 } 41 }
40 42
41 public override string Name 43 public override string Name
42 { 44 {
43 get 45 get
44 { 46 {
45 return item.Name; 47 return item.Name;
46 } 48 }
47 set 49 set
48 { 50 {
49 base.Name = value; 51 base.Name = value;
50 } 52 }
51 } 53 }
52 54
53 public override string ID { 55 public override string ID
56 {
54 get 57 get
55 { 58 {
56 return (EquipmentForUnit == null ? base.ID : EquipmentForUnit.ID) + EquipmentItemID; 59 return (EquipmentForUnit == null ? base.ID : EquipmentForUnit.ID) + EquipmentItemID;
57 } 60 }
58 set 61 set
59 { 62 {
60 base.ID = value; 63 base.ID = value;
61 } 64 }
62 } 65 }
63 66
64 67
65 public string EquipmentItemID 68 public string EquipmentItemID
66 { 69 {
67 get { return item.ID; } 70 get { return item.ID; }
68 } 71 }
69 72
70 public double Cost 73 public double Cost
71 { 74 {
72 get 75 get
73 { 76 {
74 return IBBMath.Round(EquipmentItem.Cost * CostMultiplier, CostRoundType); 77 return IBBMath.Round(EquipmentItem.Cost * CostMultiplier, CostRoundType);
75 } 78 }
76 } 79 }
77 80
78 public double CostMultiplier 81 public double CostMultiplier
79 { 82 {
80 get { return costMultiplier; } 83 get { return costMultiplier; }
81 set 84 set
88 { 91 {
89 get { return roundType; } 92 get { return roundType; }
90 set 93 set
91 { 94 {
92 roundType = value; 95 roundType = value;
93 } 96 }
94 } 97 }
95 98
96 public bool IsRequired 99 public bool IsRequired
97 { 100 {
98 get { return required; } 101 get { return required; }
118 121
119 public UnitType EquipmentForUnit 122 public UnitType EquipmentForUnit
120 { 123 {
121 get { return unitType; } 124 get { return unitType; }
122 } 125 }
123 126
124 public bool IsRatioLimit 127 public bool IsRatioLimit
125 { 128 {
126 get { return minPercentage!=100 || maxPercentage!=100; } 129 get { return minPercentage != 100 || maxPercentage != 100; }
127 } 130 }
128 131
129 public int MinNumber 132 public int MinNumber
130 { 133 {
131 get { return minNum; } 134 get { return minNum; }
132 set 135 set
133 { 136 {
134 if (value >=0 || value == WarFoundryCore.INFINITY) 137 if (value >= 0 || value == WarFoundryCore.INFINITY)
135 { 138 {
136 minNum = value; 139 minNum = value;
137 } 140 }
138 //TODO: Check Min<Max 141 //TODO: Check Min<Max
139 } 142 }
140 } 143 }
141 144
142 public int MaxNumber 145 public int MaxNumber
143 { 146 {
144 get { return maxNum; } 147 get { return maxNum; }
145 set 148 set
146 { 149 {
147 if (value >=0 || value == WarFoundryCore.INFINITY) 150 if (value >= 0 || value == WarFoundryCore.INFINITY)
148 { 151 {
149 maxNum = value; 152 maxNum = value;
150 } 153 }
151 //TODO: Check Min<Max 154 //TODO: Check Min<Max
152 } 155 }
153 } 156 }
154 157
155 public double MinPercentage 158 public double MinPercentage
156 { 159 {
157 get { return minPercentage; } 160 get { return minPercentage; }
158 set 161 set
159 { 162 {
160 if (value >=0 && value <= 100) 163 if (value >= 0 && value <= 100)
161 { 164 {
162 minPercentage = value; 165 minPercentage = value;
163 } 166 }
164 //TODO: Check Min<Max 167 //TODO: Check Min<Max
165 } 168 }
166 } 169 }
167 170
168 public double MaxPercentage 171 public double MaxPercentage
169 { 172 {
170 get { return maxPercentage; } 173 get { return maxPercentage; }
171 set 174 set
172 { 175 {
173 if (value >=0 && value <= 100) 176 if (value >= 0 && value <= 100)
174 { 177 {
175 maxPercentage = value; 178 maxPercentage = value;
176 } 179 }
177 //TODO: Check Min<Max 180 //TODO: Check Min<Max
178 } 181 }
207 210
208 public ArmourType ItemArmourType 211 public ArmourType ItemArmourType
209 { 212 {
210 get { return EquipmentItem.ItemArmourType; } 213 get { return EquipmentItem.ItemArmourType; }
211 } 214 }
212 215
213 public string Description 216 public string Description
214 { 217 {
215 get { return EquipmentItem.Description; } 218 get { return EquipmentItem.Description; }
216 } 219 }
217 220
218 public Race EquipmentForRace 221 public Race EquipmentForRace
219 { 222 {
220 get { return EquipmentItem.EquipmentForRace; } 223 get { return EquipmentItem.EquipmentForRace; }
221 } 224 }
222 225
233 [Obsolete("Use UnitEquipmentUtil method instead")] 236 [Obsolete("Use UnitEquipmentUtil method instead")]
234 public bool IsMutuallyExclusive(UnitEquipmentItem item) 237 public bool IsMutuallyExclusive(UnitEquipmentItem item)
235 { 238 {
236 return UnitEquipmentUtil.ItemsAreMutuallyExclusive(this, item); 239 return UnitEquipmentUtil.ItemsAreMutuallyExclusive(this, item);
237 } 240 }
241
242 public string SlotName
243 {
244 get { return slotName; }
245 set
246 {
247 if (value != null && value != "")
248 {
249 slotName = value;
250 }
251 }
252 }
238 } 253 }
239 } 254 }