Skip to content

Commit

Permalink
Disable TFE game start struggles (#1734)
Browse files Browse the repository at this point in the history
  • Loading branch information
IhateTrains authored Jan 27, 2024
1 parent b807ac8 commit 6d7589a
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 14 deletions.
50 changes: 49 additions & 1 deletion ImperatorToCK3/Outputter/OnActionOutputter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using commonItems;
using commonItems.Collections;
using commonItems.Mods;
using ImperatorToCK3.CommonUtils;
using System.IO;
using System.Text;

Expand Down Expand Up @@ -53,4 +56,49 @@ public static void DisableUnneededFallenEagleOnActions(string outputModName) {
writer.WriteLine("# disabled by IRToCK3");
}
}
}

public static void RemoveStruggleStartFromFallenEagleOnActions(ModFilesystem ck3ModFS, string outputModName) {
var inputPath = ck3ModFS.GetActualFileLocation("common/on_action/TFE_game_start.txt");
if (!File.Exists(inputPath)) {
Logger.Debug("TFE_game_start.txt not found.");
return;
}
var fileContent = File.ReadAllText(inputPath);

// List of blocks to remove as of 2024-01-07.
string[] struggleStartBlocksToRemove = [
"""
if = {
limit = {
AND = {
game_start_date >= 476.9.4
game_start_date <= 768.1.1
}
}
start_struggle = { struggle_type = britannia_struggle start_phase = struggle_britannia_phase_migration }
}
""",
"""
if = {
limit = {
AND = {
game_start_date <= 651.1.1 # Death of Yazdegerd III
}
}
start_struggle = { struggle_type = roman_persian_struggle start_phase = struggle_TFE_roman_persian_phase_contention }
}
start_struggle = { struggle_type = eastern_iranian_struggle start_phase = struggle_TFE_eastern_iranian_phase_expansion }
start_struggle = { struggle_type = north_indian_struggle start_phase = struggle_TFE_north_indian_phase_invasion }
""",
];

foreach (var block in struggleStartBlocksToRemove) {
fileContent = fileContent.Replace(block, "");
}


var outputPath = $"output/{outputModName}/common/on_action/TFE_game_start.txt";
using var output = FileOpeningHelper.OpenWriteWithRetries(outputPath);
output.Write(fileContent);
}
}
31 changes: 18 additions & 13 deletions ImperatorToCK3/Outputter/WorldOutputter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public static void OutputWorld(World ck3World, Imperator.World imperatorWorld, C
CreateModFolder(outputName);
OutputModFile(outputName);

Logger.Info("Creating folders...");
CreateFolders(outputName);
Logger.IncrementProgress();

Expand All @@ -39,7 +38,7 @@ public static void OutputWorld(World ck3World, Imperator.World imperatorWorld, C
ck3World.LandedTitles
);
Logger.IncrementProgress();

PillarOutputter.OutputPillars(outputName, ck3World.CulturalPillars);
CulturesOutputter.OutputCultures(outputName, ck3World.Cultures);

Expand All @@ -61,12 +60,15 @@ public static void OutputWorld(World ck3World, Imperator.World imperatorWorld, C
ck3World
);
Logger.IncrementProgress();

Logger.Info("Writing game start on-action...");
OnActionOutputter.OutputCustomGameStartOnAction(config);
if (config.FallenEagleEnabled) {
Logger.Info("Disabling unneeded Fallen Eagle on-actions...");
OnActionOutputter.DisableUnneededFallenEagleOnActions(config.OutputModName);

Logger.Info("Removing struggle start from Fallen Eagle on-actions...");
OnActionOutputter.RemoveStruggleStartFromFallenEagleOnActions(ck3World.ModFS, config.OutputModName);
}
Logger.IncrementProgress();

Expand All @@ -76,6 +78,8 @@ public static void OutputWorld(World ck3World, Imperator.World imperatorWorld, C

var outputPath = Path.Combine("output", config.OutputModName);

WriteDummyStruggleHistory(outputPath);

NamedColorsOutputter.OutputNamedColors(outputName, imperatorWorld.NamedColors, ck3World.NamedColors);

CoatOfArmsEmblemsOutputter.CopyEmblems(config, imperatorWorld.ModFS);
Expand All @@ -89,6 +93,13 @@ public static void OutputWorld(World ck3World, Imperator.World imperatorWorld, C
OutputPlaysetInfo(ck3World, outputName);
}

private static void WriteDummyStruggleHistory(string outputPath) {
Logger.Info("Writing dummy struggles history file...");
// Just to make sure the history/struggles folder exists.
string struggleDummyPath = Path.Combine(outputPath, "history/struggles/IRToCK3_dummy.txt");
File.WriteAllText(struggleDummyPath, string.Empty, Encoding.UTF8);
}

private static void CopyBlankModFilesToOutput(string outputPath) {
Logger.Info("Copying blankMod files to output...");
SystemUtils.TryCopyFolder(
Expand Down Expand Up @@ -147,6 +158,7 @@ private static void OutputModFile(string outputName) {
modFileBuilder.AppendLine("replace_path=\"history/characters\"");
modFileBuilder.AppendLine("replace_path=\"history/province_mapping\"");
modFileBuilder.AppendLine("replace_path=\"history/provinces\"");
modFileBuilder.AppendLine("replace_path=\"history/struggles\"");
modFileBuilder.AppendLine("replace_path=\"history/titles\"");
modFileBuilder.AppendLine("replace_path=\"history/wars\"");
var modText = modFileBuilder.ToString();
Expand All @@ -163,22 +175,20 @@ private static void CreateModFolder(string outputName) {
}

private static void CreateFolders(string outputName) {
Logger.Info("Creating folders...");

var outputPath = Path.Combine("output", outputName);

SystemUtils.TryCreateFolder(Path.Combine(outputPath, "history"));
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "history", "titles"));
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "history", "characters"));
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "history", "provinces"));
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "history", "province_mapping"));
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "history", "struggles"));
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "history", "wars"));
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "common"));
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "common", "bookmarks"));
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "common", "bookmarks", "bookmarks"));
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "common", "bookmarks", "groups"));
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "common", "bookmark_portraits"));
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "common", "coat_of_arms"));
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "common", "coat_of_arms", "coat_of_arms"));
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "common", "culture"));
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "common", "culture", "cultures"));
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "common", "culture", "pillars"));
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "common", "dna_data"));
Expand All @@ -187,7 +197,6 @@ private static void CreateFolders(string outputName) {
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "common", "men_at_arms_types"));
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "common", "named_colors"));
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "common", "on_action"));
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "common", "religion"));
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "common", "religion", "holy_sites"));
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "common", "religion", "religions"));
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "common", "scripted_triggers"));
Expand All @@ -199,14 +208,10 @@ private static void CreateFolders(string outputName) {
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "localization", language));
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "localization", "replace", language));
}
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "gfx"));
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "gfx", "coat_of_arms"));
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "gfx", "coat_of_arms", "colored_emblems"));
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "gfx", "coat_of_arms", "patterns"));
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "gfx", "coat_of_arms", "textured_emblems"));
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "gfx", "interface"));
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "gfx", "interface", "bookmarks"));
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "gfx", "portraits"));
SystemUtils.TryCreateFolder(Path.Combine(outputPath, "gfx", "portraits", "portrait_modifiers"));
}

Expand Down

0 comments on commit 6d7589a

Please sign in to comment.