SimsPersonalityGenerator/Program.cs
Tony Bark 70e948569d Merged Launch/RestartSession into SessionManager
- Renamed isRestartSession to isFinishedSession
2025-02-07 07:31:37 -05:00

78 lines
No EOL
2.2 KiB
C#

using SimsPersonalityGenerator;
var isFinishedSession = false;
void GenerateTraits()
{
Console.WriteLine("You can prioritize one or more traits to be above 8 by entering them.");
Console.Write("Enter traits separated by commas (e.g., Outgoing, Nice), or press Enter to generate a random personality: ");
var prioritizedTraitsInput = Console.ReadLine()?.Trim();
var traits = new Dictionary<string, int>
{
{ "Outgoing", 0 },
{ "Nice", 0 },
{ "Playful", 0 },
{ "Neat", 0 },
{ "Active", 0 }
};
// Process the prioritized traits
var prioritizedTraits = new HashSet<string>(prioritizedTraitsInput.Split(',')
.Select(t => t.Trim()).Where(t => !string.IsNullOrEmpty(t) && traits.ContainsKey(t)));
if (prioritizedTraits.Count > 0)
{
Sim.AssignPrioritizedTraits(traits, prioritizedTraits);
}
else
{
Sim.AssignRandomTraits(traits);
}
Sim.DisplayPersonality(traits);
isFinishedSession = true;
SessionManager();
}
string? GetUserInput(string message)
{
// Prompt the user to generate a random personality
Console.WriteLine(message);
// Read the user input
var input = Console.ReadLine();
return input;
}
// Method to launch a new session
void SessionManager()
{
if (!isFinishedSession)
Console.WriteLine("Welcome to the Sim Personality Generator!");
var message = "Would you like to generate a random personality? [y/n]";
if (isFinishedSession)
message = "Would you like to generate a new personality? [y/n]";
var input = GetUserInput(message);
// Convert the input to lowercase to handle case insensitivity
switch (input?.ToLower())
{
case "y": // If the user enters 'y'
if (isFinishedSession) isFinishedSession = false;
// Clear the console for a fresh start
Console.Clear();
// Generate traits (presumably some form of random data)
GenerateTraits();
break;
default: // If the user enters anything other than 'y'
// Exit the application with the current exit code
Environment.Exit(Environment.ExitCode);
break;
}
}
SessionManager();