Files
FinalBattle/Player.cs

45 lines
1.2 KiB
C#

public class Player : Character
{
public Player()
{
name = GetName();
maxHP = 25;
currentHP = maxHP;
dead = false;
CharacterEnabledActions.AddRange("Punch", "Health Potion", "Items", "Do Nothing");
}
public string GetName()
{
string input = null;
if (GameState.Instance.herosAIControl == false)
{
while (true)
{
try
{
input = ColoredConsole.Prompt("Enter your name");
if (input.Length < 1)
{
ColoredConsole.WriteLine("Sorry, that isn't a valid input.", ConsoleColor.Red);
continue;
}
else
{
return input;
}
}
catch (FormatException)
{
ColoredConsole.WriteLine("Sorry, that isn't a valid input.", ConsoleColor.Red);
continue;
}
}
}
else
{
return "The True Programmer";
}
}
}