personaforge/Program.cs
2025-04-28 13:56:46 -04:00

66 lines
1.7 KiB
C#

// .NET 8 C# - Random Sims 2 Personality Allocator
// Clear, minimal, portable, with basic validation.
using PersonaForge;
var rootCommand = new RootCommand("PersonaForge: Sims 2 Personality Generator");
var nameOption = new Option<string>(
name: "--name",
description: "Enter a name for the Sim"
);
var archetypeOption = new Option<string>(
name: "--archetype",
description: "The archetype template to base traits on",
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"
);
rootCommand.AddOption(nameOption);
rootCommand.AddOption(archetypeOption);
rootCommand.AddOption(exportOption);
rootCommand.SetHandler(async (
string name,
string archetype,
bool zodiac,
bool export
) =>
{
var definitions = new Dictionary<string, double>();
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,
Qualities = traits,
Archetype = archetype
};
Console.WriteLine($"--- Generated Profile ---{Environment.NewLine}{PersonaProfile.ToJson(profile)}");
if (export)
{
var safeName = name.Replace(" ", "_").Replace("\"", "");
await File.WriteAllTextAsync($"{safeName}.json", PersonaProfile.ToJson(profile));
}
}, nameOption, archetypeOption, zodiacOption, exportOption);
return await rootCommand.InvokeAsync(args);