diff --git a/Archetypes.cs b/Archetypes.cs index 86d3c37..76e2c12 100644 --- a/Archetypes.cs +++ b/Archetypes.cs @@ -5,32 +5,22 @@ public class Archetypes public string Name { get; set; } public Dictionary TraitBiases { get; set; } = new(); - public static Dictionary LoadFromJson(string json) + public static List LoadFromJson(string file) { var opt = new JsonSerializerOptions() { PropertyNameCaseInsensitive = false }; + var json = File.ReadAllText(file); var definitions = JsonSerializer.Deserialize>(json, opt); if (definitions is null) throw new InvalidOperationException("Failed to deserialize Archetype JSON."); - var traitBiases = new Dictionary(); - - foreach (var def in definitions) - { - foreach (var traitBias in def.TraitBiases) - { - traitBiases[traitBias.Key] = traitBias.Value; - } - } - - return traitBiases; + return definitions; } - // TODO: Load default archetypes from a file or database public static List DefaultArchetypes() => new() { new Archetypes diff --git a/Program.cs b/Program.cs index db9aee6..64bc010 100644 --- a/Program.cs +++ b/Program.cs @@ -19,12 +19,14 @@ var archetypeOption = new Option( var zodiacOption = new Option( name: "--zodiac", description: "Use zodiac signs instead of archetypes" -); +) +{ IsRequired = false }; var exportOption = new Option( name: "--export", description: "Export the generated profile to a file" -); +) +{ IsRequired = false }; rootCommand.AddOption(nameOption); rootCommand.AddOption(archetypeOption); @@ -37,15 +39,15 @@ rootCommand.SetHandler(async ( bool export ) => { - var definitions = new Dictionary(); - - definitions = Archetypes.LoadFromJson("archetypes.json"); + var archetypeDefs = Archetypes.LoadFromJson("archetypes.json"); + var archetypeDict = new Dictionary>(); if (zodiac) - definitions = Archetypes.LoadFromJson("zodiacs.json"); + archetypeDefs = Archetypes.LoadFromJson("zodiacs.json"); - var traits = PersonalityGen.GenerateRandom(definitions.GetValueOrDefault(archetype, new())); + + var traits = PersonalityGen.GenerateRandom(archetypeDict.GetValueOrDefault(archetype, new())); var profile = new PersonaProfile { Name = name, diff --git a/README.md b/README.md index 3098d97..4f14baa 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Because The Sims 2 doesn’t have traits in the same way later installments do, ## 📌 Stretch Goals -- [ ] Import The Sims' Zodiac signs +- [x] Import The Sims' Zodiac signs - [x] Cross-platform dotnet tool. (e.g. `dotnet tool install`) ## 🧩 Tech Stack