# HG changeset patch # User IBBoard # Date 1301943961 0 # Node ID 7bd2a7cdbfbd00a1d208c5c3b2986727922c4446 # Parent 50cd43bf51b3259d68b03a03bb5e3c9b2458d534 Re #27: Unit requirements * Update "Requires at least" requirements to use new enum diff -r 50cd43bf51b3 -r 7bd2a7cdbfbd API/Objects/Requirement/RequiresAtLeastNUnitsRequirement.cs --- a/API/Objects/Requirement/RequiresAtLeastNUnitsRequirement.cs Sun Apr 03 19:40:42 2011 +0000 +++ b/API/Objects/Requirement/RequiresAtLeastNUnitsRequirement.cs Mon Apr 04 19:06:01 2011 +0000 @@ -28,7 +28,7 @@ /// Checks whether the supplied WarFoundryObject can be added to the supplied army. /// /// - /// true if the object can be added, else false + /// A Validation enum to show the result of the validation /// /// /// The object that we want to add. This may be involved in the check, or it may not affect the evaluation of the requirement @@ -36,7 +36,7 @@ /// /// The army to add the object to. /// - public virtual bool AllowsAdding(WarFoundryObject wfObject, Army toArmy) + public virtual Validation AllowsAdding(WarFoundryObject wfObject, Army toArmy) { return this.ValidatesArmy(toArmy); } @@ -70,25 +70,25 @@ /// Checks whether the supplied army is currently valid according to this requirement. /// /// - /// true if the army is valid, else false + /// A Validation enum to show the result of the validation /// /// /// The army to validate /// - public virtual bool ValidatesArmy(Army toValidate) + public virtual Validation ValidatesArmy(Army toValidate) { - bool canAdd = true; + Validation isValid = Validation.Passed; foreach (UnitCountRequirementData requirement in requiredTypes) { if (toValidate.GetUnitTypeCount(requirement.UnitType) < requirement.Count) { - canAdd = false; + isValid = Validation.Failed; break; } } - return canAdd; + return isValid; } } } diff -r 50cd43bf51b3 -r 7bd2a7cdbfbd API/Objects/Requirement/UnitRequiresAtLeastNUnitsRequirement.cs --- a/API/Objects/Requirement/UnitRequiresAtLeastNUnitsRequirement.cs Sun Apr 03 19:40:42 2011 +0000 +++ b/API/Objects/Requirement/UnitRequiresAtLeastNUnitsRequirement.cs Mon Apr 04 19:06:01 2011 +0000 @@ -23,7 +23,7 @@ /// Checks whether the supplied WarFoundryObject can be added to the supplied army. /// /// - /// true if the object can be added, else false + /// A Validation enum to show the result of the validation /// /// /// The object that we want to add. This may be involved in the check, or it may not affect the evaluation of the requirement @@ -31,9 +31,9 @@ /// /// The army to add the object to. /// - public override bool AllowsAdding(WarFoundryObject wfObject, Army toArmy) + public override Validation AllowsAdding(WarFoundryObject wfObject, Army toArmy) { - return IsApplicable(wfObject, toArmy) ? base.ValidatesArmy(toArmy) : true; + return IsApplicable(wfObject, toArmy) ? base.ValidatesArmy(toArmy) : Validation.NotApplicable; } @@ -55,9 +55,9 @@ } - public override bool ValidatesArmy(Army toArmy) + public override Validation ValidatesArmy(Army toArmy) { - return IsApplicable(toArmy) ? base.ValidatesArmy(toArmy) : true; + return IsApplicable(toArmy) ? base.ValidatesArmy(toArmy) : Validation.NotApplicable; } } }