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.Text.Json;
|
||||||
|
global using System.CommandLine;
|
||||||
|
|
|
@ -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>
|
||||||
|
|
67
Program.cs
67
Program.cs
|
@ -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)
|
|
||||||
|
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");
|
||||||
|
|
||||||
|
rootCommand.AddOption(nameOption);
|
||||||
|
rootCommand.AddOption(archetypeOption);
|
||||||
|
|
||||||
|
rootCommand.SetHandler(async (string name, string archetype) =>
|
||||||
{
|
{
|
||||||
Console.WriteLine($"- {archetype.Name}");
|
var traits = PersonalityGen.GenerateRandom(archetypeDict.GetValueOrDefault(archetype));
|
||||||
archetypeDict.Add(archetype.Name, archetype.TraitBiases);
|
var profile = new PersonaProfile
|
||||||
}
|
{
|
||||||
|
Name = name,
|
||||||
|
Qualities = traits,
|
||||||
|
Archetype = archetype
|
||||||
|
};
|
||||||
|
|
||||||
Console.Write("Choose an Archetype (or 'Random'): ");
|
Console.WriteLine(PersonaProfile.ToJson(profile));
|
||||||
string archetypeInput = Console.ReadLine() ?? "Random";
|
}, nameOption, archetypeOption);
|
||||||
if (!archetypeDict.ContainsKey(archetypeInput))
|
|
||||||
{
|
|
||||||
Console.WriteLine("Invalid archetype. Using Random.");
|
|
||||||
archetypeInput = "Random";
|
|
||||||
}
|
|
||||||
|
|
||||||
Console.WriteLine($"{Environment.NewLine}Generating {archetypeInput} profile...");
|
return await rootCommand.InvokeAsync(args);
|
||||||
var qualities = PersonalityGen.GenerateRandom(archetypeDict[archetypeInput]);
|
|
||||||
var profile = new PersonaProfile
|
|
||||||
{
|
|
||||||
Name = name,
|
|
||||||
Qualities = qualities,
|
|
||||||
Archetype = archetypeInput
|
|
||||||
};
|
|
||||||
|
|
||||||
Console.WriteLine($"{Environment.NewLine}--- Generated Profile ---{Environment.NewLine}{PersonaProfile.ToJson(profile)}");
|
|
||||||
|
|
||||||
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();
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue