# HangMan Game - main program
#

# Import the classes
from Words import Words
from Game import Game
from Scaffold import Scaffold

# Create an object of the three classes, choosing
#  the secret word.
ws = Words()
g = Game(ws.chooseWord())
s = Scaffold() 
print("I have chosen a secret word:")

# Initialise a flag and counter
complete = False
count = 0

# Repeatedly prompt the player to guess a letter until 
#   the word or the scaffold are complete
while count < 6 and not complete:
    print("   ", g.getCompletion(), "\n")
    l = ""
    while len(l) != 1:
        l = input("Guess a letter:").lower()
    res = g.makeGuess(l)
    if res:
        print("Good guess", l, "is correct")
        complete = g.isCompleted()
    else:
        count += 1
        print("Bad luck", l, "is wrong")
    s.draw(count)

# Print a message dependng on how the game ended
if count == 6:
    print("You have lost. Game over")
if complete:
    print("   ", g.getCompletion(), "\n")
    print("You have won. Well done")


