The
New member
- Joined
- Sep 24, 2022
- Messages
- 1
- Programming Experience
- Beginner
So, I'm writing a Console RPG game thing, to become more proficient in C#, and at one line, I get CS8600, and I'm not sure why. it is a command system thing, and for some reason it closes the command window as if there is no more code after (There is, I will put it below). Please help me! (And yes, I've already tried putting a '!' in Console.ReadLine(); it closes anyway.)
Fight():
public static int Fight()
{
Random rng = new Random();
Random dmg = new Random();
string[] monsters = {"skeleton", "goblin", "zombie"};
int[] monstersHealth = {3, 2, 5};
int monsterPicked = rng.Next(0, 3);
int monsterPickedHealth = monstersHealth[monsterPicked];
string monsterName = monsters[monsterPicked];
Console.Write("You adventure down a cave, and find a " + monsterName + " blocking your path!\n");
Console.Write("What would you like to do?\n Attack, Guard, Run\n");
string fightCommand = Console.ReadLine();
Console.Write("You wrote " + fightCommand + "!");
if (fightCommand == "attack" || fightCommand == "Attack")
{
int damage = dmg.Next(1, 4);
Console.Write("You use your trusty wooden sword to attack the " + monsterName + ".\nYou do " + damage + " damage!\n");
int result1 = monsterPickedHealth - damage;
Console.Write("The " + monsterName + " has " + result1 + " health left!");
}
return 0;
}