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 diff
     1.1 --- a/api/Factories/Xml/WarFoundryXmlArmyParser.cs	Sun Aug 23 10:28:03 2009 +0000
     1.2 +++ b/api/Factories/Xml/WarFoundryXmlArmyParser.cs	Sun Aug 23 10:32:09 2009 +0000
     1.3 @@ -65,9 +65,8 @@
     1.4  			foreach (XmlElement unitElem in WarFoundryXmlFactoryUtils.SelectNodes(elem, "/army:army/army:units/army:unit"))
     1.5  			{
     1.6  				string id = unitElem.GetAttribute("id");
     1.7 -				Unit unit = DictionaryUtils.GetValue(units, id);
     1.8  
     1.9 -				if (unit == null)
    1.10 +				if (!units.ContainsKey(id))
    1.11  				{
    1.12  					string unitTypeId = unitElem.GetAttribute("unitType");
    1.13  					UnitType unitType = army.Race.GetUnitType(unitTypeId);
    1.14 @@ -77,8 +76,11 @@
    1.15  						throw new RequiredDataMissingException(file.Name, "unitType", unitTypeId);
    1.16  					}
    1.17  
    1.18 -					unit = new Unit(unitType, army.GetCategory(unitType.MainCategory));
    1.19 +					Unit unit = new Unit(unitType, army.GetCategory(unitType.MainCategory));
    1.20 +					army.AddUnit(unit);
    1.21  					units.Add(id, unit);
    1.22 +
    1.23 +					//LoadUnitEquipment(
    1.24  				}
    1.25  			}
    1.26  		}