comparison API/Objects/Requirement/RequirementHandler.cs @ 451:676f5ce04176

Re #379: Fix validation of requirements to check for unit * Add method to Army to differentiate "all requirements" from "requirements relevant to adding a unit"
author IBBoard <dev@ibboard.co.uk>
date Sat, 28 Jan 2012 16:57:59 +0000
parents 506af4cbe3f5
children 248df19652f9
comparison
equal deleted inserted replaced
450:8811737baebf 451:676f5ce04176
48 public static Validation AllowsAdding(UnitType unitType, Army army, out ICollection<string> failureMessages) 48 public static Validation AllowsAdding(UnitType unitType, Army army, out ICollection<string> failureMessages)
49 { 49 {
50 Validation result = Validation.Passed; 50 Validation result = Validation.Passed;
51 failureMessages = new List<string>(); 51 failureMessages = new List<string>();
52 52
53 foreach (IRequirement requirement in army.GetRequirements()) 53 foreach (IRequirement requirement in army.GetAddingUnitRequirements(unitType))
54 { 54 {
55 if (!Validates.AsOkay(requirement.AllowsAdding(unitType, army))) 55 if (!Validates.AsOkay(requirement.AllowsAdding(unitType, army)))
56 { 56 {
57 result = Validation.Failed; 57 result = Validation.Failed;
58 failureMessages.Add(requirement.GetAllowsAddingMessage(unitType, army)); 58 failureMessages.Add(requirement.GetAllowsAddingMessage(unitType, army));