Mercurial > repos > IBDev-IBBoard.WarFoundry.API
comparison API/Objects/Requirement/UnitRequiresAtLeastNUnitsRequirement.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 |
---|---|
21 | 21 |
22 /// <summary> | 22 /// <summary> |
23 /// Checks whether the supplied WarFoundryObject can be added to the supplied army. | 23 /// Checks whether the supplied WarFoundryObject can be added to the supplied army. |
24 /// </summary> | 24 /// </summary> |
25 /// <returns> | 25 /// <returns> |
26 /// <c>true</c> if the object can be added, else <c>false</c> | 26 /// A <code>Validation</code> enum to show the result of the validation |
27 /// </returns> | 27 /// </returns> |
28 /// <param name='wfObject'> | 28 /// <param name='wfObject'> |
29 /// The object that we want to add. This may be involved in the check, or it may not affect the evaluation of the requirement | 29 /// The object that we want to add. This may be involved in the check, or it may not affect the evaluation of the requirement |
30 /// </param> | 30 /// </param> |
31 /// <param name='toArmy'> | 31 /// <param name='toArmy'> |
32 /// The army to add the object to. | 32 /// The army to add the object to. |
33 /// </param> | 33 /// </param> |
34 public override bool AllowsAdding(WarFoundryObject wfObject, Army toArmy) | 34 public override Validation AllowsAdding(WarFoundryObject wfObject, Army toArmy) |
35 { | 35 { |
36 return IsApplicable(wfObject, toArmy) ? base.ValidatesArmy(toArmy) : true; | 36 return IsApplicable(wfObject, toArmy) ? base.ValidatesArmy(toArmy) : Validation.NotApplicable; |
37 } | 37 } |
38 | 38 |
39 | 39 |
40 private bool IsApplicable(WarFoundryObject toObject, Army toArmy) | 40 private bool IsApplicable(WarFoundryObject toObject, Army toArmy) |
41 { | 41 { |
53 { | 53 { |
54 return requirementOnType.Equals(toObject) || (toObject is Unit && requirementOnType.Equals(((Unit)toObject).UnitType)); | 54 return requirementOnType.Equals(toObject) || (toObject is Unit && requirementOnType.Equals(((Unit)toObject).UnitType)); |
55 } | 55 } |
56 | 56 |
57 | 57 |
58 public override bool ValidatesArmy(Army toArmy) | 58 public override Validation ValidatesArmy(Army toArmy) |
59 { | 59 { |
60 return IsApplicable(toArmy) ? base.ValidatesArmy(toArmy) : true; | 60 return IsApplicable(toArmy) ? base.ValidatesArmy(toArmy) : Validation.NotApplicable; |
61 } | 61 } |
62 } | 62 } |
63 } | 63 } |
64 | 64 |