Personality generator class

This commit is contained in:
Tony Bark 2025-04-28 05:39:47 -04:00
parent f710a9b109
commit 83784d2c00
2 changed files with 49 additions and 3 deletions

View file

@ -2,15 +2,61 @@ namespace PersonaForge;
public static class PersonalityGen
{
int MaxPoints = 10;
int TotalBudget = 25;
const int MaxPoints = 10;
const int TotalBudget = 25;
static readonly Random rng = new();
public static PersonalityProfile GeneratePersonalityProfile()
{
var profile = PersonalityProfile.Create();
var traits = new List<string> { "Outgoing", "Nice", "Playful", "Neat", "Active" };
var remaining = TotalBudget;
while (remaining > 0)
{
var trait = traits[rng.Next(traits.Count)];
var current = GetCurrentTraitPoints(profile, trait);
if (current < MaxPoints)
{
var add = (rng.NextDouble() < 0.1) ? Math.Min(2, MaxPoints - current) : 1;
add = Math.Min(add, remaining);
SetTraitPoints(profile, trait, current + add);
remaining -= add;
}
}
return profile;
}
static int GetCurrentTraitPoints(PersonalityProfile p, string trait) => trait switch
{
"Outgoing" => p.Outgoing,
"Nice" => p.Nice,
"Playful" => p.Playful,
"Neat" => p.Neat,
"Active" => p.Active,
_ => 0
};
static void SetTraitPoints(PersonalityProfile p, string trait, int points)
{
switch (trait)
{
case "Outgoing":
p.Outgoing = points;
break;
case "Nice":
p.Nice = points;
break;
case "Playful":
p.Playful = points;
break;
case "Neat":
p.Neat = points;
break;
case "Active":
p.Active = points;
break;
}
}
}

View file

@ -38,7 +38,7 @@ PersonaForge is intended to help you generate a personality for The Sims 2. It i
### 🔍 Background
With Sims 3 and later, creating personalities is as simple as selecting a trait. Sims 2 doesnt have traits in the same way later installments do. You had to figure out what kind of Sim you wanted based on the traits and points you had to spend. Even if you knew what you wanted, you didnt know how to spend the rest. This was created to solve that.
With Sims 3 and later, creating personalities is as simple as selecting a trait. Sims 2 doesnt have traits in the same way later installments do. You had to figure out what kind of Sim you wanted based on certain qualities and points you had to spend. Even if you knew what you wanted, you didnt know how to spend the rest. This was created to solve that.
## 📄 License