changeset 370:077e9be48438

Re #346: Add requirement schema support * Pass unit test with a specific case for one requirement - needs extensibility
author IBBoard <dev@ibboard.co.uk>
date Mon, 13 Jun 2011 15:15:04 +0000
parents c2bc207a1571
children bfdb95906075
files API/Factories/Xml/WarFoundryXmlRaceFactory.cs
diffstat 1 files changed, 13 insertions(+), 2 deletions(-) [+]
line diff
     1.1 --- a/API/Factories/Xml/WarFoundryXmlRaceFactory.cs	Sat May 28 16:02:36 2011 +0000
     1.2 +++ b/API/Factories/Xml/WarFoundryXmlRaceFactory.cs	Mon Jun 13 15:15:04 2011 +0000
     1.3 @@ -11,7 +11,8 @@
     1.4  using IBBoard.Limits;
     1.5  using IBBoard.CustomMath;
     1.6  using ICSharpCode.SharpZipLib.Zip;
     1.7 -using IBBoard.WarFoundry.API.Objects;
     1.8 +using IBBoard.WarFoundry.API.Objects;
     1.9 +using IBBoard.WarFoundry.API.Objects.Requirement;
    1.10  
    1.11  namespace IBBoard.WarFoundry.API.Factories.Xml
    1.12  {
    1.13 @@ -373,7 +374,17 @@
    1.14  
    1.15  		private void LoadRequirementsForUnitType(XmlElement elem, UnitType type)
    1.16  		{
    1.17 -			//TODO: Load requirements
    1.18 +			//TODO: Handle requirements more extensibly
    1.19 +			foreach (XmlElement extraData in WarFoundryXmlFactoryUtils.SelectNodes(elem, "race:requirements/race:requirement"))
    1.20 +			{
    1.21 +				string name = extraData.GetAttribute("requirementName");
    1.22 +				if (name == "RequiresAtLeastNUnits") {
    1.23 +					string data = WarFoundryXmlFactoryUtils.SelectSingleElement(extraData, "race:data").InnerText;
    1.24 +					UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(type);
    1.25 +					req.AddUnitTypeRequirement(GetUnitTypeFromDocument(elem.OwnerDocument, data, type.Race));
    1.26 +					type.AddRequirement(req);
    1.27 +				}
    1.28 +			}
    1.29  		}
    1.30  		
    1.31  		private void LoadExtraDataForUnitType(XmlElement elem, UnitType type)