- Dotnet tool support
- Moved profile import/load to after 1.0
This commit is contained in:
Tony Bark 2025-04-28 11:45:04 -04:00
parent af5ee82bd0
commit 6a9c9a4533
5 changed files with 44 additions and 44 deletions

View file

@ -0,0 +1,5 @@
{
"version": 1,
"isRoot": true,
"tools": {}
}

View file

@ -1 +1,2 @@
global using System.Text.Json; global using System.Text.Json;
global using System.CommandLine;

View file

@ -2,10 +2,18 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<Version>0.4.102</Version> <Version>0.5.101</Version>
<TargetFramework>net9.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<PackAsTool>true</PackAsTool>
<ToolCommandName>personaforge</ToolCommandName>
<PackageId>PersonaForge</PackageId>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
</ItemGroup>
</Project> </Project>

View file

@ -3,49 +3,34 @@
using PersonaForge; using PersonaForge;
Console.WriteLine("=== Welcome to The Sims 2 Personality Generator ===");
Console.Write("Enter Sim's name: ");
string name = Console.ReadLine() ?? "Unndanmed Sim";
// Move the conversion logic to a separate method
Console.WriteLine("\nAvailable Archetypes:");
var archetypeList = Archetypes.DefaultArchetypes(); var archetypeList = Archetypes.DefaultArchetypes();
var archetypeDict = new Dictionary<string, Dictionary<string, double>>(); var archetypeDict = new Dictionary<string, Dictionary<string, double>>();
foreach (var archetype in archetypeList)
{
Console.WriteLine($"- {archetype.Name}");
archetypeDict.Add(archetype.Name, archetype.TraitBiases);
}
Console.Write("Choose an Archetype (or 'Random'): "); var rootCommand = new RootCommand("PersonaForge: Sims 2 Personality Generator");
string archetypeInput = Console.ReadLine() ?? "Random";
if (!archetypeDict.ContainsKey(archetypeInput))
{
Console.WriteLine("Invalid archetype. Using Random.");
archetypeInput = "Random";
}
Console.WriteLine($"{Environment.NewLine}Generating {archetypeInput} profile..."); var nameOption = new Option<string>(
var qualities = PersonalityGen.GenerateRandom(archetypeDict[archetypeInput]); name: "--name",
var profile = new PersonaProfile description: "Enter a name for the Sim");
var archetypeOption = new Option<string>(
name: "--archetype",
description: "The archetype template to base traits on",
getDefaultValue: () => "Random");
rootCommand.AddOption(nameOption);
rootCommand.AddOption(archetypeOption);
rootCommand.SetHandler(async (string name, string archetype) =>
{ {
var traits = PersonalityGen.GenerateRandom(archetypeDict.GetValueOrDefault(archetype));
var profile = new PersonaProfile
{
Name = name, Name = name,
Qualities = qualities, Qualities = traits,
Archetype = archetypeInput Archetype = archetype
}; };
Console.WriteLine($"{Environment.NewLine}--- Generated Profile ---{Environment.NewLine}{PersonaProfile.ToJson(profile)}"); Console.WriteLine(PersonaProfile.ToJson(profile));
}, nameOption, archetypeOption);
Console.Write("Save profile? (y/n): "); return await rootCommand.InvokeAsync(args);
var saveInput = Console.ReadLine()?.Trim().ToLowerInvariant();
if (saveInput == "y")
{
var safeName = name.Replace(" ", "_").Replace("\"", "");
File.WriteAllText($"{safeName}.json", PersonaProfile.ToJson(profile));
Console.WriteLine($"Profile saved as {name}.json");
}
Console.WriteLine($"Done. Forge on! 🔥{Environment.NewLine}Press any key to exit...");
Console.ReadKey();

View file

@ -16,12 +16,13 @@ With Sims 3 and later, creating personalities is as simple as selecting a trait.
| Phase | Goal | Status | | Phase | Goal | Status |
| ----- | ------------------------------------------- | ------ | | ----- | ------------------------------------------- | ------ |
| v0.1 | Core random point generator (working) | ✅ | | v0.1 | Core random point generator | ✅ |
| v0.2 | PersonalityProfile class | ✅ | | v0.2 | PersonalityProfile class | ✅ |
| v0.3 | Interactive JSON export | ✅ | | v0.3 | Interactive JSON export | ✅ |
| v0.4 | Archetypes with weighted biases | ✅ | | v0.4 | Archetypes with weighted biases | ✅ |
| v0.5 | Profile import/load from JSON | 🔜 | | v0.5 | Command line tool | ✅ |
| v1.0 | Stable "Release" version with documentation | 🔜 | | v1.0 | Stable "Release" version with documentation | 🔜 |
| v1.x | Profile import/load from JSON | 🔜 |
## 🧩 Tech Stack ## 🧩 Tech Stack