Commented Sims class
- Both main code and this class were commented by AI
This commit is contained in:
parent
af9f85b1a4
commit
5a68aecb9d
1 changed files with 29 additions and 6 deletions
33
Sim.cs
33
Sim.cs
|
@ -1,10 +1,25 @@
|
|||
namespace SimsPersonalityGenerator;
|
||||
|
||||
static class Sim
|
||||
/// <summary>
|
||||
/// Represents the Sim personality generator with methods to assign traits and display personality.
|
||||
/// </summary>
|
||||
internal static class Sim
|
||||
{
|
||||
/// <summary>
|
||||
/// The target value for prioritized traits to aim for, typically 8.
|
||||
/// </summary>
|
||||
private const int Target = 8;
|
||||
private static readonly Random Random = new Random();
|
||||
|
||||
/// <summary>
|
||||
/// A random number generator instance for generating random values.
|
||||
/// </summary>
|
||||
private static readonly Random Rand = new Random();
|
||||
|
||||
/// <summary>
|
||||
/// Assigns high values to the specified prioritized traits and random values to other traits.
|
||||
/// </summary>
|
||||
/// <param name="traits">A dictionary of traits with their initial values.</param>
|
||||
/// <param name="prioritizedTraits">A set of traits that the user wants to prioritize.</param>
|
||||
public static void AssignPrioritizedTraits(Dictionary<string, int> traits, HashSet<string> prioritizedTraits)
|
||||
{
|
||||
Console.WriteLine("Assigning high values to prioritized traits...");
|
||||
|
@ -13,7 +28,7 @@ static class Sim
|
|||
// Assign high values to prioritized traits (8, 9, or 10)
|
||||
foreach (var trait in prioritizedTraits)
|
||||
{
|
||||
var value = Math.Min(Target + Random.Next(3), 10);
|
||||
var value = Math.Min(Target + Rand.Next(3), 10);
|
||||
remainingPoints -= value;
|
||||
traits[trait] = value;
|
||||
Console.WriteLine($"Setting {trait} to {value}.");
|
||||
|
@ -24,7 +39,7 @@ static class Sim
|
|||
foreach (var trait in nonPrioritizedTraits)
|
||||
{
|
||||
var maxPossibleValue = Math.Min(remainingPoints, 10);
|
||||
var value = Random.Next(maxPossibleValue + 1);
|
||||
var value = Rand.Next(maxPossibleValue + 1);
|
||||
remainingPoints -= value;
|
||||
traits[trait] = value;
|
||||
Console.WriteLine($"Setting {trait} to {value}.");
|
||||
|
@ -33,6 +48,10 @@ static class Sim
|
|||
Console.WriteLine("Adjusted remaining traits to maintain balance.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Assigns random values to all traits.
|
||||
/// </summary>
|
||||
/// <param name="traits">A dictionary of traits with their initial values.</param>
|
||||
public static void AssignRandomTraits(Dictionary<string, int> traits)
|
||||
{
|
||||
Console.WriteLine("Generating random personality...");
|
||||
|
@ -41,7 +60,7 @@ static class Sim
|
|||
foreach (var trait in traits.Keys)
|
||||
{
|
||||
var maxPossibleValue = Math.Min(remainingPoints, 10);
|
||||
var value = Random.Next(maxPossibleValue + 1);
|
||||
var value = Rand.Next(maxPossibleValue + 1);
|
||||
remainingPoints -= value;
|
||||
traits[trait] = value;
|
||||
Console.WriteLine($"Setting {trait} to {value}.");
|
||||
|
@ -50,6 +69,10 @@ static class Sim
|
|||
Console.WriteLine("Random personality generation complete.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays the generated personality traits.
|
||||
/// </summary>
|
||||
/// <param name="traits">A dictionary of traits with their assigned values.</param>
|
||||
public static void DisplayPersonality(Dictionary<string, int> traits)
|
||||
{
|
||||
Console.WriteLine("\nGenerated Sim Personality:");
|
||||
|
|
Reference in a new issue