Mercurial > repos > IBDev-IBBoard.WarFoundry.API
comparison api/Factories/Xml/WarFoundryXmlArmyFactory.cs @ 52:64ef178c18aa
Re #10 - Refactor for readability
* Break WarFoundryXMLFactory out in to GameSystem, Race and Army factories
* Create factory utils classes with methods from WarFoundryXMLFactory for getting node lists etc
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 30 Mar 2009 19:44:03 +0000 |
parents | |
children | 2f3cafb69799 |
comparison
equal
deleted
inserted
replaced
51:b271a2252758 | 52:64ef178c18aa |
---|---|
1 // This file (WarFoundryXmlArmyFactory.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard | |
2 // | |
3 // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license. | |
4 // | |
5 | |
6 using System; | |
7 using System.Xml; | |
8 using IBBoard.Xml; | |
9 using ICSharpCode.SharpZipLib.Zip; | |
10 using IBBoard.WarFoundry.API.Objects; | |
11 | |
12 namespace IBBoard.WarFoundry.API.Factories.Xml | |
13 { | |
14 /// <summary> | |
15 /// A sub-factory for loading WarFoundry Army XML files | |
16 /// </summary> | |
17 public class WarFoundryXmlArmyFactory | |
18 { | |
19 public Army CreateArmyFromElement(ZipFile file, XmlElement elem) | |
20 { | |
21 string name = elem.GetAttribute("name"); | |
22 string systemID = elem.GetAttribute("gameSystem"); | |
23 GameSystem system = WarFoundryLoader.GetDefault().GetGameSystem(systemID); | |
24 string raceID = elem.GetAttribute("race"); | |
25 Race race = WarFoundryLoader.GetDefault().GetRace(system, raceID); | |
26 int points = XmlTools.GetIntValueFromAttribute(elem, "maxPoints"); | |
27 Army army = new Army(race, name, points, file); | |
28 //TODO: Complete loading of army | |
29 return army; | |
30 } | |
31 } | |
32 } |