-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Like the title says.
I have implemented this in a private fork of ISM and tested it out, and it works fine.
Alterations for Converter.cs:
public int Year { get; set; }
public List<string> GetAllFactions()
{
// Validate that the year is within an acceptable range
if (Year < 0)
{
throw new ArgumentOutOfRangeException("Year must be non-negative.");
}
// Define the path to the JSON file
string filePath = "factions-by-year.json";
// Validate that the file exists
if (!File.Exists(filePath))
{
throw new FileNotFoundException($"The file '{filePath}' does not exist.");
}
// Load the JSON data from the file
var jsonData = File.ReadAllText(filePath);
// Parse the JSON into a dictionary
var factionsByYear = JsonConvert.DeserializeObject<Dictionary<int, List<string>>>(jsonData);
// Validate that the JSON was successfully parsed
if (factionsByYear == null)
{
throw new InvalidOperationException("Failed to parse factions data from JSON.");
}
// Attempt to get the factions for the specified year
if (factionsByYear.TryGetValue(Year, out var factions))
{
return factions;
}
else
{
throw new KeyNotFoundException($"No factions found for the year {Year}.");
}
}
The format for the factions-by-year.json:
{
"0": [
"Steiner","Marik","Kurita","Davion","Liao","AuriganRestoration","ComStar","MagistracyOfCanopus","TaurianConcordat","Outworld","Niops","Oberon","Lothian","Circinus","Illyrian","Rasalhague","Ives","Axumite","Castile","Chainelane","ClanFreeGuilds","ClanBloodSpirit","ClanBurrock","ClanCloudCobra","ClanCoyote","ClanDiamondShark","ClanFireMandrill","ClanGhostBear","ClanGoliathScorpion","ClanHellsHorses","ClanIceHellion","ClanJadeFalcon","ClanNovaCat","ClansGeneric","ClanSmokeJaguar","ClanSnowRaven","ClanStarAdder","ClanSteelViper","ClanWolf","Delphi","Elysia","Hanse","JarnFolk","Tortuga","Valkyrate","NoFaction","Locals", "AuriganDirectorate","AuriganPirates","WordOfBlake","LocalMalcontents"
],
"1": [
"Steiner","Marik","Kurita","Davion","Liao","AuriganRestoration","ComStar","MagistracyOfCanopus","TaurianConcordat","Outworld","Niops","Oberon","Lothian","Circinus","Illyrian","Rasalhague","Ives","Axumite","Castile","Chainelane","ClanFreeGuilds","ClanBloodSpirit","ClanBurrock","ClanCloudCobra","ClanCoyote","ClanDiamondShark","ClanFireMandrill","ClanGhostBear","ClanGoliathScorpion","ClanHellsHorses","ClanIceHellion","ClanJadeFalcon","ClanNovaCat","ClansGeneric","ClanSmokeJaguar","ClanSnowRaven","ClanStarAdder","ClanSteelViper","ClanWolf","Delphi","Elysia","Hanse","JarnFolk","Tortuga","Valkyrate","NoFaction","Locals", "AuriganDirectorate", "AuriganPirates","WordOfBlake","LocalMalcontents"
],
"2": [
"Steiner","Marik","Kurita","Davion","Liao","AuriganRestoration","ComStar","MagistracyOfCanopus","TaurianConcordat","Outworld","Niops","Oberon","Lothian","Circinus", "Illyrian","Rasalhague","Ives","Axumite","Castile","Chainelane","ClanFreeGuilds","ClanBloodSpirit","ClanBurrock","ClanCloudCobra","ClanCoyote","ClanDiamondShark","ClanFireMandrill","ClanGhostBear","ClanGoliathScorpion","ClanHellsHorses","ClanIceHellion","ClanJadeFalcon","ClanNovaCat","ClansGeneric","ClanSmokeJaguar","ClanSnowRaven","ClanStarAdder","ClanSteelViper","ClanWolf","Delphi","Elysia","Hanse","JarnFolk","Tortuga","Valkyrate","NoFaction","Locals","AuriganDirectorate", "AuriganPirates","WordOfBlake","LocalMalcontents","Rim"
]
}
This allows the faction list to be updated without having to completely recompile the DocToSystem executable.
Metadata
Metadata
Assignees
Labels
No labels