Mercurial > repos > snowblizz-super-API-ideas
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 wrap: on
line diff
--- a/API/Factories/Xml/WarFoundryXmlRaceFactory.cs Sat May 28 16:02:36 2011 +0000 +++ b/API/Factories/Xml/WarFoundryXmlRaceFactory.cs Mon Jun 13 15:15:04 2011 +0000 @@ -11,7 +11,8 @@ using IBBoard.Limits; using IBBoard.CustomMath; using ICSharpCode.SharpZipLib.Zip; -using IBBoard.WarFoundry.API.Objects; +using IBBoard.WarFoundry.API.Objects; +using IBBoard.WarFoundry.API.Objects.Requirement; namespace IBBoard.WarFoundry.API.Factories.Xml { @@ -373,7 +374,17 @@ private void LoadRequirementsForUnitType(XmlElement elem, UnitType type) { - //TODO: Load requirements + //TODO: Handle requirements more extensibly + foreach (XmlElement extraData in WarFoundryXmlFactoryUtils.SelectNodes(elem, "race:requirements/race:requirement")) + { + string name = extraData.GetAttribute("requirementName"); + if (name == "RequiresAtLeastNUnits") { + string data = WarFoundryXmlFactoryUtils.SelectSingleElement(extraData, "race:data").InnerText; + UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(type); + req.AddUnitTypeRequirement(GetUnitTypeFromDocument(elem.OwnerDocument, data, type.Race)); + type.AddRequirement(req); + } + } } private void LoadExtraDataForUnitType(XmlElement elem, UnitType type)