Mercurial > repos > IBBoard.WarFoundry.Plugin.Rollcall
view RollcallFactory.cs @ 14:f7582a3c8bdf default tip
* Fix tooling version - we're 2.0 compatible, not 3.5
no-open-ticket
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 26 Jan 2011 20:04:35 +0000 |
parents | 9aecf6628eb0 |
children |
line wrap: on
line source
// This file (RollcallFactory.cs) is a part of the IBBoard.WarFoundry.Plugin.Rollcall project and is copyright 2008, 2009 IBBoard. // // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING 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; 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 (objects.Count > 0) { objects.Add(RollcallSystem); } 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)"); } } }