Fixed conversion problem
- Zodiac option isn’t showing for some reason
This commit is contained in:
parent
45fdf40af2
commit
3690f96e42
3 changed files with 13 additions and 21 deletions
|
@ -5,32 +5,22 @@ public class Archetypes
|
|||
public string Name { get; set; }
|
||||
public Dictionary<string, double> TraitBiases { get; set; } = new();
|
||||
|
||||
public static Dictionary<string, double> LoadFromJson(string json)
|
||||
public static List<Archetypes> LoadFromJson(string file)
|
||||
{
|
||||
var opt = new JsonSerializerOptions()
|
||||
{
|
||||
PropertyNameCaseInsensitive = false
|
||||
};
|
||||
|
||||
var json = File.ReadAllText(file);
|
||||
var definitions = JsonSerializer.Deserialize<List<Archetypes>>(json, opt);
|
||||
|
||||
if (definitions is null)
|
||||
throw new InvalidOperationException("Failed to deserialize Archetype JSON.");
|
||||
|
||||
var traitBiases = new Dictionary<string, double>();
|
||||
|
||||
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<Archetypes> DefaultArchetypes() => new()
|
||||
{
|
||||
new Archetypes
|
||||
|
|
16
Program.cs
16
Program.cs
|
@ -19,12 +19,14 @@ var archetypeOption = new Option<string>(
|
|||
var zodiacOption = new Option<bool>(
|
||||
name: "--zodiac",
|
||||
description: "Use zodiac signs instead of archetypes"
|
||||
);
|
||||
)
|
||||
{ IsRequired = false };
|
||||
|
||||
var exportOption = new Option<bool>(
|
||||
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<string, double>();
|
||||
|
||||
definitions = Archetypes.LoadFromJson("archetypes.json");
|
||||
var archetypeDefs = Archetypes.LoadFromJson("archetypes.json");
|
||||
var archetypeDict = new Dictionary<string, Dictionary<string, double>>();
|
||||
|
||||
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,
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue