51 lines
1.5 KiB
C#
51 lines
1.5 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 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 export) =>
|
|
{
|
|
var archetypeList = Archetypes.DefaultArchetypes();
|
|
var archetypeDict = new Dictionary<string, Dictionary<string, double>>();
|
|
|
|
var traits = PersonalityGen.GenerateRandom(archetypeDict.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, exportOption);
|
|
|
|
return await rootCommand.InvokeAsync(args);
|