This should be simple, and I'm really hung up on this here......
As you will see in the code below, I'm trying to make a simple Pokemon battle. I'm trying to create a While loop, to constantly subract Health and Attack, until somebody has 0 health.
Though the code will be written incorrectly, he is what I'm trying to do:
while (myPokemon[int parse(myChoice)-1].Health >0 && chadPokemon[randomChoice].Health>0)
This is giving me errors. I will post the rest of my current, working code below. Please look it over, and let me know what I am missing!!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Practice_Battle
{
class Pokemon
{
public string Name;
public int Health;
public int Attack;
}
class Program
{
static List<Pokemon> chadPokemon = new List<Pokemon>() {
new Pokemon {
Name = "Charizard",
Health = 200,
Attack = 50
},
new Pokemon {
Name = "Garchomp",
Health = 180,
Attack = 50
},
new Pokemon {
Name= "Metagross",
Health = 200,
Attack = 50
},
new Pokemon {
Name = "Aegislash",
Health = 200,
Attack = 50
},
new Pokemon {
Name = "Quagsire",
Health = 200,
Attack = 50
},
new Pokemon {
Name = "Gardevoir",
Health = 200,
Attack = 50
}
};
static List<Pokemon> myPokemon = new List<Pokemon>() {
new Pokemon {
Name = "Blastoise",
Health = 200,
Attack = 50
},
new Pokemon {
Name = "Blazekin",
Health = 200,
Attack = 50
},
new Pokemon {
Name = "Meganium",
Health= 200,
Attack = 50
}
};
static void Main(string[] args)
{
//Chad's List of Pokemon
//string[] chadPokemon = new string[6] { "Charizard", "Garchomp", "Metagross", "Aegislash", "Quagsire", "Gardevoir" };
//Random Pokemon Generator
var rnd = new Random();
var randomChoice = chadPokemon[rnd.Next(chadPokemon.Count)];
Console.WriteLine("Gamer Chad wants to battle!");
Console.WriteLine("Do you accept? (yes or no)");
string acceptInput = Console.ReadLine();
string message = "";
if (acceptInput == "yes")
message = "It's time to put your game face on!";
else
message = "Too bad. It's time to battle!";
//Random Pokemon is Chosen, I choose a Pokemon
Console.WriteLine(message);
Console.WriteLine();
Console.WriteLine("I choose you, " + randomChoice.Name);
Console.WriteLine();
Console.WriteLine("Please choose your Pokemon:");
Console.WriteLine("Press 1 for Blastoise.");
Console.WriteLine("Press 2 for Blazekin.");
Console.WriteLine("Press 3 for Meganium.");
var myChoice = Console.ReadLine();
Console.WriteLine();
Console.WriteLine(myPokemon[int.Parse(myChoice)-1].Name + ", I choose you!");
Console.WriteLine("Type yes to Attack.");
acceptInput = Console.ReadLine();
while(myPokemon.Health >0 && chadPokemon.Health>0)
{
}
}
}
}