view api/Factories/Xml/AbstractStagedLoadedSubFactory.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
line wrap: on
line source

//  This file (AbstractStagedLoadedSubFactory.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard
// 
//  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.
// 

using System;
using System.Xml;
using IBBoard.Xml;
using IBBoard.WarFoundry.API.Objects;

namespace IBBoard.WarFoundry.API.Factories.Xml
{
	public class AbstractStagedLoadedSubFactory
	{
		protected WarFoundryXmlFactory mainFactory;
		
		protected AbstractStagedLoadedSubFactory(WarFoundryXmlFactory factory)
		{
			mainFactory = factory;
		}
		
		protected Category CreateCategoryFromElement(XmlElement elem)
		{
			string id = elem.GetAttribute("id");
			string name = elem.GetAttribute("name");
			Category cat = new Category(id, name);
			cat.MaximumPercentage = XmlTools.GetIntValueFromAttribute(elem, "maxPercentage");
			cat.MinimumPercentage = XmlTools.GetIntValueFromAttribute(elem, "minPercentage");
			cat.MaximumPoints = XmlTools.GetIntValueFromAttribute(elem, "maxPoints");
			cat.MinimumPoints = XmlTools.GetIntValueFromAttribute(elem, "minPoints");
			return cat;
		}	
	}
}