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 string Name { get; set; }
|
||||||
public Dictionary<string, double> TraitBiases { get; set; } = new();
|
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()
|
var opt = new JsonSerializerOptions()
|
||||||
{
|
{
|
||||||
PropertyNameCaseInsensitive = false
|
PropertyNameCaseInsensitive = false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var json = File.ReadAllText(file);
|
||||||
var definitions = JsonSerializer.Deserialize<List<Archetypes>>(json, opt);
|
var definitions = JsonSerializer.Deserialize<List<Archetypes>>(json, opt);
|
||||||
|
|
||||||
if (definitions is null)
|
if (definitions is null)
|
||||||
throw new InvalidOperationException("Failed to deserialize Archetype JSON.");
|
throw new InvalidOperationException("Failed to deserialize Archetype JSON.");
|
||||||
|
|
||||||
var traitBiases = new Dictionary<string, double>();
|
return definitions;
|
||||||
|
|
||||||
foreach (var def in definitions)
|
|
||||||
{
|
|
||||||
foreach (var traitBias in def.TraitBiases)
|
|
||||||
{
|
|
||||||
traitBiases[traitBias.Key] = traitBias.Value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return traitBiases;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Load default archetypes from a file or database
|
|
||||||
public static List<Archetypes> DefaultArchetypes() => new()
|
public static List<Archetypes> DefaultArchetypes() => new()
|
||||||
{
|
{
|
||||||
new Archetypes
|
new Archetypes
|
||||||
|
|
16
Program.cs
16
Program.cs
|
@ -19,12 +19,14 @@ var archetypeOption = new Option<string>(
|
||||||
var zodiacOption = new Option<bool>(
|
var zodiacOption = new Option<bool>(
|
||||||
name: "--zodiac",
|
name: "--zodiac",
|
||||||
description: "Use zodiac signs instead of archetypes"
|
description: "Use zodiac signs instead of archetypes"
|
||||||
);
|
)
|
||||||
|
{ IsRequired = false };
|
||||||
|
|
||||||
var exportOption = new Option<bool>(
|
var exportOption = new Option<bool>(
|
||||||
name: "--export",
|
name: "--export",
|
||||||
description: "Export the generated profile to a file"
|
description: "Export the generated profile to a file"
|
||||||
);
|
)
|
||||||
|
{ IsRequired = false };
|
||||||
|
|
||||||
rootCommand.AddOption(nameOption);
|
rootCommand.AddOption(nameOption);
|
||||||
rootCommand.AddOption(archetypeOption);
|
rootCommand.AddOption(archetypeOption);
|
||||||
|
@ -37,15 +39,15 @@ rootCommand.SetHandler(async (
|
||||||
bool export
|
bool export
|
||||||
) =>
|
) =>
|
||||||
{
|
{
|
||||||
var definitions = new Dictionary<string, double>();
|
var archetypeDefs = Archetypes.LoadFromJson("archetypes.json");
|
||||||
|
var archetypeDict = new Dictionary<string, Dictionary<string, double>>();
|
||||||
definitions = Archetypes.LoadFromJson("archetypes.json");
|
|
||||||
|
|
||||||
if (zodiac)
|
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
|
var profile = new PersonaProfile
|
||||||
{
|
{
|
||||||
Name = name,
|
Name = name,
|
||||||
|
|
|
@ -26,7 +26,7 @@ Because The Sims 2 doesn’t have traits in the same way later installments do,
|
||||||
|
|
||||||
## 📌 Stretch Goals
|
## 📌 Stretch Goals
|
||||||
|
|
||||||
- [ ] Import The Sims' Zodiac signs
|
- [x] Import The Sims' Zodiac signs
|
||||||
- [x] Cross-platform dotnet tool. (e.g. `dotnet tool install`)
|
- [x] Cross-platform dotnet tool. (e.g. `dotnet tool install`)
|
||||||
|
|
||||||
## 🧩 Tech Stack
|
## 🧩 Tech Stack
|
||||||
|
|
Loading…
Add table
Reference in a new issue