comparison API/Objects/Requirement/RequiresNoMoreThanNOfUnitTypeRequirement.cs @ 341:5f94b8a40876

Re #27: Unit requirements * Switch remaining unit requirement to using enum
author IBBoard <dev@ibboard.co.uk>
date Mon, 04 Apr 2011 19:28:44 +0000
parents 3c4a6403a88c
children 407757e597f9
comparison
equal deleted inserted replaced
340:7bd2a7cdbfbd 341:5f94b8a40876
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 bool AllowsAdding(WarFoundryObject wfObject, Army toArmy) 39 public Validation AllowsAdding(WarFoundryObject wfObject, Army toArmy)
40 { 40 {
41 bool canAdd = true; 41 Validation canAdd = Validation.Passed;
42 42
43 foreach (UnitCountRequirementData limit in limitedTypes) 43 foreach (UnitCountRequirementData limit in limitedTypes)
44 { 44 {
45 if (toArmy.GetUnitTypeCount(limit.UnitType) > limit.Count) 45 if (toArmy.GetUnitTypeCount(limit.UnitType) > limit.Count)
46 { 46 {
47 canAdd = false; 47 canAdd = Validation.Failed;
48 break; 48 break;
49 } 49 }
50 } 50 }
51 51
52 return canAdd; 52 return canAdd;
53 } 53 }
54 54
55 /// <summary> 55 /// <summary>
56 /// Adds a requirement for there to be at least minCount of a given UnitType 56 /// Adds a requirement for there to be at least minCount of a given UnitType