Mercurial > repos > IBBoard.WarFoundry.API
comparison API/Objects/Requirement/RequiresAtLeastNUnitsRequirement.cs @ 427:3882b533d99d
Re #27: Define unit requirements
* Add ID to requirements so that it isn't just defined in factories
* Make factory use ID from requirement class to avoid duplication and possible mismatch
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 30 Oct 2011 20:31:43 +0000 |
parents | 71fceea2725b |
children | b671085871b7 |
comparison
equal
deleted
inserted
replaced
426:61fae5cbba02 | 427:3882b533d99d |
---|---|
7 using System.Text; | 7 using System.Text; |
8 | 8 |
9 namespace IBBoard.WarFoundry.API.Objects.Requirement | 9 namespace IBBoard.WarFoundry.API.Objects.Requirement |
10 { | 10 { |
11 /// <summary> | 11 /// <summary> |
12 /// A requirement where a WarFoundryObject requires at least N units of one or more unit types before any number of that object can be taken in an army. | 12 /// A requirement where a WarFoundryObject requires at least N units of any of the specified unit types before any number of that object can be taken in an army. |
13 /// | |
14 /// The definition for how this requirement is built from a data file is defined in the <see cref="UnitRequiresAtLeastNUnitsRequirementFactory"/> class. | |
13 /// </summary> | 15 /// </summary> |
14 public class RequiresAtLeastNUnitsRequirement : AbstractRequirement | 16 public class RequiresAtLeastNUnitsRequirement : AbstractRequirement |
15 { | 17 { |
18 public static readonly string REQUIREMENT_ID = "RequiresAtLeastNUnits"; | |
16 private List<UnitCountRequirementData> requiredTypes; | 19 private List<UnitCountRequirementData> requiredTypes; |
17 | 20 |
18 public RequiresAtLeastNUnitsRequirement(params UnitType[] requiredUnitTypes) | 21 public RequiresAtLeastNUnitsRequirement(params UnitType[] requiredUnitTypes) |
19 { | 22 { |
20 FailureStringPrefix = "Army must contain: "; | 23 FailureStringPrefix = "Army must contain: "; |
21 requiredTypes = new List<UnitCountRequirementData>(); | 24 requiredTypes = new List<UnitCountRequirementData>(); |
22 | 25 |
23 foreach (UnitType unitType in requiredUnitTypes) | 26 foreach (UnitType unitType in requiredUnitTypes) |
24 { | 27 { |
25 AddUnitTypeRequirement(unitType); | 28 AddUnitTypeRequirement(unitType); |
29 } | |
30 } | |
31 | |
32 | |
33 public override string RequirementID | |
34 { | |
35 get | |
36 { | |
37 return REQUIREMENT_ID; | |
26 } | 38 } |
27 } | 39 } |
28 | 40 |
29 protected override bool TypeEquals (object obj) | 41 protected override bool TypeEquals (object obj) |
30 { | 42 { |