Mercurial > repos > IBBoard.WarFoundry.API
diff API/Objects/Requirement/RequirementHandler.cs @ 487:248df19652f9
Re #410: Create "N units per M models in parent unit" requirement
* Add null adding context
* Add initial skeleton of "N units per M models in parent unit" requirement
* Update use of context
* Standardise some of "is applicable" testing
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Fri, 27 Jul 2012 20:31:12 +0100 |
parents | 676f5ce04176 |
children | 4f01fdc3bb41 |
line wrap: on
line diff
--- a/API/Objects/Requirement/RequirementHandler.cs Sun Jul 15 21:01:47 2012 +0100 +++ b/API/Objects/Requirement/RequirementHandler.cs Fri Jul 27 20:31:12 2012 +0100 @@ -3,6 +3,7 @@ // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license. using System; using System.Collections.Generic; +using IBBoard.WarFoundry.API.Objects.Requirement.Context; namespace IBBoard.WarFoundry.API.Objects.Requirement { @@ -41,12 +42,22 @@ public static Validation AllowsAdding(UnitType unitType, Army army) { - ICollection<string> ignored; - return AllowsAdding(unitType, army, out ignored); + return AllowsAdding(unitType, army, new NullAddingContext()); } + public static Validation AllowsAdding(UnitType unitType, Army army, AddingContext context) + { + ICollection<string> ignored; + return AllowsAdding(unitType, army, context, out ignored); + } + public static Validation AllowsAdding(UnitType unitType, Army army, out ICollection<string> failureMessages) { + return AllowsAdding(unitType, army, new NullAddingContext(), out failureMessages); + } + + public static Validation AllowsAdding(UnitType unitType, Army army, AddingContext context, out ICollection<string> failureMessages) + { Validation result = Validation.Passed; failureMessages = new List<string>(); @@ -55,7 +66,7 @@ if (!Validates.AsOkay(requirement.AllowsAdding(unitType, army))) { result = Validation.Failed; - failureMessages.Add(requirement.GetAllowsAddingMessage(unitType, army)); + failureMessages.Add(requirement.GetAllowsAddingMessage(unitType, army, context)); } }