changeset 0:c387d9f011a4

Initial commit of WarFoundry code
author IBBoard <dev@ibboard.co.uk>
date Fri, 19 Dec 2008 15:57:51 +0000
parents
children d3e0e2914400
files AssemblyInfo.cs IBBoard.WarFoundry.Plugin.Rollcall.mdp IBBoard.WarFoundry.Plugin.Rollcall.pidb RollcallFactory.cs
diffstat 4 files changed, 230 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/AssemblyInfo.cs	Fri Dec 19 15:57:51 2008 +0000
@@ -0,0 +1,44 @@
+// AssemblyInfo.cs
+//
+//  Copyright (C) 2008 IBBoard
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
+//
+//
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following attributes. 
+// Change them to the values specific to your project.
+
+[assembly: AssemblyTitle("IBBoard.WarFoundry.Plugin.Rollcall")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// If the build and revision are set to '*' they will be updated automatically.
+
+[assembly: AssemblyVersion("1.0.*.*")]
+
+// The following attributes are used to specify the signing key for the assembly, 
+// if desired. See the Mono documentation for more information about signing.
+
+[assembly: AssemblyDelaySign(false)]
+[assembly: AssemblyKeyFile("")]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/IBBoard.WarFoundry.Plugin.Rollcall.mdp	Fri Dec 19 15:57:51 2008 +0000
@@ -0,0 +1,25 @@
+<Project name="IBBoard.WarFoundry.Plugin.Rollcall" fileversion="2.0" DefaultNamespace="IBBoard.WarFoundry.Plugin.Rollcall" language="C#" clr-version="Net_2_0" ctype="DotNetProject">
+  <Configurations active="Debug">
+    <Configuration name="Debug" ctype="DotNetProjectConfiguration">
+      <Output directory="bin/Debug" assembly="IBBoard.WarFoundry.Plugin.Rollcall" />
+      <Build debugmode="True" target="Library" />
+      <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_2_0" />
+      <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" definesymbols="DEBUG" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
+    </Configuration>
+    <Configuration name="Release" ctype="DotNetProjectConfiguration">
+      <Output directory="bin/Release" assembly="IBBoard.WarFoundry.Plugin.Rollcall" />
+      <Build debugmode="False" target="Library" />
+      <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_2_0" />
+      <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
+    </Configuration>
+  </Configurations>
+  <Contents>
+    <File name="AssemblyInfo.cs" subtype="Code" buildaction="Compile" />
+    <File name="RollcallFactory.cs" subtype="Code" buildaction="Compile" />
+  </Contents>
+  <References>
+    <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+    <ProjectReference type="Project" localcopy="True" refto="IBBoard.WarFoundry.API" />
+    <ProjectReference type="Project" localcopy="True" refto="IBBoard" />
+  </References>
+</Project>
\ No newline at end of file
Binary file IBBoard.WarFoundry.Plugin.Rollcall.pidb has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RollcallFactory.cs	Fri Dec 19 15:57:51 2008 +0000
@@ -0,0 +1,161 @@
+// RollcallFactory.cs
+//
+//  Copyright (C) 2008 IBBoard
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
+//
+//
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using IBBoard.Logging;
+using IBBoard.WarFoundry.API.Factories;
+using IBBoard.WarFoundry.API.Objects;
+
+namespace IBBoard.WarFoundry.Plugin.Rollcall
+{
+	public class RollcallFactory : AbstractNonNativeFileExtensionWarFoundryFactory
+	{
+		public static RollcallFactory CreateFactory()
+		{
+			return new RollcallFactory();
+		}
+		
+		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"; }
+		}
+		
+		protected override ICollection<IWarFoundryObject> DoCreateObjectsFromFile(FileInfo file)
+		{			
+			ICollection<IWarFoundryObject> objects = null;
+			IWarFoundryObject obj = null;
+			
+			if (IsRaceFile(file))
+			{
+				obj = CreateRaceFromFile(file);
+			}
+			else if (IsArmyFile(file))
+			{
+				obj = CreateArmyFromFile(file);
+			}
+			
+			if (obj != null)
+			{
+				objects = new List<IWarFoundryObject>();
+				objects.Add(obj);
+				objects.Add(new GameSystem("Rollcall", "Rollcall armies"));
+			}
+			
+			return objects;
+		}
+
+		protected override Army CreateArmyFromFile (FileInfo file)
+		{			
+			return null;
+		}
+		
+		protected override Race CreateRaceFromFile(FileInfo file)
+		{
+			//TODO parse army file
+			StreamReader stream = file.OpenText();
+			string id = null, name = null;
+			
+			while (!stream.EndOfStream)
+			{
+				string line = stream.ReadLine();
+				
+				if (line.StartsWith("["))
+				{					
+					string sectionTitle = line.Trim().Substring(1, line.Length - 2);
+					string sectionTitleLower = sectionTitle.ToLower();
+					
+					if (sectionTitleLower.Equals("army"))
+					{
+						ReadRaceSection(stream, out id, out name);
+					}
+					else if (sectionTitleLower.Equals("category"))
+					{
+						ReadCategorySection(stream);
+					}
+					else if (sectionTitleLower.StartsWith("unit"))
+					{
+						ReadUnitSection(stream, sectionTitle);
+					}
+					else
+					{
+						ReadEquipmentSection(stream, sectionTitle);
+					}
+				}				
+				//else ignore the line
+			}
+			
+			LogNotifier.Debug(GetType(), "Loaded race ID "+id);
+			return new Race(id, name, "Rollcall");
+		}
+
+		private void ReadRaceSection(StreamReader stream, out string id, out string name)
+		{
+			id = name = null;
+			
+			while (!stream.EndOfStream && stream.Peek() != '[')
+			{
+				string line = stream.ReadLine();
+				
+				if (line.StartsWith("BitCodeID="))
+				{
+					id = line.Substring(10);
+				}
+				else if (line.StartsWith("Name="))
+				{
+					name = line.Substring(5);
+				}
+			}
+		}
+		
+		private void ReadCategorySection(StreamReader stream)
+		{
+		}
+		
+		private void ReadUnitSection(StreamReader stream, string unitSectionTitle)
+		{
+		}
+		
+		private void ReadEquipmentSection(StreamReader stream, string equipmentSectionTitle)
+		{
+		}
+		
+		protected override GameSystem CreateGameSystemFromFile (FileInfo file)
+		{
+			//Return null because there is no such thing
+			//TODO Check whether we should exception
+			return null;
+		}
+	}
+}