86 lines
2.8 KiB
C#
86 lines
2.8 KiB
C#
|
namespace SimsPersonalityGenerator;
|
||
|
|
||
|
public class Sim
|
||
|
{
|
||
|
public int Niceness { get; private set; }
|
||
|
public int Neatness { get; private set; }
|
||
|
public int Outgoingness { get; private set; }
|
||
|
public int Activeness { get; private set; }
|
||
|
public int Playfulness { get; private set; }
|
||
|
|
||
|
public Sim()
|
||
|
{
|
||
|
GenerateRandomPersonality();
|
||
|
}
|
||
|
|
||
|
public void SetTraitHigher(string trait, bool isHigh)
|
||
|
{
|
||
|
switch (trait.ToLower())
|
||
|
{
|
||
|
case "niceness":
|
||
|
if (isHigh)
|
||
|
Niceness = Math.Min(10, Neatness + 5);
|
||
|
else
|
||
|
Neatness = Math.Min(10, Niceness + 5);
|
||
|
break;
|
||
|
case "neatness":
|
||
|
if (isHigh)
|
||
|
Neatness = Math.Min(10, Activeness + 5);
|
||
|
else
|
||
|
Activeness = Math.Min(10, Neatness + 5);
|
||
|
break;
|
||
|
case "outgoingness":
|
||
|
if (isHigh)
|
||
|
Outgoingness = Math.Min(10, Playfulness + 5);
|
||
|
else
|
||
|
Playfulness = Math.Min(10, Outgoingness + 5);
|
||
|
break;
|
||
|
case "activeness":
|
||
|
if (isHigh)
|
||
|
Activeness = Math.Min(10, Niceness + 5);
|
||
|
else
|
||
|
Niceness = Math.Min(10, Activeness + 5);
|
||
|
break;
|
||
|
case "playfulness":
|
||
|
if (isHigh)
|
||
|
Playfulness = Math.Min(10, Outgoingness + 5);
|
||
|
else
|
||
|
Outgoingness = Math.Min(10, Playfulness + 5);
|
||
|
break;
|
||
|
default:
|
||
|
throw new ArgumentException("Invalid trait name.");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void GenerateRandomPersonality()
|
||
|
{
|
||
|
Random rand = new Random();
|
||
|
Niceness = rand.Next(11);
|
||
|
Neatness = rand.Next(11);
|
||
|
Outgoingness = rand.Next(11);
|
||
|
Activeness = rand.Next(11);
|
||
|
Playfulness = rand.Next(11);
|
||
|
|
||
|
// Ensure that the sum of traits is balanced
|
||
|
int totalSum = Niceness + Neatness + Outgoingness + Activeness + Playfulness;
|
||
|
if (totalSum > 50)
|
||
|
{
|
||
|
int overage = totalSum - 50;
|
||
|
int traitToReduce = rand.Next(5);
|
||
|
switch (traitToReduce)
|
||
|
{
|
||
|
case 0: Niceness -= Math.Min(Niceness, overage); break;
|
||
|
case 1: Neatness -= Math.Min(Neatness, overage); break;
|
||
|
case 2: Outgoingness -= Math.Min(Outgoingness, overage); break;
|
||
|
case 3: Activeness -= Math.Min(Activeness, overage); break;
|
||
|
case 4: Playfulness -= Math.Min(Playfulness, overage); break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public override string ToString()
|
||
|
{
|
||
|
return $"Niceness: {Niceness}, Neatness: {Neatness}, Outgoingness: {Outgoingness}, Activeness: {Activeness}, Playfulness: {Playfulness}";
|
||
|
}
|
||
|
}
|