CLI tool
- Dotnet tool support - Moved profile import/load to after 1.0
This commit is contained in:
parent
af5ee82bd0
commit
6a9c9a4533
5 changed files with 44 additions and 44 deletions
5
.config/dotnet-tools.json
Normal file
5
.config/dotnet-tools.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {}
|
||||
}
|
|
@ -1 +1,2 @@
|
|||
global using System.Text.Json;
|
||||
global using System.CommandLine;
|
||||
|
|
|
@ -2,10 +2,18 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<Version>0.4.102</Version>
|
||||
<Version>0.5.101</Version>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<PackAsTool>true</PackAsTool>
|
||||
<ToolCommandName>personaforge</ToolCommandName>
|
||||
<PackageId>PersonaForge</PackageId>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
61
Program.cs
61
Program.cs
|
@ -3,49 +3,34 @@
|
|||
|
||||
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 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'): ");
|
||||
string archetypeInput = Console.ReadLine() ?? "Random";
|
||||
if (!archetypeDict.ContainsKey(archetypeInput))
|
||||
{
|
||||
Console.WriteLine("Invalid archetype. Using Random.");
|
||||
archetypeInput = "Random";
|
||||
}
|
||||
var rootCommand = new RootCommand("PersonaForge: Sims 2 Personality Generator");
|
||||
|
||||
Console.WriteLine($"{Environment.NewLine}Generating {archetypeInput} profile...");
|
||||
var qualities = PersonalityGen.GenerateRandom(archetypeDict[archetypeInput]);
|
||||
var profile = new PersonaProfile
|
||||
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");
|
||||
|
||||
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,
|
||||
Qualities = qualities,
|
||||
Archetype = archetypeInput
|
||||
};
|
||||
Qualities = traits,
|
||||
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): ");
|
||||
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();
|
||||
return await rootCommand.InvokeAsync(args);
|
||||
|
|
|
@ -16,12 +16,13 @@ With Sims 3 and later, creating personalities is as simple as selecting a trait.
|
|||
|
||||
| Phase | Goal | Status |
|
||||
| ----- | ------------------------------------------- | ------ |
|
||||
| v0.1 | Core random point generator (working) | ✅ |
|
||||
| v0.1 | Core random point generator | ✅ |
|
||||
| v0.2 | PersonalityProfile class | ✅ |
|
||||
| v0.3 | Interactive JSON export | ✅ |
|
||||
| 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.x | Profile import/load from JSON | 🔜 |
|
||||
|
||||
## 🧩 Tech Stack
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue