#ifndef _COMPUTEROPPONENT
#define _COMPUTEROPPONENT

#include "WordList.h"
#include "Word.h"
#include "FileInterface.h"
#include "RndWordGenerator.h"
#include "ScoreCard.h"
#include "GuessList.h"

	class ComputerOpponent{

	private:

		enum gameState {lost, won, inProgress, notStarted};

		int theGameState;	// equals lost, won, or inProgress.
		int numWordsUsed;	// keeps track of the number of words that have been used
							// in the current game so far.

		WordList theWordList;	// holds a list of word objects.
		FileInterface theFileInterface;	// object that allows file handling.
		Word theSecretWord;	// word to be guessed by user.
		RandomWordGenerator theRandWordGenerator;	// object that picks words at random.
		ScoreCard theScoreCard;	// keeps track of the users score.
		PreviouslyUsedGuessList theUsedGuessList;	// keeps a list of all words used.

		void updateGameState();
		//		
		// post-condition: Checks to see if player has guesses left and if they have won or lost.
		//				   Updates theGameState variable to appropriate value, and changes score
		//				   card if need be.
		//

		int validateLetter(char &guess);
		//		
		// post-condition: checks that guess is valid i.e. a letter.
		//				   If valid it is converted to
		//				   upper case if it is in lower case and returns value 1..
		//				   If guess is not a letter the value returned is 0 (FALSE).

	public:

		ComputerOpponent();
		//		
		// post-condition: initialises private member variables.
		//

		int startNewGame(char theFileName[]);
		//		
		// post-condition: Sets up a new game and chooses word from
		//				   the file specified in theFileName parameter.
		//				   Returns 1 if successful, zero if not.
		//

		void getSecretWord(char secretWord[]);
		//
		// post-condition: Copies secret word e.g '*** ****' into 
		//				   array used as parameter.
		//				   The secret word contains letters which
		//                 have been guessed correctly.

		void getCategory(char category[]);
		//
		// post-condition: Copies category name into 
		//				   array used as parameter.
		//				   category[] must be have [MaxWordLength] array elements.

		void getUsedGuessList(char list[MaxGuessListLength]);
		//		
		// post-condition: 
		//

		void getScore(int &gamesPlayed, int &gamesWon);
		//		
		// post-condition: Copies number of games played and won into parameters.
		//				   

		int getNumGuessesLeft();
		//		
		// post-condition: returns number of guesses the player has left.
		//

		int checkGuess(char guess);
		//		
		// post-condition: checks to see if letter is in word. Returns 1 if true, 0 if false.
		//

		int getGameState();
		//		
		// post-condition: returns value in theGameState variable.
		//				   1 = Lost
		//				   2 = Won
		//				   3 = InProgress
		//

		int chooseNewWord();
		//		
		// post-condition: Chooses a new secret word.
		//				   Return value equals 1 if a new word has been chosen succesfully,
		//  			   equals 0 otherwise.
		//

		void getUncoveredWord(char uncoveredWord[]);
		//		
		// post-condition: The phrase revealed is copied into uncoverdWord parameter.
		//
		
		void resetComputerOpponent();
		//		
		// post-condition: Sets gameState to notStarted, re-initilises private variables.
		//
	};

#endif
