# game_while.py
# Anne Bracy (awb93), Daisy Fan (kdf4)
# April, 2020
""" Module to play a word guessing game - use WHILE loop instead of recursion
"""

import random, wordGuess

def guess_the_word(secret, n_guesses_left):
    num_guesses= 0
    while num_guesses < n_guesses_left and not secret.is_solved():
        secret.print_word_so_far()
        user_guess= input("Guess a letter: ")
        num_guesses = num_guesses + 1
        secret.apply_guess(user_guess)

    # Loop ended. Which stopping condition kicked in?
    if secret.is_solved():
        print("YOU WIN!!!")
    else:
        print("Sorry you're out of guesses")


# from 100 Words to Make You Sound Great by Editors of the American Heritage Dictionaries
# https://www.hmhco.com/shop/books/100-Words-to-Make-You-Sound-Great/9780618883103
word_list = ["adamant", "affectation", "affinity", "allay", "amelioration", "amenable", "amoral", "assuage", "bauble", "beguile", "beset", "bulwark", "busybody", "complacent", "concomitant", "consign", "contend", "cosmopolitan", "culpable", "depravity", "derelict", "dissimulate", "dissipate", "distill", "dogmatic", "elicit", "epithet", "espouse", "expediency", "forestall", "furtive", "galling", "gloat", "gratuitous", "hallmark", "happenstance", "ignominious", "imperturbable", "ingratiate", "innocuous", "intemperate", "interpolate", "inure", "jingoism", "juggernaut", "ken ", "latent", "legacy", "ludicrous", "mandate", "maven", "mawkish", "modus operandi", "nefarious", "nicety", "nonchalance", "obdurate", "orthodoxy", "palliate", "patina", "penury", "pernicious", "perpetuate", "pittance", "pompous", "precipitate", "prescience", "profusion", "propensity", "pugnacity", "pusillanimous", "quip", "rankle", "reconciliation", "resiliency", "respite", "riposte", "sacrosanct", "scapegoat", "spurious", "squander", "supersede", "surreptitious", "tenacity", "tenuous", "travail", "truculence", "turpitude", "tyro", "unbridled", "uncanny", "urbane", "velleity", "venial", "verbose", "vexation", "vista", "wanton", "wheedle", "yammer"]

N_GUESSES = 10
print('You have '+str(N_GUESSES)+ ' chances to guess the secret word ...')
secret = wordGuess.SecretWord(random.choice(word_list))
guess_the_word(secret, N_GUESSES)
secret.reveal()
