Mercurial > repos > IBBoard.WarFoundry.API
comparison api/Objects/UnitType.cs @ 176:22429737cd77
Re #198: Add slots with counts to units
* Migrate to using new Limit objects from ibboard:ticket:24
* Parse new objects
* Move more data type definitions in to Core schema for re-use
* Make UnitType just return limit objects
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Thu, 22 Oct 2009 19:51:42 +0000 |
parents | 3045a168714a |
children | 8c6f55d289b0 |
comparison
equal
deleted
inserted
replaced
175:996816199b72 | 176:22429737cd77 |
---|---|
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. | 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. |
4 | 4 |
5 using System; | 5 using System; |
6 using System.Collections.Generic; | 6 using System.Collections.Generic; |
7 using System.Xml; | 7 using System.Xml; |
8 using IBBoard.Limits; | |
8 using IBBoard.Logging; | 9 using IBBoard.Logging; |
9 using IBBoard.WarFoundry.API.Requirements; | 10 using IBBoard.WarFoundry.API.Requirements; |
10 | 11 |
11 namespace IBBoard.WarFoundry.API.Objects | 12 namespace IBBoard.WarFoundry.API.Objects |
12 { | 13 { |
29 private Dictionary<string, Ability> requiredAbilities = new Dictionary<string, Ability>(); | 30 private Dictionary<string, Ability> requiredAbilities = new Dictionary<string, Ability>(); |
30 private Dictionary<string, Ability> optionalAbilities = new Dictionary<string, Ability>(); | 31 private Dictionary<string, Ability> optionalAbilities = new Dictionary<string, Ability>(); |
31 private String notes = ""; | 32 private String notes = ""; |
32 private List<UnitType> containedTypes = new List<UnitType>(); | 33 private List<UnitType> containedTypes = new List<UnitType>(); |
33 private Dictionary<string, string> extraData = new Dictionary<string, string>(); | 34 private Dictionary<string, string> extraData = new Dictionary<string, string>(); |
34 private Dictionary<string, int> slotLimits = new Dictionary<string, int>(); | 35 private Dictionary<string, AbstractLimit> slotLimits = new Dictionary<string, AbstractLimit>(); |
35 | 36 |
36 | 37 |
37 public UnitType(string id, string typeName, Race parentRace) : base(id, typeName) | 38 public UnitType(string id, string typeName, Race parentRace) : base(id, typeName) |
38 { | 39 { |
39 race = parentRace; | 40 race = parentRace; |
448 { | 449 { |
449 return stats.StatsID; | 450 return stats.StatsID; |
450 } | 451 } |
451 } | 452 } |
452 | 453 |
453 public void AddEquipmentSlot(string slotName, int slotLimit) | 454 public void AddEquipmentSlot(string slotName, AbstractLimit slotLimit) |
454 { | 455 { |
455 slotLimits.Add(slotName, slotLimit); | 456 slotLimits.Add(slotName, slotLimit); |
456 } | 457 } |
457 | 458 |
458 public bool HasEquipmentSlot(string slotName) | 459 public bool HasEquipmentSlot(string slotName) |
459 { | 460 { |
460 return slotLimits.ContainsKey(slotName); | 461 return slotLimits.ContainsKey(slotName); |
461 } | 462 } |
462 | 463 |
463 /// <summary> | 464 /// <summary> |
464 /// Gets the maximum number of items allowed in a single slot | 465 /// Gets the maximum limit on the number of items allowed in a single slot |
465 /// </summary> | 466 /// </summary> |
466 /// <param name="slotName">The name of the equipment slot to get the limit for the named slot</param> | 467 /// <param name="slotName">The name of the equipment slot to get the limit for</param> |
467 /// <returns>The maximum number of items allowed in a slot, or <code>-1</code> if the slot is the default one or has not been specified</returns> | 468 /// <returns>The limit of the number of items allowed in a slot, or an infinite limit if the slot is the default one or has not been specified</returns> |
468 public int GetEquipmentSlotLimit(string slotName) | 469 public AbstractLimit GetEquipmentSlotLimit(string slotName) |
469 { | 470 { |
470 int slotLimit = -1; | 471 AbstractLimit slotLimit = null; |
471 | 472 |
472 if (HasEquipmentSlot(slotName)) | 473 if (HasEquipmentSlot(slotName)) |
473 { | 474 { |
474 slotLimit = DictionaryUtils.GetValue(slotLimits, slotName); | 475 slotLimit = DictionaryUtils.GetValue(slotLimits, slotName); |
476 } | |
477 | |
478 if (slotLimit == null) | |
479 { | |
480 slotLimit = new UnlimitedLimit(); | |
475 } | 481 } |
476 | 482 |
477 return slotLimit; | 483 return slotLimit; |
478 } | 484 } |
479 } | 485 } |