Mercurial > repos > IBBoard.WarFoundry.API
changeset 119:0cdc0b07fe11
Re #54: Add army loading
* Add unit to army once it is loaded
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 23 Aug 2009 10:32:09 +0000 |
parents | d39de20f2ba1 |
children | fcbc3beea498 |
files | api/Factories/Xml/WarFoundryXmlArmyParser.cs |
diffstat | 1 files changed, 5 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/api/Factories/Xml/WarFoundryXmlArmyParser.cs Sun Aug 23 10:28:03 2009 +0000 +++ b/api/Factories/Xml/WarFoundryXmlArmyParser.cs Sun Aug 23 10:32:09 2009 +0000 @@ -65,9 +65,8 @@ foreach (XmlElement unitElem in WarFoundryXmlFactoryUtils.SelectNodes(elem, "/army:army/army:units/army:unit")) { string id = unitElem.GetAttribute("id"); - Unit unit = DictionaryUtils.GetValue(units, id); - if (unit == null) + if (!units.ContainsKey(id)) { string unitTypeId = unitElem.GetAttribute("unitType"); UnitType unitType = army.Race.GetUnitType(unitTypeId); @@ -77,8 +76,11 @@ throw new RequiredDataMissingException(file.Name, "unitType", unitTypeId); } - unit = new Unit(unitType, army.GetCategory(unitType.MainCategory)); + Unit unit = new Unit(unitType, army.GetCategory(unitType.MainCategory)); + army.AddUnit(unit); units.Add(id, unit); + + //LoadUnitEquipment( } } }