コード例 #1
0
        private static void GenerateDevices(string directory)
        {
            var cyphersFileName = Path.Combine(directory, "Cyphers_AllSources.xml");
            var cyphersList     = NumeneraXML.DeserializeCyphersListFromXML(cyphersFileName);

            Console.WriteLine("Cyphers loaded: " + cyphersList.Count);

            var artefactsFileName = Path.Combine(directory, "Artefacts_AllSources.xml");
            var artefactsList     = NumeneraXML.DeserializeArtefactsListFromXML(artefactsFileName);

            Console.WriteLine("Artefacts loaded: " + artefactsList.Count);

            var odditiesFilename = Path.Combine(directory, "Oddities_AllSources.xml");
            var odditiesList     = NumeneraXML.DeserializeOdditiesListFromXML(odditiesFilename);

            Console.WriteLine("Oddities loaded: " + odditiesList.Count);

            var rand = new Random(Guid.NewGuid().GetHashCode());
            int randomIndex = 0, diceRandom = 1;

            ConsoleKeyInfo c = new ConsoleKeyInfo();

            // TODO: D6/D10 random
            // TODO: Calculate final level automatically
            // TODO: RollTable Random (find maximum number in the last element)
            // TODO: Owerwrite ToString() specific to device? Or create custom output for each device?
            while (c.Key != ConsoleKey.Escape)
            {
                Console.WriteLine("******** Choose device to generate: 1 - Cypher; 2 - Artefact; 3 - Oddity;");
                c = Console.ReadKey(true);
                switch (c.KeyChar)
                {
                case '1':
                    Console.WriteLine($"Generating from {cyphersList.Count} cyphers\n");
                    randomIndex = rand.Next(cyphersList.Count);
                    diceRandom  = rand.Next(1, 6);
                    var device = cyphersList[randomIndex];
                    //device.Level += $" [D6 = {diceRandom}]";
                    Console.WriteLine(device.ToString());
                    break;

                case '2':
                    Console.WriteLine($"Generatring from {artefactsList.Count} artefacts\n");
                    randomIndex = rand.Next(artefactsList.Count);
                    diceRandom  = rand.Next(1, 6);
                    artefactsList[randomIndex].Level += $" [D6 = {diceRandom}]";
                    Console.WriteLine(artefactsList[randomIndex].ToString());
                    break;

                case '3':
                    Console.WriteLine($"Generating from {odditiesList.Count} oddities\n");
                    randomIndex = rand.Next(odditiesList.Count);
                    Console.WriteLine(odditiesList[randomIndex].ToString());
                    break;
                }
            }
        }
コード例 #2
0
        public static void ParseArtefactsToXML()
        {
            var directory    = @"E:\Documents\Tabletop RPGs\Numenera\APPs\Artefacts\";
            var name         = "RAW_Artefacts_Compendium.txt";
            var fileName     = Path.Combine(directory, name);
            var fileNameXml  = fileName + "_xml.xml";
            var deviceParser = new DevicesParser("Compendium", DeviceType.Artefact);

            deviceParser.CreateXMLFromRawArtefactsText(fileName, fileNameXml);
            var cyphers = NumeneraXML.DeserializeArtefactsListFromXML(fileNameXml);

            cyphers.ForEach(x => Console.WriteLine(x));
        }
コード例 #3
0
        public void TestPDFParsing_Artefacts()
        {
            var directory    = @"..\..\..\ExampleFiles";
            var name         = "Test_Artefacts.txt";
            var fileName     = Path.Combine(directory, name);
            var fileNameXml  = Path.Combine(directory, Path.GetFileNameWithoutExtension(fileName) + ".xml");
            var deviceParser = new DevicesParser("Discovery", DeviceType.Artefact);

            deviceParser.CreateXMLFromRawArtefactsText(fileName, fileNameXml);
            var artefacts = NumeneraXML.DeserializeArtefactsListFromXML(fileNameXml);

            System.Diagnostics.Debug.WriteLine(artefacts[0].Name);
            artefacts.Should().BeEquivalentTo(ArtefactsExample.List);
            //artefacts[1].Should().BeEquivalentTo(ArtefactsExample.List[1]);
        }
コード例 #4
0
        public static void CombineAllArtefacts()
        {
            // combine them all
            var directory = @"E:\Documents\Tabletop RPGs\Numenera\NumeneraAppFiles\Devices\Artefacts_";
            var files     = new List <string>()
            {
                "Discovery.xml", "Destiny.xml", "Compendium.xml"
            };

            var allArtefacts = new List <Artefact>();

            foreach (var file in files)
            {
                var filename  = directory + file;
                var artefacts = NumeneraXML.DeserializeArtefactsListFromXML(filename);
                NumeneraXML.SerializeToXml(artefacts, directory + $"{artefacts[0].Source}_fixed.xml");
                allArtefacts.AddRange(artefacts);
            }

            var artefactsToSerialize = new NumeneraDevices(allArtefacts);

            NumeneraXML.SerializeToXml(artefactsToSerialize.Artefacts, directory + $"AllSources_{artefactsToSerialize.Artefacts.Count}.xml");
        }