Zodiac option (buggy)
This commit is contained in:
parent
0ae58c67fa
commit
45fdf40af2
5 changed files with 55 additions and 15 deletions
|
@ -1,14 +1,39 @@
|
|||
namespace PersonaForge;
|
||||
|
||||
public class ArchetypeDefinition
|
||||
public class Archetypes
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public Dictionary<string, double> TraitBiases { get; set; } = new();
|
||||
|
||||
// TODO: Load default archetypes from a file or database
|
||||
public static List<ArchetypeDefinition> DefaultArchetypes() => new()
|
||||
public static Dictionary<string, double> LoadFromJson(string json)
|
||||
{
|
||||
new ArchetypeDefinition
|
||||
var opt = new JsonSerializerOptions()
|
||||
{
|
||||
PropertyNameCaseInsensitive = false
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// TODO: Load default archetypes from a file or database
|
||||
public static List<Archetypes> DefaultArchetypes() => new()
|
||||
{
|
||||
new Archetypes
|
||||
{
|
||||
Name = "Grumpy",
|
||||
TraitBiases = new Dictionary<string, double>
|
||||
|
@ -20,7 +45,7 @@ public class ArchetypeDefinition
|
|||
{ "Active", 0.5 }
|
||||
}
|
||||
},
|
||||
new ArchetypeDefinition
|
||||
new Archetypes
|
||||
{
|
||||
Name = "Party Animal",
|
||||
TraitBiases = new Dictionary<string, double>
|
||||
|
@ -32,7 +57,7 @@ public class ArchetypeDefinition
|
|||
{ "Neat", 0.3 }
|
||||
}
|
||||
},
|
||||
new ArchetypeDefinition
|
||||
new Archetypes
|
||||
{
|
||||
Name = "Lazy",
|
||||
TraitBiases = new Dictionary<string, double>
|
||||
|
@ -44,7 +69,7 @@ public class ArchetypeDefinition
|
|||
{ "Active", 0.1 }
|
||||
}
|
||||
},
|
||||
new ArchetypeDefinition
|
||||
new Archetypes
|
||||
{
|
||||
Name = "Shy",
|
||||
TraitBiases = new Dictionary<string, double>
|
||||
|
@ -56,7 +81,7 @@ public class ArchetypeDefinition
|
|||
{ "Active", 0.2 }
|
||||
}
|
||||
},
|
||||
new ArchetypeDefinition
|
||||
new Archetypes
|
||||
{
|
||||
Name = "Energetic",
|
||||
TraitBiases = new Dictionary<string, double>
|
||||
|
@ -68,7 +93,7 @@ public class ArchetypeDefinition
|
|||
{ "Active", 0.3 }
|
||||
}
|
||||
},
|
||||
new ArchetypeDefinition
|
||||
new Archetypes
|
||||
{
|
||||
Name = "Random",
|
||||
TraitBiases = new()
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<Version>0.5.102</Version>
|
||||
<Version>0.5.103</Version>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
|
25
Program.cs
25
Program.cs
|
@ -16,6 +16,11 @@ var archetypeOption = new Option<string>(
|
|||
getDefaultValue: () => "Random"
|
||||
);
|
||||
|
||||
var zodiacOption = new Option<bool>(
|
||||
name: "--zodiac",
|
||||
description: "Use zodiac signs instead of archetypes"
|
||||
);
|
||||
|
||||
var exportOption = new Option<bool>(
|
||||
name: "--export",
|
||||
description: "Export the generated profile to a file"
|
||||
|
@ -25,12 +30,22 @@ rootCommand.AddOption(nameOption);
|
|||
rootCommand.AddOption(archetypeOption);
|
||||
rootCommand.AddOption(exportOption);
|
||||
|
||||
rootCommand.SetHandler(async (string name, string archetype, bool export) =>
|
||||
rootCommand.SetHandler(async (
|
||||
string name,
|
||||
string archetype,
|
||||
bool zodiac,
|
||||
bool export
|
||||
) =>
|
||||
{
|
||||
var archetypeList = Archetypes.DefaultArchetypes();
|
||||
var archetypeDict = new Dictionary<string, Dictionary<string, double>>();
|
||||
var definitions = new Dictionary<string, double>();
|
||||
|
||||
var traits = PersonalityGen.GenerateRandom(archetypeDict.GetValueOrDefault(archetype, new()));
|
||||
definitions = Archetypes.LoadFromJson("archetypes.json");
|
||||
|
||||
if (zodiac)
|
||||
definitions = Archetypes.LoadFromJson("zodiacs.json");
|
||||
|
||||
|
||||
var traits = PersonalityGen.GenerateRandom(definitions.GetValueOrDefault(archetype, new()));
|
||||
var profile = new PersonaProfile
|
||||
{
|
||||
Name = name,
|
||||
|
@ -46,6 +61,6 @@ rootCommand.SetHandler(async (string name, string archetype, bool export) =>
|
|||
await File.WriteAllTextAsync($"{safeName}.json", PersonaProfile.ToJson(profile));
|
||||
}
|
||||
|
||||
}, nameOption, archetypeOption, exportOption);
|
||||
}, nameOption, archetypeOption, zodiacOption, exportOption);
|
||||
|
||||
return await rootCommand.InvokeAsync(args);
|
||||
|
|
Loading…
Add table
Reference in a new issue