using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using System.Threading.Tasks;
namespace JoyceDamienCWGnew
{
class GameOfWar
{
static int[] deck = new int[52]; // all zero by default
static int count = 0;
static string result;
static string[] cards = { "Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King" };
static string[] suits = { "Hearts", "Clubs", "Diamonds", "Spades" };
static Random rnd = new Random();
static void Main(string[] args)
{
int totalCompScore = 0;
int totalPlayerScore = 0;
string playerName;
int i;
//Entering the players name
Console.Write("Warrior please enter your name here: ");
playerName = Console.ReadLine();
FillDeck();
//====================================================================================================
//deal the deck 26 times
//for loop
for (i = 0; i < 26; i++)
{
string playerSuit;
string compSuit;
int compCard = SelectCard(compSuit) - 1;
int playerCard = SelectCard(playerSuit) - 1;
//if statement for the card number
if(compCard < playerCard)
{
totalPlayerScore += 2;
}//if
else if(playerCard < compCard)
{
totalCompScore += 2;
}//else if
else
{
totalCompScore += 1;
totalPlayerScore += 1;
}//else
//if statement for the suit
//Output after each deal
Console.WriteLine("Deal {0}: ", i + 1);
Console.WriteLine("Computer's card {1} {2} ", cards[compCard], compSuit);
Console.WriteLine("{0} card {1} {2}", playerName, cards[playerCard], playerSuit);
Console.WriteLine("");
}//for loop
Console.WriteLine("Computer's total score : {0}", totalCompScore);
Console.WriteLine("{0} total score : {1}", playerName, totalPlayerScore);
Console.ReadKey();
}//main
//=====================================================================================================================================
static void FillDeck()
{
//For Loop
for (int i = 0; i < 52; i++)
{
//While Loop
while (true)
{
int num = rnd.Next(1, 53); // get number between 1 and 52 inclusive
if (Array.IndexOf(deck, num) == -1) // not already used
{
deck[i] = num;
break;
}//if
}//while
}//for
}//FillDeck
static int SelectCard(string suit)
{
int num = deck[count];
count++;
// suit = suits[(num - 1) % 4];
return count; // (num - 1) / 4 + 1;
}//SelectCard()
}//GameOfWar
}//JoyceDamienCWGnew