Personality generator class
This commit is contained in:
parent
f710a9b109
commit
83784d2c00
2 changed files with 49 additions and 3 deletions
|
@ -2,15 +2,61 @@ namespace PersonaForge;
|
||||||
|
|
||||||
public static class PersonalityGen
|
public static class PersonalityGen
|
||||||
{
|
{
|
||||||
int MaxPoints = 10;
|
const int MaxPoints = 10;
|
||||||
int TotalBudget = 25;
|
const int TotalBudget = 25;
|
||||||
|
static readonly Random rng = new();
|
||||||
|
|
||||||
public static PersonalityProfile GeneratePersonalityProfile()
|
public static PersonalityProfile GeneratePersonalityProfile()
|
||||||
{
|
{
|
||||||
var profile = PersonalityProfile.Create();
|
var profile = PersonalityProfile.Create();
|
||||||
var traits = new List<string> { "Outgoing", "Nice", "Playful", "Neat", "Active" };
|
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;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ PersonaForge is intended to help you generate a personality for The Sims 2. It i
|
||||||
|
|
||||||
### 🔍 Background
|
### 🔍 Background
|
||||||
|
|
||||||
With Sims 3 and later, creating personalities is as simple as selecting a trait. Sims 2 doesn’t 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 didn’t 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 doesn’t 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 didn’t know how to spend the rest. This was created to solve that.
|
||||||
|
|
||||||
## 📄 License
|
## 📄 License
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue