Mercurial > repos > IBDev-IBBoard.WarFoundry.API
comparison api/Factories/Xml/WarFoundryXmlArmyParser.cs @ 259:35dc06030355
Re #270: Add multiple categories to API
* Add "category" attribute to army schema
* Add method to define category when adding unit to army
* Make army loading check new attribute and assign to correct category or main category
TODO: Write out category of unit to army file
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 19 May 2010 20:07:07 +0000 |
parents | d1068f4b6d1c |
children | cd657faa0c05 |
comparison
equal
deleted
inserted
replaced
258:3b395ab8784d | 259:35dc06030355 |
---|---|
77 throw new RequiredDataMissingException(file.Name, "Unit Type", unitTypeId); | 77 throw new RequiredDataMissingException(file.Name, "Unit Type", unitTypeId); |
78 } | 78 } |
79 | 79 |
80 string name = unitElem.GetAttribute("unitName"); | 80 string name = unitElem.GetAttribute("unitName"); |
81 int size = XmlTools.GetIntValueFromAttribute(unitElem, "size"); | 81 int size = XmlTools.GetIntValueFromAttribute(unitElem, "size"); |
82 | |
83 string catID = unitElem.GetAttribute("category"); | |
84 Category cat = army.Race.GetCategory(catID); | |
85 | |
86 if (cat == null) | |
87 { | |
88 cat = unitType.MainCategory; | |
89 } | |
82 | 90 |
83 Unit unit = new Unit(id, name, size, unitType, army.GetCategory(unitType.MainCategory)); | 91 Unit unit = new Unit(id, name, size, unitType, army.GetCategory(cat)); |
84 army.AddUnit(unit); | 92 army.AddUnit(unit, cat); |
85 units.Add(id, unit); | 93 units.Add(id, unit); |
86 | 94 |
87 LoadUnitEquipment(unitElem, unit); | 95 LoadUnitEquipment(unitElem, unit); |
88 } | 96 } |
89 else | 97 else |