Mercurial > repos > IBBoard.WarFoundry.API
comparison API/Objects/Requirement/RequiresAtLeastNUnitsRequirement.cs @ 340:7bd2a7cdbfbd
Re #27: Unit requirements
* Update "Requires at least" requirements to use new enum
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 04 Apr 2011 19:06:01 +0000 |
parents | 4497ebce9a57 |
children | 008537acf244 |
comparison
equal
deleted
inserted
replaced
339:50cd43bf51b3 | 340:7bd2a7cdbfbd |
---|---|
26 | 26 |
27 /// <summary> | 27 /// <summary> |
28 /// Checks whether the supplied WarFoundryObject can be added to the supplied army. | 28 /// Checks whether the supplied WarFoundryObject can be added to the supplied army. |
29 /// </summary> | 29 /// </summary> |
30 /// <returns> | 30 /// <returns> |
31 /// <c>true</c> if the object can be added, else <c>false</c> | 31 /// A <code>Validation</code> enum to show the result of the validation |
32 /// </returns> | 32 /// </returns> |
33 /// <param name='wfObject'> | 33 /// <param name='wfObject'> |
34 /// The object that we want to add. This may be involved in the check, or it may not affect the evaluation of the requirement | 34 /// The object that we want to add. This may be involved in the check, or it may not affect the evaluation of the requirement |
35 /// </param> | 35 /// </param> |
36 /// <param name='toArmy'> | 36 /// <param name='toArmy'> |
37 /// The army to add the object to. | 37 /// The army to add the object to. |
38 /// </param> | 38 /// </param> |
39 public virtual bool AllowsAdding(WarFoundryObject wfObject, Army toArmy) | 39 public virtual Validation AllowsAdding(WarFoundryObject wfObject, Army toArmy) |
40 { | 40 { |
41 return this.ValidatesArmy(toArmy); | 41 return this.ValidatesArmy(toArmy); |
42 } | 42 } |
43 | 43 |
44 /// <summary> | 44 /// <summary> |
68 | 68 |
69 /// <summary> | 69 /// <summary> |
70 /// Checks whether the supplied army is currently valid according to this requirement. | 70 /// Checks whether the supplied army is currently valid according to this requirement. |
71 /// </summary> | 71 /// </summary> |
72 /// <returns> | 72 /// <returns> |
73 /// <c>true</c> if the army is valid, else <c>false</c> | 73 /// A <code>Validation</code> enum to show the result of the validation |
74 /// </returns> | 74 /// </returns> |
75 /// <param name='toValidate'> | 75 /// <param name='toValidate'> |
76 /// The army to validate | 76 /// The army to validate |
77 /// </param> | 77 /// </param> |
78 public virtual bool ValidatesArmy(Army toValidate) | 78 public virtual Validation ValidatesArmy(Army toValidate) |
79 { | 79 { |
80 bool canAdd = true; | 80 Validation isValid = Validation.Passed; |
81 | 81 |
82 foreach (UnitCountRequirementData requirement in requiredTypes) | 82 foreach (UnitCountRequirementData requirement in requiredTypes) |
83 { | 83 { |
84 if (toValidate.GetUnitTypeCount(requirement.UnitType) < requirement.Count) | 84 if (toValidate.GetUnitTypeCount(requirement.UnitType) < requirement.Count) |
85 { | 85 { |
86 canAdd = false; | 86 isValid = Validation.Failed; |
87 break; | 87 break; |
88 } | 88 } |
89 } | 89 } |
90 | 90 |
91 return canAdd; | 91 return isValid; |
92 } | 92 } |
93 } | 93 } |
94 } | 94 } |
95 | 95 |