Mercurial > repos > IBBoard.WarFoundry.Plugin.Rollcall
view RollcallFactory.cs @ 8:35bc86f8c283
Re #17 - Load unit data
* Parse more attributes including troop cost
* Improve handling of required values
* Refactor code in to generic parent
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 21 Feb 2009 21:00:52 +0000 |
parents | 0509ed2e686a |
children | 4971e5d16653 |
line wrap: on
line source
// This file (RollcallFactory.cs) is a part of the IBBoard.WarFoundry.Plugin.Rollcall 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.Collections.Generic; using System.IO; using IBBoard.Ini; using IBBoard.IO; using IBBoard.Logging; using IBBoard.WarFoundry.API.Factories; using IBBoard.WarFoundry.API.Objects; namespace IBBoard.WarFoundry.Plugin.Rollcall { public class RollcallFactory : AbstractNonNativeFileExtensionWarFoundryFactory { private static RollcallFactory factory; private GameSystem rollcallSystem; private bool addedSystem = false; public static RollcallFactory GetFactory() { if (factory == null) { factory = new RollcallFactory(); } return factory; } private RollcallFactory() { rollcallSystem = new GameSystem("Rollcall", "Rollcall armies", this); } public override string NonNativeDataType { get { return "Rollcall ADF files"; } } protected override string ArmyFileExtension { get { return null; } } protected override string GameSystemFileExtension { get { return null; } } protected override string RaceFileExtension { get { return ".adf"; } } public GameSystem RollcallSystem { get { return rollcallSystem; } } protected override ICollection<IWarFoundryObject> DoCreateObjectsFromFile(FileInfo file) { ICollection<IWarFoundryObject> objects = base.DoCreateObjectsFromFile(file); if (!addedSystem && objects.Count > 0) { objects.Add(RollcallSystem); addedSystem = true; } return objects; } protected override Army CreateArmyFromFile (FileInfo file) { throw new NotImplementedException(); } protected override Race CreateRaceFromFile(FileInfo file) { IniFile rollcallFile = IniFileReader.ReadFile(file); Race race = RollcallRaceParser.ReadRaceDetails(rollcallFile); RollcallRaceParser.ReadCategories(rollcallFile, race); RollcallRaceParser.ReadUnitTypeAndEquipmentSections(rollcallFile, race); return race; } protected override GameSystem CreateGameSystemFromFile (FileInfo file) { throw new InvalidDataException("No such file format (Rollcall GameSystem)"); } } }