#
# This class models the state of the hangman game. The class
# includes the following attributes:
#   secretStr - the secret word, as a string
#   secretSet - the secret word as a set of letters
#   guessed   - the set of correct letters guessed 
# All letters are lowercase. The first two ae initialised in the constructor
# and do not change. There is NO record of the number of incorrect guesses in 
# this class.
#
# The class has the methods:
#    makeGuess - next letter guessed. Return true if the letter is correct
#                (in word and not peviously guessed). Update the guessed set
#    isCompleted - return true is all letters guessed
#    getCompletion - return a string of the form: _ n _ s _ _ _ showing the
#                    letters guessed and remaining


class Game:

    def __init__(self, word):
        self.secretStr = word     # the word we are trying to guess       
        self.secretSet = set(word)  # the set of letters in the secret word
        self.guessed = set()        # the correct letters guessed

    def isCompleted(self):
        return self.secretSet == self.guessed

    def makeGuess(self, letter):
        if letter in self.secretSet - self.guessed:
            self.guessed.add(letter)
            return True
        return False

    def getCompletion(self):
        s = ""
        for l in self.secretStr:
            if l in self.guessed:
                s = s + l + " "
            else:
                s = s + "_ "
        return s
                
