#include <stdio.h>
#include "tone.h"


int main(void){
	//declare a card to hold the king of hearts
	card kingofhearts;
	kingofhearts.value = 13;
	kingofhearts.label = 'K';
	kingofhearts.suit = 'H';

	//and the king of spades
	card kingofspades;
	kingofspades.value = 13;
	kingofspades.label = 'K';
	kingofspades.suit = 'S';

	//and the king of diamonds
	card kingofdiamonds;
	kingofdiamonds.value = 13;
	kingofdiamonds.label = 'K';
	kingofdiamonds.suit = 'D';

	//and the queen of diamonds
	card queenofdiamonds;
	queenofdiamonds.value = 12;
	queenofdiamonds.label = 'Q';
	queenofdiamonds.suit = 'D';

	printf("Testing cardString.\n");
	printf("\tCard string for queen of diamonds is: ");
	char c[100];
	cardString(queenofdiamonds, c);
	printf("%s\n",c);


	printf("Testing isRed and isBlack.\n");

	printf("\tIs the king of hearts red? ");
	if (isRed(kingofhearts)){
		printf("\t\tYes.\n");
	}
	else{
		printf("\t\tNo.\n");
	}

	printf("\tIs the king of hearts black? ");
	if (isBlack(kingofhearts)){
		printf("\t\tYes.\n");
	}
	else{
		printf("\t\tNo.\n");
	}
	printf("\tIs the king of spades red? ");
	if (isRed(kingofspades)){
		printf("\t\tYes.\n");
	}
	else{
		printf("\t\tNo.\n");
	}

	printf("\tIs the king of spades black? ");
	if (isBlack(kingofspades)){
		printf("\t\tYes.\n");
	}
	else{
		printf("\t\tNo.\n");
	}

	printf("Testing compareCards.\n");
	printf("\tDoes the king of spades have the same value as the king of hearts? \n");
	if (compareCards(kingofspades, kingofhearts) == 0){
		printf("\t\tYes.");
	}
	else{
		printf("\t\tNo.");
	}

	printf("\tDoes the king of spades have the same value as the queen of diamonds? \n");
	if (compareCards(kingofspades, queenofdiamonds) == 0){
		printf("\t\tYes.");
	}
	else{
		printf("\t\tNo.");
	}
	
	printf("Testing printDeck.\n");
	//put all four cards into a deck
	int ncards = 4;
	card deck[10];
	deck[0] = kingofhearts;
	deck[1] = kingofspades;
	deck[2] = kingofdiamonds;
	deck[3] = queenofdiamonds;

	printf("Deck: \n");
	printDeck(deck, ncards);

	printf("Testing containsCard.\n");
	printf("\tDoes the deck contain a king of hearts? \n");
	int x = containsCard(deck, ncards, kingofhearts);
	if (x != -1){
		printf("\t\tYes, at index %d.\n",x);
	}
	else{
		printf("\t\tNo.\n");
	}

	card tenofhearts;
	tenofhearts.suit = 'H';
	tenofhearts.value = 10;
	tenofhearts.label = 'T';
	printf("\tDoes the deck contain a ten of hearts? \n");
	x = containsCard(deck, ncards, tenofhearts);
	if (x != -1){
		printf("\t\tYes, at index %d.\n",x);
	}
	else{
		printf("\t\tNo.\n");
	}

	printf("Testing containsMatch.\n");
	printf("\tDoes the deck contain a match for the ten of hearts? \n");
	x = containsMatch(deck, ncards, tenofhearts);
	if (x != -1){
		printf("\t\tYes, at index %d.\n",x);
	}
	else{
		printf("\t\tNo.\n");
	}

	printf("Does the deck contain a match for the king of hearts?\n");
	x = containsMatch(deck, ncards, kingofhearts);
	if (x != -1){
		printf("\t\tYes, at index %d.\n",x);
	}
	else{
		printf("\t\tNo.\n");
	}

	printf("Testing addToDeck.\n");
	printf("\tThe deck before adding the ten of hearts: \n");
	printDeck(deck, ncards);

	addToDeck(deck, tenofhearts, &ncards);
	printf("\tThe deck after adding the ten of hearts: \n");
	printDeck(deck, ncards);

	printf("Testing removeCard.\n");
	
	removeCard(deck, &ncards, 0);
	printf("\tThe deck after removing the first card: ");
	printDeck(deck, ncards);

	printf("Testing drawCard.\n");
	card t;
	bool wasCard = drawCard(deck,&t, &ncards);
	printf("\tWas there a card to draw? \n");
	if (wasCard){
		char cardstr[100];
		cardString(t, cardstr);
		printf("\t\tYes. The card I drew was %s\n", cardstr);
	}
	else{
		printf("\t\tNo.\n");
	}

	printf("Testing combineDecks.\n");
	printf("\tFirst deck: \n");
	printDeck(deck, ncards);

	int n = 2;
	card deck2[2];
	deck2[0] = kingofhearts;
	deck2[1] = kingofdiamonds;
	printf("\tSecond deck: \n");
	printDeck(deck2,n);
	
	combineDecks(deck, &ncards, deck2, &n);
	printf("\tCombined deck: \n");	
	printDeck(deck, ncards);

	printf("Testing shuffleCards.\n");
	shuffleCards(deck, ncards);
	printf("\tDeck after shuffling: ");
	printDeck(deck,ncards);

	return 0;
}
