Mercurial > repos > IBDev-IBBoard.WarFoundry.API
comparison api/Objects/UnitType.cs @ 64:2094bd0ba652
Re #61 - Complete structure of WarFoundry API objects
* Make Unit work with EquipmentItem objects as it doesn't need to know about the limits
* Add methods to UnitType to check limits on an EquipmentItem
Also:
* Remove some unnecessary casting now that we're using genericed lists
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Thu, 09 Apr 2009 15:36:22 +0000 |
parents | 3c77722a02b5 |
children | d100ca4bd0c1 |
comparison
equal
deleted
inserted
replaced
63:a920b1bcb408 | 64:2094bd0ba652 |
---|---|
243 { | 243 { |
244 UnitEquipmentItem equipItem = null; | 244 UnitEquipmentItem equipItem = null; |
245 equipment.TryGetValue(id, out equipItem); | 245 equipment.TryGetValue(id, out equipItem); |
246 return equipItem; | 246 return equipItem; |
247 } | 247 } |
248 | |
249 /// <summary> | |
250 /// Gets a <see cref=" UnitEquipmentItem"/> for the given <see cref=" EquipmentItem"/>, or <code>null</code> if the unit can't take that <code>EquipmentItem</code> | |
251 /// </summary> | |
252 /// <param name="item"> | |
253 /// The <see cref="EquipmentItem"/> to get the <see cref=" UnitEquipmentItem"/> | |
254 /// </param> | |
255 /// <returns> | |
256 /// The <see cref="UnitEquipmentItem"/> that definies the UnitType's restrictions for taking the <see cref=" EquipmentItem"/> | |
257 /// </returns> | |
258 public UnitEquipmentItem GetEquipmentItem(EquipmentItem item) | |
259 { | |
260 return GetEquipmentItem(item.ID); | |
261 } | |
248 | 262 |
249 /// <summary> | 263 /// <summary> |
250 /// Gets an array of all available <see cref="UnitEquipmentItem"/>s for this UnitType | 264 /// Gets an array of all available <see cref="UnitEquipmentItem"/>s for this UnitType |
251 /// </summary> | 265 /// </summary> |
252 /// <returns> | 266 /// <returns> |
270 { | 284 { |
271 return list.ToArray(); | 285 return list.ToArray(); |
272 } | 286 } |
273 } | 287 } |
274 | 288 |
289 public bool IsRatioLimitedEquipmentItem(EquipmentItem item) | |
290 { | |
291 UnitEquipmentItem equip = GetEquipmentItem(item); | |
292 return equip != null && equip.IsRatioLimit; | |
293 } | |
294 | |
295 public bool IsAbsoluteLimitedEquipmentItem(EquipmentItem item) | |
296 { | |
297 UnitEquipmentItem equip = GetEquipmentItem(item); | |
298 return equip != null && !equip.IsRatioLimit; | |
299 } | |
300 | |
275 public ICollection<Ability> GetRequiredAbilities() | 301 public ICollection<Ability> GetRequiredAbilities() |
276 { | 302 { |
277 return requiredAbilities.Values; | 303 return requiredAbilities.Values; |
278 } | 304 } |
279 | 305 |