changeset 361:8781e53c59bb

Re #345: Add failure message to requirements * Return message for each failure (don't stop at first one)
author IBBoard <dev@ibboard.co.uk>
date Sun, 01 May 2011 14:45:56 +0000
parents 777725613edb
children c19e61262400
files API/Objects/Requirement/RequirementHandler.cs
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line diff
     1.1 --- a/API/Objects/Requirement/RequirementHandler.cs	Sun May 01 14:33:27 2011 +0000
     1.2 +++ b/API/Objects/Requirement/RequirementHandler.cs	Sun May 01 14:45:56 2011 +0000
     1.3 @@ -2,6 +2,7 @@
     1.4  // 
     1.5  // 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.
     1.6  using System;
     1.7 +using System.Collections.Generic;
     1.8  
     1.9  namespace IBBoard.WarFoundry.API.Objects.Requirement
    1.10  {
    1.11 @@ -15,15 +16,22 @@
    1.12  		}
    1.13  
    1.14  		public static Validation ValidateArmy (Army army)
    1.15 +		{
    1.16 +			ICollection<string> ignored;
    1.17 +			return ValidateArmy(army, out ignored);
    1.18 +		}
    1.19 +
    1.20 +		public static Validation ValidateArmy (Army army, out ICollection<string> failureMessages)
    1.21  		{
    1.22 -			Validation result = Validation.Passed;
    1.23 +			Validation result = Validation.Passed;
    1.24 +			failureMessages = new List<string>();
    1.25  
    1.26  			foreach (IRequirement requirement in army.GetRequirements())
    1.27  			{
    1.28  				if (!Validates.AsOkay(requirement.ValidatesArmy(army)))
    1.29  				{
    1.30 -					result = Validation.Failed;
    1.31 -					break;
    1.32 +					result = Validation.Failed;
    1.33 +					failureMessages.Add(requirement.GetValidationMessage(army));
    1.34  				}
    1.35  			}
    1.36