Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 33 additions & 13 deletions EngineTests/GameData/SaveTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,24 +278,44 @@ public void LoadAllConquestScenarios() {
string is_on_github = System.Environment.GetEnvironmentVariable("CI");
if (is_on_github != null) { return; }

string[] singleplayerScenarios = {
"1 Mesopotamia.biq",
"2 Rise of Rome.biq",
"3 Fall of Rome.biq",
"4 Middle Ages.biq",
"5 Mesoamerica.biq",
"6 Age of Discovery.biq",
// skip for now because BIQ parsing fails
// "7 Sengoku - Sword of the Shogun.biq",
"8 Napoleonic Europe.biq",
"9 WWII in the Pacific.biq",
};
string[] multiplayerScenarios = {
"1 MP Mesopotamia.biq",
"2 MP Rise of Rome.biq",
"3 MP Fall of Rome.biq",
"4 MP Middle Ages.biq",
"5 MP Mesoamerica.biq",
"6 MP Age of Discovery.biq",
// skip for now because BIQ parsing fails
// "7 MP Sengoku - Sword of the Shogun.biq",
"8 MP Napoleonic Europe.biq",
"9 MP WWII in the Pacific.biq",
};
// Only bother running one turn of the newer scenarios, just to keep the
// tests faster.
CheckScenariosInCiv3Subfolder("Conquests/Conquests", runOneTurn: true);
CheckScenariosInCiv3Subfolder("Conquests/Scenarios", runOneTurn: false);
CheckScenariosInCiv3Subfolder("Conquests/Conquests", singleplayerScenarios, runOneTurn: true, "singleplayer");
CheckScenariosInCiv3Subfolder("Conquests/Scenarios", multiplayerScenarios, runOneTurn: false, "multiplayer");
}

private void CheckScenariosInCiv3Subfolder(string subfolder, bool runOneTurn) {
private void CheckScenariosInCiv3Subfolder(string subfolder, string[] scenarioNamesToTest, bool runOneTurn, string basename) {
string conquests = Path.Join(Civ3Location.GetCiv3Path(), subfolder);
DirectoryInfo directoryInfo = new DirectoryInfo(conquests);
IEnumerable<FileInfo> saveFiles = directoryInfo.EnumerateFiles().Where(fi => {
// currently only test 1 Mesopotamia.biq -> 9 WWII in the Pacific.biq:
int prefix = fi.Name[0];
if (prefix == '7') {
// skip 7 Sengoku - Sword of the Shogun.biq for now because biq parsing fails
return false;
}
return fi.Extension.EndsWith(".biq", true, null) && char.IsAsciiDigit(fi.Name[0]);
});
IEnumerable<FileInfo> saveFiles = directoryInfo.EnumerateFiles().Where(fi => scenarioNamesToTest.Contains(fi.Name));
Assert.True(
scenarioNamesToTest.Count() == saveFiles.Count(),
$"Expected {scenarioNamesToTest.Count()} files but got {saveFiles.Count()}"
);
foreach (FileInfo saveFileInfo in saveFiles) {
string name = saveFileInfo.Name;
SaveGame game = null;
Expand Down Expand Up @@ -367,7 +387,7 @@ private void CheckScenariosInCiv3Subfolder(string subfolder, bool runOneTurn) {
}
}

game.Save(Path.Combine(testDirectory, "data", "output", $"conquest_{name[0]}.json"));
game.Save(Path.Combine(testDirectory, "data", "output", $"{basename}_{name[0]}.json"));

// Finally, ensure we can run the first turn of the scenario.
if (runOneTurn) {
Expand Down