Ejemplo n.º 1
0
    public static void OutputTitles(string outputModName, Title.LandedTitles titles, IMPERATOR_DE_JURE deJure)
    {
        var outputPath = Path.Combine("output", outputModName, "common", "landed_titles", "00_landed_titles.txt");

        using var outputStream = File.OpenWrite(outputPath);
        using var output       = new StreamWriter(outputStream, System.Text.Encoding.UTF8);

        foreach (var(name, value) in titles.Variables)
        {
            output.WriteLine($"@{name}={value}");
        }

        // titles with a de jure liege will be outputted under the liege
        var topDeJureTitles = titles.Where(t => t.DeJureLiege is null);

        output.Write(PDXSerializer.Serialize(topDeJureTitles, string.Empty, false));

        if (deJure == IMPERATOR_DE_JURE.REGIONS)
        {
            var srcPath = Path.Combine("blankMod", "optionalFiles", "ImperatorDeJure", "common", "landed_titles");
            var dstPath = Path.Combine("output", outputModName, "common", "landed_titles");
            if (!SystemUtils.TryCopyFolder(srcPath, dstPath))
            {
                Logger.Error("Could not copy ImperatorDeJure landed titles!");
            }
        }

        OutputTitlesHistory(outputModName, titles);
    }
Ejemplo n.º 2
0
    public static void OutputDynasties(string outputModName, DynastyCollection dynasties)
    {
        var outputPath = Path.Combine("output", outputModName, "common", "dynasties", "imp_dynasties.txt");

        using FileStream stream = File.OpenWrite(outputPath);
        using var output        = new StreamWriter(stream, encoding: Encoding.UTF8);  // dumping all into one file
        foreach (var dynasty in dynasties)
        {
            output.WriteLine($"{dynasty.Id}={PDXSerializer.Serialize(dynasty, string.Empty)}");
        }
    }
Ejemplo n.º 3
0
        public void IntegersAreSerializedWithoutQuotes()
        {
            var fields = new Dictionary <string, HistoryField> {
                { "development_level", new HistoryField("change_development_level", 10) }
            };
            var history = new History(fields);

            history.Fields["development_level"].AddValueToHistory(20, new Date(5, 1, 1));

            var expectedStr =
                "change_development_level=10" + Environment.NewLine +
                "5.1.1={" + Environment.NewLine +
                "\tchange_development_level=20" + Environment.NewLine +
                "}" + Environment.NewLine;

            Assert.Equal(expectedStr, PDXSerializer.Serialize(history));
        }
Ejemplo n.º 4
0
        public void EmptyListInitialValuesAreNotSerialized()
        {
            var fields = new Dictionary <string, HistoryField> {
                { "buildings", new HistoryField("buildings", new List <object>()) }              // container field initially empty
            };
            var history = new History(fields);

            history.Fields["buildings"].AddValueToHistory(new List <object> {
                "baths"
            }, new Date(5, 1, 1));

            var expectedStr =
                "5.1.1={" + Environment.NewLine +
                "\tbuildings={ \"baths\" }" + Environment.NewLine +
                "}" + Environment.NewLine;

            Assert.Equal(expectedStr, PDXSerializer.Serialize(history));
        }
Ejemplo n.º 5
0
        public void HistoryCanBeSerialized()
        {
            var fields = new Dictionary <string, HistoryField> {
                { "holder", new HistoryField("holder", null) },               // simple field with null initial value
                { "culture", new HistoryField("culture", "roman") },          // simple field with initial value
                { "buildings", new HistoryField("buildings", new List <object> {
                        "baths"
                    }) }                                                                                 // container field
            };
            var history = new History(fields);

            history.Fields["holder"].AddValueToHistory("nero", new Date(5, 1, 1));

            // Entries with same date should be added to a single date block.
            history.Fields["holder"].AddValueToHistory("justinian", new Date(540, 1, 1));
            history.Fields["culture"].AddValueToHistory("better_roman", new Date(540, 1, 1));

            // A field can have values of multiple types.
            // Here we're adding a value as a set, while the initial value is a list.
            history.Fields["buildings"].AddValueToHistory(new SortedSet <string> {
                "aqueduct", "baths"
            }, new Date(2, 1, 1));

            // Date blocks are ordered by date.
            var expectedStr =
                "culture=\"roman\"" + Environment.NewLine +
                "buildings={ \"baths\" }" + Environment.NewLine +
                "2.1.1={" + Environment.NewLine +
                "\tbuildings={ \"aqueduct\" \"baths\" }" + Environment.NewLine +
                "}" + Environment.NewLine +
                "5.1.1={" + Environment.NewLine +
                "\tholder=\"nero\"" + Environment.NewLine +
                "}" + Environment.NewLine +
                "540.1.1={" + Environment.NewLine +
                "\tholder=\"justinian\"" + Environment.NewLine +
                "\tculture=\"better_roman\"" + Environment.NewLine +
                "}" + Environment.NewLine;

            Assert.Equal(expectedStr, PDXSerializer.Serialize(history));
        }