Code: Select all
Console.WriteLine("1 - Play Game");
Console.WriteLine("2 - See Rules");
int pChoice = Convert.ToInt32(Console.ReadLine());
switch (pChoice)
{
case 1:
deck.Draw(ref player);
deck.Draw(ref player);
Debug.WriteLine("Player hand initialized.");
deck.Draw(ref opponent);
deck.Draw(ref opponent);
int turn = generator.Next(2);
switch (turn)
{
case 1:
if (turn == 1)
player.Turn(ref deck, ref player);
else
opponent.Turn(ref deck, ref player);
Console.ReadKey();
break;
case 2:
opponent.Turn(ref deck, ref player);
break;
}
break;
case 2:
ShowRules();
break;
}
Code: Select all
public void Draw(ref Player player)
{
Random generator = new Random();
bool used = false;
while (true)
{
int value = generator.Next(Names.Length);
string name = Names[value] + Suits[generator.Next(Suits.Length)];
for (int i = 0; i < Used.Length; i++)
{
if (name == Used[i])
{
used = true;
break;
}
if (Used[i + 1] == null)
{
break;
}
}
if (used == false)
{
cards--;
player.cards++;
Used[iter] = name;
iter++;
player.hand += name;
player.score += value;
Console.WriteLine("You drew a {0}!", name);
break;
}
}
}