changeset 355:47712a323cf2

Re #27: Unit requirements * Implement check for adding units to army
author IBBoard <dev@ibboard.co.uk>
date Mon, 25 Apr 2011 10:32:51 +0000
parents 47acc63cf529
children 51cccccf3669
files API/Objects/Requirement/RequirementHandler.cs
diffstat 1 files changed, 16 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- a/API/Objects/Requirement/RequirementHandler.cs	Fri Apr 22 10:38:03 2011 +0000
     1.2 +++ b/API/Objects/Requirement/RequirementHandler.cs	Mon Apr 25 10:32:51 2011 +0000
     1.3 @@ -29,6 +29,22 @@
     1.4  
     1.5  			return result;
     1.6  		}
     1.7 +
     1.8 +		public static Validation AllowsAdding(UnitType unitType, Army army)
     1.9 +		{
    1.10 +			Validation result = Validation.Passed;
    1.11 +
    1.12 +			foreach (IRequirement requirement in army.GetRequirements())
    1.13 +			{
    1.14 +				if (!Validates.AsOkay(requirement.AllowsAdding(unitType, army)))
    1.15 +				{
    1.16 +					result = Validation.Failed;
    1.17 +					break;
    1.18 +				}
    1.19 +			}
    1.20 +
    1.21 +			return result;
    1.22 +		}
    1.23  	}
    1.24  }
    1.25