#include <iostream>
#include <cstdlib>
#include <ctime>
#include <string>
#include <cctype>
#include <fstream>
using namespace std;

/*
Pair Project 2: Hangman 
DUE: 12/07/2025 11:59pm
- Please name this sourcecode file like "username_hangman.cpp" - using your banner name and email as an attachment to: james.dittrich+YSU@gmail.com
- List all members of the group (name and email here in the comments.)
- Include your datafile (data.csv) for testing purposes as a separate attachment.
*/

// maximum size of the answer bank:
#define MAXSIZE 10

// struct for the answer bank (build an array):
struct wordItem{
	string word;
	string hint;
};

void drawGallows(int incorrect){
	if(incorrect==0){
		// empty display
		cout << endl;
		cout << endl;
		cout << endl;
		cout << endl;
		cout << endl;
		cout << endl;
		cout << endl;
	}else if(incorrect==1){
		cout << endl;
		cout << endl;
		cout << endl;
		cout << endl;
		cout << endl;
		cout << endl;
		cout << "  =======" << endl;
	}else if(incorrect==2){
		cout << endl;
		cout << "     |" << endl;
		cout << "     |" << endl;
		cout << "     |" << endl;
		cout << "     |" << endl;
		cout << "    /|\\" << endl;
		cout << "  =======" << endl;
	}else if(incorrect==3){
		cout << " _____" << endl;
		cout << " |   |" << endl;
		cout << "     |" << endl;
		cout << "     |" << endl;
		cout << "     |" << endl;
		cout << "    /|\\" << endl;
		cout << "  =======" << endl;
	}else if(incorrect==4){
		cout << " _____" << endl;
		cout << " |   |" << endl;
		cout << " 0   |" << endl;
		cout << "     |" << endl;
		cout << "     |" << endl;
		cout << "    /|\\" << endl;
		cout << "  =======" << endl;
	}else if(incorrect==5){
		cout << " _____" << endl;
		cout << " |   |" << endl;
		cout << " 0   |" << endl;
		cout << "/|   |" << endl;
		cout << "     |" << endl;
		cout << "    /|\\" << endl;
		cout << "  =======" << endl;
	}else if(incorrect==6){
		cout << " _____" << endl;
		cout << " |   |" << endl;
		cout << " 0   |" << endl;
		cout << "/|\\  |" << endl;
		cout << "     |" << endl;
		cout << "    /|\\" << endl;
		cout << "  =======" << endl;
	}else if(incorrect==7){
		cout << " _____" << endl;
		cout << " |   |" << endl;
		cout << " 0   |" << endl;
		cout << "/|\\  |" << endl;
		cout << "/    |" << endl;
		cout << "    /|\\" << endl;
		cout << "  =======" << endl;
	}else{
		cout << " _____" << endl;
		cout << " |   |" << endl;
		cout << " 0   |" << endl;
		cout << "/|\\  |" << endl;
		cout << "/ \\  |" << endl;
		cout << "    /|\\" << endl;
		cout << "  =======" << endl;
    cout << endl;
    for(int i=0;i<21;i++){
		  cout << "YOU LOSE!!! ";
    }
    cout << endl;
	}
	return;
}

// MAIN PROGRAM

int main(){

	wordItem wordList[MAXSIZE];
	string temp;

	ifstream inputFile;
	int count = 0;

	inputFile.open("data.csv");

	// If the file successfully opened, process it.
	if(inputFile){
		// Read the word-hint pairs from the file
		while (inputFile >> temp && count < MAXSIZE){
			// DEBUG: display the item read
			cout << temp << endl;
			
			// TODO: split the temp string into pairs
			// TODO: append the items in the pair into the list

			// DEBUG: display them
			cout << "word: " << wordList[count].word << endl;
			cout << "hint: " << wordList[count].hint << "\n" << endl;
			
			// move to the next list item
			count++;
		}
		// Close the file.
		inputFile.close();
	}else{
		// Display an error message.
		cout << "Error opening data.csv\n";
	}
	cout << "The word list contains: " << count << " items." << endl;

	for (int n=0; n<=8; n++){
		drawGallows(n);
    	cout << endl;
	}

	return 0;
}
