comparison api/Factories/Xml/WarFoundryXmlArmyFactory.cs @ 116:2010a7e8bf9a

Re #54: Add Army support to WarFoundryFactory * Separate out army parsing to a separate class to make unit loading easier
author IBBoard <dev@ibboard.co.uk>
date Sat, 22 Aug 2009 19:42:04 +0000
parents 5ebbffd4a05f
children
comparison
equal deleted inserted replaced
115:d0c60b3204c1 116:2010a7e8bf9a
15 /// </summary> 15 /// </summary>
16 public class WarFoundryXmlArmyFactory 16 public class WarFoundryXmlArmyFactory
17 { 17 {
18 public Army CreateArmyFromElement(ZipFile file, XmlElement elem) 18 public Army CreateArmyFromElement(ZipFile file, XmlElement elem)
19 { 19 {
20 string name = elem.GetAttribute("name"); 20 return new WarFoundryXmlArmyParser(file, elem).GetArmy();
21 string systemID = elem.GetAttribute("system");
22 GameSystem system = WarFoundryLoader.GetDefault().GetGameSystem(systemID);
23
24 if (system == null)
25 {
26 throw new RequiredDataMissingException(file.Name, "gameSystem", systemID);
27 }
28
29 string raceID = elem.GetAttribute("race");
30 Race race = WarFoundryLoader.GetDefault().GetRace(system, raceID);
31
32 if (race == null)
33 {
34 throw new RequiredDataMissingException(file.Name, "race", raceID);
35 }
36
37 int points = XmlTools.GetIntValueFromAttribute(elem, "maxPoints");
38 Army army = new Army(race, name, points, file);
39 //TODO: Complete loading of army
40 return army;
41 } 21 }
42 } 22 }
43 } 23 }