#include "WheelBoard.h"

string WheelBoard::GetPhrase()
{
	return Phrase;
}
Revealed WheelBoard::GetBoolPhrase()
{
	return Bool_Phrase;
}
void WheelBoard::DisplayBoard()
{
	cout << endl << endl;
	for (int i=0; i < int(Phrase.length()); i++)
	{
		if (Bool_Phrase.B_Phrase[i] == true)
			cout << Phrase.at(i) << " ";
		else
			cout << "_ ";
	}
	cout << endl << endl;
}
void WheelBoard::MakeBoard()
{
	string Puzzle[MAX];
	int count = 0;
	ifstream in;
	in.open("Puzzle.txt");
	if (in.fail())
	{
		cerr << "Error reading puzzle file\n";
		exit(1);
	}
	getline(in, Puzzle[count]);
	while (!in.eof() && count < MAX)
	{
		count++;
		getline(in, Puzzle[count]);
	}
	in.close();
	srand((unsigned)time(NULL));
	int RandNum = rand() % count;
	Phrase = Puzzle[RandNum];
	for (int i=0; i < int(Phrase.length()); i++)
		Phrase.at(i) = toupper(Phrase.at(i));
	for (int i=0; i < int(Phrase.length()); i++)
	{
		if (isalpha(Phrase.at(i)))
			Bool_Phrase.B_Phrase[i] = false;
		else
			Bool_Phrase.B_Phrase[i] = true;
	}
}
int WheelBoard::LetterInPuzzleCount(char letter)
{
	int count = 0;
	for (int i=0; i < int(Phrase.length()); i++)
	{
		if (Phrase.at(i) == letter)
		{
			Bool_Phrase.B_Phrase[i] = true;
			count++;
		}
	}
	return count;
}