#main_game_20 added global commands  updated May 25, 2015
import random
import sys
import os
import time

print("\n\nStart of run of main_game_14.py\n\n")

#May 3   still to do
##extend replace words function  done  4/28
## could put in version local to each location  (e.g. down vs jum pin...(
##modify to use data files for game
##add in some hints
##add in some complicating story lines


##This code will start the game in the homeRoom location and then
##respond to user commands.   The commands will be able navigate to other
##rooms and ask for help.   Going east from the redRoom will "win" the game.

#start game

#need functions:

# get_command
# do_command
# do_move
# give_ans
# exit_game
    # get_data    gets all the data for the game
    
#########################################  global data   ###########################################
#"global" data, defined oursid of funcionts... could be 'global" in function.

    #####################################################

######################################################################

def heather_func():

    print ("\n\nWelcome to Heather's Math Room!")

    print ("\nALERT USER!","You are now trapped in this room!")

    print ("If you try to escape, you will be denied access.")

    print ("To leave, you must answer five mathematical questions that get progressively harder.")



    status = "Q1"



    #question 1

    while (status == "Q1"):

        print ("---")

        print ("What is 1 + 1? ",end="")

        num_str_q1 = sys.stdin.readline()

        num_str_q1 = num_str_q1.rstrip()

        num_q1 = int(num_str_q1)

        if num_q1 == 2:

            print ("Correct!","Four more questions left!")

            status = "Q2"

        else:

            print ("\nYou have answered incorrectly - what a shame.")

            print ("You will now go back to the first question.")

            status = "Q1"



    #question 2

    while (status == "Q2"):

        print ("---")

        print ("What is 3 x 10? ",end="")

        num_str_q2 = sys.stdin.readline()

        num_str_q2 = num_str_q2.rstrip()

        num_q2 = int(num_str_q2)

        if num_q2 == 30:

            print ("\nCorrect!","Three more questions left!")

            status = "Q3"

        else:

            print ("\nYou have answered incorrectly - what a shame.")

            #print ("You will now go back to the first question.")
            print("You should be sent back to the first question !\n")
            print("However, this program keeps you here...\n")

            status = "Q2"



    #question 3

    while (status == "Q3"):

        print ("---")

        print ("What is the square root of 144? ",end="")

        num_str_q3 = sys.stdin.readline()

        num_str_q3 = num_str_q3.rstrip()

        num_q3 = int(num_str_q3)

        if num_q3 == 12:

            print ("\nCorrect!","Two more questions left!")

            status = "Q4"

        else:

            print ("\nYou have answered incorrectly - what a shame.")

            #print ("You will now go back to the first question.")
            print("You should be sent back to the first question !\n")
            print("However, this program keeps you here...\n")

            status = "Q3"



    #question 4

    while (status == "Q4"):

        print ("---")

        print ("Firstly, pi/3 is measured in radians, which is a form of angle measurement.")

        print ("In radians, pi = 180.")

        print ("What is pi/3 in degrees? ",end="")

        num_str_q4 = sys.stdin.readline()

        num_str_q4 = num_str_q4.rstrip()

        num_q4 = int(num_str_q4)

        if num_q4 == 60:

            print ("\nCorrect!","One more question left!")

            status = "Q5"

        else:

            print ("\nYou have answered incorrectly - what a shame.")

            #print ("You will now go back to the first question.")
            print("You should be sent back to the first question !\n")
            print("However, this program keeps you here...\n")

            status = "Q4"



    #question 5

    while (status == "Q5"):

        print ("---")

        print ("Common log has a base of 10.")

        print ("What is the value of log(100)? ",end="")

        num_str_q5 = sys.stdin.readline()

        num_str_q5 = num_str_q5.rstrip()

        num_q5 = int(num_str_q5)

        if num_q5 == 2:

            print ("Correct!","You won.")

            status = "finish"

        else:

            print ("\nYou have answered incorrectly - what a shame.")

            #print ("You will now go back to the first question.")
            print("\nYou should be sent back to the first question !\n")
            print("However, this program keeps you here...\n")

            status = "Q5"

            

    if (status == "finish"):

            print ("---")

            #print ("Congratulations!","You win a Red Key.")
            print ("\nCongratulations!","You may now get the redKey\n")
            return("completed")
                

        #PUT RED KEY INTO INVENTORY!!

    else:

            status = "Q1"  #will never get to here
            return("failed")

        ############   end of function ####################
##############################################################

def dylan_func():
    print("\n\nWelcome to Dylan`s Room")

    print("You will have options you can go through")

    print("one death one life")

    print("\nIt will be your decision of what door you pick")



    door1="\nYOU LIVE|\n"

    door2="\nyou have died\n"

    print("window or trap door : ",end="")



    answer = sys.stdin.readline()

    answer = answer.rstrip()



    if answer== "trap door": print (door1)
    elif answer == "door": print(door1)
    elif answer== "window": print (door2)
    else: print (
        """\n\nThat's not an answer Dylan wanted, but he
did not deal with that possibility.. so you get to live!\n\n""")
    print("\n\n")
    return("completed")
#################################################

def EvansFunction():
    print("\n\nWelcome to Evan's Room! Enter your favorite color and press ENTER key :", end="")
    color = sys.stdin.readline()
    print("Your favorite color is",color)
    color=color.rstrip()
    return(color)

def bluefunc():
    print("Hmm. Do you have any blue items by chance?",end="")
    blueitem=sys.stdin.readline()
    blueitem=blueitem.rstrip()
    if blueitem=="bird":
        print("You've come from the ____ room I see. You may now proceed south.")
        status="done"
    else:
        print("That doesn't look very blue to me...")

def evan_func():
    
    var=EvansFunction()
    if (var=="blue"):
        blueitem=bluefunc()
    status="inloop"
    while status=="inloop":
        if var=="blue":
            bluefunc()
            status="done"
        else:
            print("Hmm.")
            status="done"

    print("\n\n")
    return("completed")
#################################

def adam_func():

	print("\n\nHello and welcome to Adam's room. \nANSWER ALL QUESTIONS BEGINNING WITH A CAPITAL LETTER!!!")
	print("I will ask you some random questions and then you (might) be able to leave.")
	print("What is the answer to life? ",end="")

	User_Input = sys.stdin.readline()
	User_Input = User_Input.rstrip()

	if (User_Input == "Barnold"):
		print("You got it right!")
	else:
		print("Wrong! The correct answer was: Barnold")

	print("\nDo you like pie? ",end="")
	User_Input = sys.stdin.readline()
	User_Input = User_Input.rstrip()

	if (User_Input == "Yes"):
		print("Me too!")
	if (User_Input == "No"):
		print("Ah, a cake lover. I see how it is.")
	if (User_Input == "Maybe"):
		print("You see it doesn't work like that. You either like it or dislike it.")
	if (User_Input == "Barnold"):
		print("ALL PRAISE BARNOLD")

	print("\nDo you want to know the current time? ",end="")
	The_Other_Half_of_Half_of_the_Current_Time=time.strftime("%M")
	Half_the_Time_of_the_Current_time=time.strftime("%I")
	time=time.strftime("%I:%M")
	User_Input = sys.stdin.readline()
	User_Input = User_Input.rstrip()
	if (User_Input == "Yes"):
		print("The current time is, ",time)
	if (User_Input == "No"):
		print("Okeedokee")
	if (User_Input == "Barnold"):
		print("All the time is Barnold time")
	if (User_Input == "Maybe"):
		print("Fine, I will give you half the time.\nHalf the time of the current time (which in this case is just the hour of the \ncurrent time hence half the current time) is, ",Half_the_Time_of_the_Current_time,"(that was just the hour)\nOr in case you wanted to know the minutes of the current time then that is, ",The_Other_Half_of_Half_of_the_Current_Time,"(minutes of course)")

	print("\nDo you wish to leave? ",end="")
	User_Input = sys.stdin.readline()
	User_Input = User_Input.rstrip()
	if (User_Input == "Yes"):
		print("I'm sorry but I can't let you leave")
	if (User_Input == "No"):
		print("Good, because I wouldn't have let you anyways")
	if (User_Input == "Barnold"):
		print("Alright you may leave")

	print("\nThough Adam did not want you to leave..he did not give you a second chance.. so I'm letting you out.  Harry\n\n")
	return("completed")



    #This is my very simple room




########################################################

def load_cmd_dicts( loc_to_load,list_of_cmd_lists):
# for each list in  list_of_cmd_lists it loads a_cmd_dict with data and then adds a_cmd_dict to a_loc_dict["commands"]

    def load_cmd_dict(loc_to_load, cmd_list):    #command list is  name, type, arg1
                global locs_dict
                a_loc_dict = locs_dict[loc_to_load]
                a_cmd_dict = {}
                a_cmd_dict["command"] = cmd_list[0]
                a_cmd_dict["type"] = cmd_list[1]
                type = cmd_list[1]
                if (type == "move"):
                     a_cmd_dict["to_loc"] = cmd_list[2]
                elif (type == "ask"):
                     a_cmd_dict["ans"] = cmd_list[2]
                elif (type == "func"):
                     a_cmd_dict["func"] = cmd_list[2]
                cmds_dict = a_loc_dict["commands"]  #created empty dictionary before first call to this function
                cmds_dict[a_cmd_dict["command"]] = a_cmd_dict
        
                a_loc_dict["commands"] = cmds_dict

                return(a_loc_dict)
        #end of load_cmd_dict function

    global locs_dict
    for a_cmd_list in list_of_cmd_lists:
        a_loc_dict = load_cmd_dict(loc_to_load, a_cmd_list)
    return(a_loc_dict)
    #end of load_cmd_dicts  function

def load_loc_data2(loc_data_list):
                global locs_dict
                a_loc_dict = {}
                #loc_data_list = ["gen","Storage of general commands","none","""Welcome to the gen Room""" ]
              
                a_loc_dict["name"] = loc_data_list[0]
                
                a_loc_dict["long_name"] = loc_data_list[1]
               
                a_loc_dict["loc_msg"] = loc_data_list[2]
                
                a_loc_dict["num_visits"] = loc_data_list[3]
               
                a_loc_dict["auto_func"] = loc_data_list[4]
                
                a_loc_dict["func_status"] = loc_data_list[5]
                
                a_loc_inv = []  #empty list, will contain list of names of ojects in this locaton
                a_loc_dict["loc_inv"] = a_loc_inv
                a_loc_dict["commands"] = {}
                return(a_loc_dict)
                #end of load_loc_data function


def load_loc_data(loc_data_list):
                global locs_dict
                a_loc_dict = {}
                #loc_data_list = ["gen","Storage of general commands","none","""Welcome to the gen Room""" ]
                msg_str = "in load_loc_data  "+loc_data_list[0]
                ##167(msg_str)
                a_loc_dict["name"] = loc_data_list[0]
                ##show_gen_name(msg_str)
                a_loc_dict["long_name"] = loc_data_list[1]
                #show_gen_name(msg_str)
                a_loc_dict["loc_msg"] = loc_data_list[2]
                #show_gen_name(msg_str)
                a_loc_dict["num_visits"] = loc_data_list[3]
                #show_gen_name(msg_str)
                a_loc_dict["auto_func"] = loc_data_list[4]
                #show_gen_name(msg_str)
                a_loc_dict["func_status"] = loc_data_list[5]
                #show_gen_name(msg_str)
                a_loc_inv = []  #empty list, will contain list of names of ojects in this locaton
                a_loc_dict["loc_inv"] = a_loc_inv
                msg_str = "at end  load_loc_data  "+loc_data_list[0]+"\n"
                #show_gen_name(msg_str)
                a_loc_dict["commands"] = {}
                return(a_loc_dict)
        #end of load_loc_data function
            
def show_gen_name(msg):
    global locs_dict
    print("in #show_gen_name ", end = "")
    a_loc_dict = locs_dict["gen"]
    loc_name = a_loc_dict["name"]
    print ("XXXXXXXXXXXXXXX ",msg, "   name stored in a_loc_dict for gen is ", loc_name)


def get_data():
    global locs_dict
    #print("get_data started ")
    #locs_dict = {} # will contain one dictionary (a_loc_dict) for each location  (homeRoom, blueRoom, redRoom, blackRoom, gen, etc. )

    #note  locs_dict is a dictionary of locations,   each location is a dictionary of data (a_loc_dict)
    #the keys for loc_dict are the names of the locations (e.g. blueRoom,  redRoom etc. )
    #the keys used in each location dictionary (a_loc_dict) are the names of the data items (name, long_name, type, "commands", etc.  )

    #the data item in a_loc_rec with the key "commands" is a dictionary  (cmds_dict).
    #the keys used in the cmds_dict dictionary  (cmds_dict)  are the commands (e.g "go south",  "go_north", "exit"  etc. )
    #Each item in that dictionary is a dictionary for a specific command ( a_cmd_dic)

    #the keys used in each a_cmd_dic dictionary  are the names of the data items in the command ( "command", "type", "to_loc_name", "ans" etc)

    #in case this seems a little confusing... well it can be, but it will work- I hope

    # a_cmd_dict dictonary for each command is an item in the cmds_dict dictionary.  The comds_dict_dictionary is an item in the a_loc_dict
    # and each a_loc_dict is an item in the locs_dict dictionary.
    #So with a_cmd_dict we have a dictionary (a_cmd_dict) inside a dictionary (cmds_dict) inside a dictionary (a_loc_rec) inside a dictionary. (locs_dict).
    # thats a dictionary 4 levels deep



######### create loc_dict for location     "gen",  general commands accesible from anywhere  ###########################
    a_loc_dict = {}
    #print("loc data for gen")

    # data for keys : name, long_name, auto_func, and loc_msg
    loc_data_list = ["gen","Storage of general commands","""Welcome to the gen Room""",
                     0,  #number of times this room has been visited.  key  num_visits
                     "none",  #for use with autoFucn  key auto_func,  contents could be "none"
                     "not_set"  #to be filled in when func runs.    key = func_status
                     ]
    a_loc_dict = load_loc_data2(loc_data_list)  # loads data from list into a_loc_dict for appropriate keys
    
    loc_name = a_loc_dict["name"]
    locs_dict[loc_name] = a_loc_dict
    
    loc_name = a_loc_dict["name"]
    #print ("inside gen data section,  name stored in a_loc_dict is ",loc_name)

    list_of_cmd_lists = [
                ["go homeRoom","move","homeRoom"],
                            ["help","ask",
"""Well done.  There is not much help available so far..
but you can use 'go homeRoom' to go to that room
from anywhere. """],
                ["look","ask","LOOK"],
                                ["inventory","func","inventory"]
                ]
    #cmds_dict = a_loc_dict["commands"] 

    #a_loc_dict["commands"] = {}  #to be filled in by load_cmd_dict
    loc_name = loc_data_list[0]
    a_loc_dict = load_cmd_dicts( loc_name,list_of_cmd_lists)
    # for each list in  list_of_cmd_lists it loads a_cmd_dict with data and then adds a_cmd_dict to a_loc_dict["commands"]

    a_cmds_dict = a_loc_dict["commands"]
    list_of_cmds = list(a_cmds_dict.keys())
    #print("commands put into gen location are : ",list_of_cmds)

  
    loc_name = a_loc_dict["name"]
    locs_dict[loc_name] = a_loc_dict   # put location dictionary into dictionary of of locations
    #print("in get_data  a_loc_dict for gen was put in ", a_loc_dict["name"])

    #show_gen_name("af868 gen")
    #print ("\nin getdata after gen")
    #show_all_commands("gen")


######### create loc_dict for homeRoom#####################################################
    a_loc_dict = {}
    # print("loc data for homeRoom")
    #show_gen_name("start of  homeRoom")
    # data for keys : name, long_name, synch, and loc_msg
    loc_data_list = ["homeRoom","This is the Home Room" ,
"""You are in the Home room of this game.  there are  doors in this room.
try one or two word commands to leave the room. """,
                     0,  #number of times this room has been visited.  key  num_visits
                     "dylan_func",  #for use with autoFucn  key auto_func,  contents could be "none"
                     "not_set"  #to be filled in when func runs.    key = func_status
                    ]

    a_loc_dict["commands"] = {}  #to be filled in by load_cmd_dict

    

    #show_gen_name("before load_loc_data in homeRoom")
    a_loc_dict = load_loc_data(loc_data_list)  # loads data from list into a_loc_dict for appropriate keys
    
    
    
    locs_dict[a_loc_dict["name"]] = a_loc_dict
    #show_gen_name("after load_loc_data in homeRoom")
    list_of_cmd_lists = [
                ["go west","move","redRoom"],
                ["go east","move","blackRoom"],
                ["go south","move","blueRoom"]
                ]

    loc_name = loc_data_list[0]

    
    a_loc_dict = load_cmd_dicts( loc_name,list_of_cmd_lists)

    
    # for each list in  list_of_cmd_lists it loads a_cmd_dict with data and then adds a_cmd_dict to a_loc_dict["commands"]
    #show_gen_name("after load_cmd_dicts in homeRoom")
    
    locs_dict[a_loc_dict["name"]] = a_loc_dict   # put location dictionary into dictionary of of locations
    
    #print("in get_data  a_loc_dict for homeRoom was put in ", a_loc_dict["name"])

    #show_gen_name("after homeRoom")
    #print ("\nin getdata after homeroom")
    #show_all_commands("gen")


########## create loc_dict for blackRoom#####################################################
    a_loc_dict = {}
    #print("loc data for blackRoom")

    # data for keys : name, long_name, auto_func, and loc_msg
    loc_data_list = ["blackRoom","This is the Black Room" ,
"""You are in the Black  room of this game.  there is at
least one door in this room.""",
                     0,  #number of times this room has been visited.  key  num_visits
                     "heather_func",  #for use with autoFucn  key auto_func,  contents could be "none"
                     "not_set"  #to be filled in when func runs.    key = func_status
                    ]
    a_loc_dict = load_loc_data(loc_data_list) # loads data from list into a_loc_dict for appropriate keys
    locs_dict[a_loc_dict["name"]] = a_loc_dict

    a_loc_dict["commands"] = {}

    list_of_cmd_lists = [
                ["go west","move","homeRoom"],
                        ]
    loc_name = loc_data_list[0]
    a_loc_dict = load_cmd_dicts( loc_name,list_of_cmd_lists)
    # for each list in  list_of_cmd_lists it loads a_cmd_dict with data and then adds a_cmd_dict to a_loc_dict["commands"]

    locs_dict[a_loc_dict["name"]] = a_loc_dict   # put a location dictionary into dictionary of of locations
    
    #show_gen_name("after blackRoom")
    

########## create loc_dict  for blueRoom##########################################################
    a_loc_dict = {}
    #print("loc data for blueRoom")

    # data for keys : name, long_name, auto_func, and loc_msg
    loc_data_list = ["blueRoom","This is the Blue Room" ,
"""You are in the Blue  room of this game.  there is
at least one door in this room.""",
                     0,  #number of times this room has been visited.  key  num_visits
                     "adam_func",  #for use with autoFucn  key auto_func,  contents could be "none"
                     "not_set"  #to be filled in when func runs.    key = func_status
                     ]
    a_loc_dict = load_loc_data(loc_data_list)  # loads data from list into a_loc_dict for appropriate keys
    locs_dict[a_loc_dict["name"]] = a_loc_dict

    a_loc_dict["commands"] = {}

    list_of_cmd_lists = [
                ["go north","move","homeRoom"]
                        ]
    loc_name = loc_data_list[0]
    a_loc_dict = load_cmd_dicts( loc_name,list_of_cmd_lists)
    # for each list in  list_of_cmd_lists it loads a_cmd_dict with data and then adds a_cmd_dict to a_loc_dict["commands"] dictionary


    locs_dict[a_loc_dict["name"]] = a_loc_dict   # put location dictionary into dictionary of of locations

    #show_gen_name("after blueRoom")

########## create loc_dict for redRoom###############################################################
    a_loc_dict = {}
    #print("loc data for blueRoom")

    # data for keys : name, long_name, auto_func, and loc_msg
    loc_data_list = ["redRoom","This is the Red Room" ,
"""You are in the red room of this game.  there are two doors in this room.""",
                     0,  #number of times this room has been visited.  key  num_visits
                     "evan_func",  #for use with autoFucn  key auto_func,  contents could be "none"
                     "not_set"  #to be filled in when func runs.    key = func_status
                     ]
    a_loc_dict = load_loc_data(loc_data_list)   # loads data from list into a_loc_dict for appropriate keys
    locs_dict[a_loc_dict["name"]] = a_loc_dict

    a_loc_dict["commands"] = {}

    list_of_cmd_lists = [
                ["go east","move","homeRoom"],
                ["go west","move","valley_1"]
                        ]
    loc_name = loc_data_list[0]
    a_loc_dict = load_cmd_dicts( loc_name,list_of_cmd_lists)
    locs_dict[a_loc_dict["name"]] = a_loc_dict
    # for each list in  list_of_cmd_lists it loads a_cmd_dict with data and then adds a_cmd_dict to a_loc_dict["commands"]

    locs_dict[a_loc_dict["name"]] = a_loc_dict   # put location dictionary into dictionary of of locations
    #show_gen_name("after redRoom")

    

########## create loc_dict for valley_1###############################################################
    a_loc_dict = {}
    #print("loc data for valley_1")

    # data for keys : name, long_name, auto_func, and loc_msg
    loc_data_list = ["valley_1","This is a lovely Valley" ,
"""You are in a lush green valley.  There is a clear bubbling stream
nearby.    At the moment... there is no place else to go.  You
will have to go back in the building.
""",
                     0,  #number of times this room has been visited.  key  num_visits
                     "func_valley",  #for use with autoFucn  key auto_func,  contents could be "none"
                     "not_set"  #to be filled in when func runs.    key = func_status
                     ]
    a_loc_dict = load_loc_data(loc_data_list)  # loads data from list into a_loc_dict for appropriate keys
    locs_dict[a_loc_dict["name"]] = a_loc_dict

    a_loc_dict["commands"] = {}

    list_of_cmd_lists = [
                ["go east","move","redRoom"],
                ["go west","move","exit"],
                                ["test me", "func","func_valley"]
                        ]
    loc_name = loc_data_list[0]
    a_loc_dict = load_cmd_dicts( loc_name,list_of_cmd_lists)
    # for each list in  list_of_cmd_lists it loads a_cmd_dict with data and then adds a_cmd_dict to a_loc_dict["commands"]

    locs_dict[a_loc_dict["name"]] = a_loc_dict   # put location dictionary into dictionary of of locations

    # the locs_dict dictionary should now contain four dictionary, one for each of the four locations
    # the names of the locations are the keys for the loc_dicts dictinary (homeRoom, blueRoom, redRoom and blackRoom
    ##show_gen_name("after valley_1",locs_dict)

    #return(locs_dict)  #now loaded with data for all locations and related commands
    # end of get_data()

############## end of locations  part of data #############################################################
###########################################################################################################

############## start of objects part of data (hammer,  gold_medal, key  etc.  #############################################################
###########################################################################################################

#add inventories to a_loc_rec   list of objects

#####################################   obj_exist  ###########################

def obj_exists( obj_name):
    #print("in obj_exists function for : ",obj_name)
    objs_list = list(objs_dict.keys())
    #print("in obj_exists function, all objects = ", objs_list)
    if (obj_name in objs_list):
            #print("in check_for_obj_cmd / obj_exists, object was found ")
            return("true")
           
    else:
        return("false")
        #print("in check_for_obj_cmd / obj_exists, object was NOT found ")
    #end of def obj_exists

    
#################################################    check_for_obj_cmd    ###################################
        
def check_for_obj_cmd( command):  #checks to see if second word is an object, if so tries to handle here
                                  # run after check comds for cur_loc and "gen" location
    #print("entered check_for_obj_cmd function, command is : ", command)
    global objs_dict
    global locs_dict
    
    if (command == "inventory"):
        do_func("inventory")
        return("cmd_done")
                
    #break into two words.
    #if first word is [get, drop, look, work ] handle
    #if fist word is something else... skip for now

    word_list = list(command.split())
    num_words = len(word_list)
    if (num_words < 2):
        return ("not_found")
    
    obj_name = word_list[1]  #second word in command.  If this is an object, then this is assumed to be an objec related command
    obj_found = obj_exists(obj_name)
    if (obj_found == "false"):
        #print(command," referred  to  non-existent object")
        temp = 0        
        return("not_found")
    else:
########            
        first_word = word_list[0]
        if (first_word in ["get","drop","look","where"]):
        #handle these
        #check that second word is an object
        #check that second word is in acceptable location
        #get, drop or look

            player_loc_dict = locs_dict["gen"]  #using location "gen" for player inventory
            player_objs_list = player_loc_dict["loc_inv"].copy()

            cur_loc_dict = locs_dict[cur_loc].copy()
            loc_objs_list = cur_loc_dict["loc_inv"]
############
            if (first_word == "get"):
                #check to see if already have object
                if (obj_name in player_objs_list):
                            print ("\nYou are already carrying ",obj_name)
                            return("failed") 
                elif(obj_name in loc_objs_list ):
                            found_obj = "true"
                else:
                        found_obj = "false"
                        print("\n",obj_name," is not available here!")
                        return("failed")
                                             
                player_objs_list.append(obj_name)
                player_loc_dict["loc_inv"] = player_objs_list
                #print ("\nin check_for_obj_cmd, player's inventory after get is ",player_objs_list)
                
                locs_dict["gen"] = player_loc_dict.copy()
                
                loc_objs_list.remove(obj_name)
                #print("in check_for_obj_cmd, loc inventory for ", cur_loc, " after get is = ",loc_objs_list)
                cur_loc_dict["loc_inv"] = loc_objs_list
                locs_dict[cur_loc] = cur_loc_dict.copy()

                an_obj_dict = objs_dict[obj_name].copy()
                an_obj_dict["obj_loc"] = "gen"
                objs_dict[obj_name] = an_obj_dict.copy()                                                                       
                
                print("\nyou are now carrying ", obj_name)
                return("success")
############
            elif (first_word == "drop"):
                 #check to see if have object
                            if (obj_name in player_objs_list):
                                 player_objs_list.remove(obj_name)
                                 #print ("in check_for_obj_cmd, player dropped ",
                                 #      obj_name,
                                 #"player's inventory after drop is ",player_objs_list)
                                 player_loc_dict["loc_inv"] = player_objs_list                                    
                                 locs_dict["gen"] = player_loc_dict.copy()
                                 
                                 #print ("after player_loc_dict put back in locs_dict")
                                 #show_inventory()
                     
                                 loc_objs_list.append(obj_name)
                               
                                 cur_loc_dict["loc_inv"] = loc_objs_list

                                 
                                 locs_dict[cur_loc] = cur_loc_dict.copy()

                                 

                                 an_obj_dict = objs_dict[obj_name]
                                 an_obj_dict["obj_loc"] = cur_loc
                                 objs_dict[obj_name] = an_obj_dict
                     
                                 print ("\nYou are no longer carrying ",obj_name)
                                 #print("\nin check_for_obj_cmd, end of drop section")
                                 #show_inventory()
                                 return("success")
                            else :
                                 print("You are not carrying",obj_name)
                                 return("failed")

            elif (first_word == "look"):
                #check to see if object is local or in inventory
                if (obj_name in player_objs_list) or (obj_name in loc_objs_list):
                    an_obj_dict = objs_dict[obj_name]
                    obj_desc = an_obj_dict["obj_desc"]
                    print("\n",obj_desc,"\n")
                    return("success")
                else:
                  print(obj_name,"is not available to view")
                  return("failed")
                # end of elif  look

            elif (first_word == "where"):
                 #already checked that object exists in the game       
                an_obj_dict = objs_dict[obj_name]
                object_loc = an_obj_dict["obj_loc"]
                all_locs = list(locs_dict.keys())
                if (object_loc in all_locs):
                  if (object_loc == "gen"):
                     print("You are carrying it!")
                     return("success")
                  else:
                      a_loc_dict = locs_dict[object_loc]
                      loc_desc = a_loc_dict["long_name"]
                      print(obj_name," is in : ",loc_desc)
                      return("success")
                 
                return("success")
                # end of elif  where      
########                                         
        else:  # if not get, drop, look, or where
            return("not_found") 

############################  end of check_for_obj_cmd ##########################################################
                                                        
objs_dict = {}

######################################  check_loc,  load_obj_dict   ###########################

def check_loc(loc_to_check):
    loc_to_check = str(loc_to_check)
    locs = list(locs_dict.keys())
    
    if (loc_to_check in locs):
        #print("check_loc found >"+loc_to_check+"<")
        temp = 0
        return("true")
    else:
         print("check_loc did not find >",+loc_to_check+"<")
         return("false")

def load_obj_dict_1(obj_data_list):
    global objs_dict
    
    an_obj_dict = {}
    obj_name = obj_data_list[0]
    #print("in load_obj_div for ", obj_name)
    an_obj_dict["name"] = obj_name
    obj_loc = obj_data_list[1]
    an_obj_dict["obj_loc"] = obj_loc
    #put in location inventory also  at this time
    if (check_loc(obj_loc) == "true"):  # returns True or False
        #print("check_loc for ",obj_loc, " returned true ")
        #location exists
        a_loc_dict = locs_dict[obj_loc]
        a_loc_dict["loc_inv"].append(obj_name)   #adds to inventory for that location
        #print ("in load_obj_dict_1, object = ",obj_name, "put in location = ",obj_loc)
        #print("object list in, obj_loc, is ",a_loc_dict["loc_inv"])
    else:
         print("check_loc for ",obj_loc, " returned false ")
         print ("object = ",obj_name, " target loc = ", obj_loc," does not exist")

    obj_status_list = obj_data_list[2]  # I think this should be a list, could contain
                                   # numerous statuses. 
    an_obj_dict["obj_status_list"] = obj_status_list
    obj_desc = obj_data_list[3]
    an_obj_dict["obj_desc"] = obj_desc
    objs_dict[obj_name] = an_obj_dict
    
    return(an_obj_dict)
    #end of load_obj_dict_1  function


##################start of def load_obj_cmds_dict()
##  list_of_cmd_lists = ["get", ["none"],["none"],"none","not_set"],
##                      ["drop", ["none"],["none"],"none","not_set"]
##                      ["look", ["none"],["none"],"none","not_set"]
##                      ["where", ["none"],["none"],"none","not_set"]
####                keys are "command, req_status_list, required_objects_list auto_func, func_return"


################################  load_obj_cmds_dict  ##############################
                  

def load_obj_cmds_dict(list_of_cmd_lists,an_obj_dict):  #obj_dicts has one dictionary for each object, key to object dictionary is name of object
#keys of commmand dictionary are "command, req_status_list, required_objs_list auto_func, func_return"
    
    cur_object = an_obj_dict["name"]
    obj_cmds_dict = {}  #will contain one dictionary for each commmand,  key for obj_cmds_dict is name of command
                  
    for an_obj_cmd_list in list_of_cmd_lists:
                  
            an_obj_cmd_dict = {}  #dictionary for a single command,  keys are "name", "req_status_list","required_objs_list" ,"auto_func","func_return" 
            cmd_name = an_obj_cmd_list[0]
            an_obj_cmd_dict["name"] = cmd_name
            an_obj_cmd_dict["req_status_list" ] = an_obj_cmd_list[1]
            an_obj_cmd_dict["required_objs_list" ] = an_obj_cmd_list[2]
            an_obj_cmd_dict["auto_func" ] =  an_obj_cmd_list[3]
            an_obj_cmd_dict["func_return" ] =  an_obj_cmd_list[4]
            obj_cmds_dict[cmd_name] = an_obj_cmd_dict
            

    an_obj_dict = objs_dict[cur_object]
    an_obj_dict["commands"] = obj_cmds_dict
    return (an_obj_dict)
           
     
################## end  of def load_obj_cmds_dict() #####################################


##########################  start of load_objs_dict  ############################################

def load_objs_dict():
        global cur_object
        global objs_dict
                  
####################   start  hammer object      ######################################################
#######       
        obj_data_list = ["hammer","homeRoom",["not_set"],
"""This is a hammer.  It can be used to  hammer things"""
                         ]
        obj_name = obj_data_list[0]

        #######       obj_name = obj_data_list[0]
        cur_object = obj_name
                 
        # related keys are name, obj_loc, obj_status_list, obj_desc
        an_obj_dict = load_obj_dict_1(obj_data_list)
##################### end hammer ####################


###################   start redKey ######################
        obj_data_list = ["redKey","blackRoom",["not_set"],
"""This is a redMedal.  It may be useful later"""
                         ]
        obj_name = obj_data_list[0]

        #######       obj_name = obj_data_list[0]
        cur_object = obj_name
                 
        # related keys are name, obj_loc, obj_status_list, obj_desc
        an_obj_dict = load_obj_dict_1(obj_data_list)
    
##########################  end redKey ##################    

#note: intial thought is that most related commands must  be two words
# and second word must be name of object.  Question:  To what extent can
# this be generalized for "get"  vs "get hammer".   User would type "get hammer"
# but command processing would use a generalize get (or drop) command.

#use of the object, eg. "hammer nail" "hit nail"  would check  numerous things:
# do either words refer to an object or are associated with a particular object
# if so, which is the one word command and which is the object named
#what object does the one_word command imply :
#  does one_word command require associated object (a)in loc, (b.in player inventory
#It would then need to check
#  if the named object was required (a) loc or (b) player inventory
#  e.g. light lamp,  hammer[bang,hit... ] nail, open door,  etc.   
########
        list_of_cmd_lists =  [
                      ["get", ["none"],["none"],"none","not_set"],
                      ["drop", ["none"],["none"],"none","not_set"],
                      ["look", ["none"],["none"],"none","not_set"],
                      ["where", ["none"],["none"],"none","not_set"]
                             ]
####                keys are "command, req_status_list, required_objects_list auto_func, func_return"
####                       if command is get new_loc is player if succeeds
####                       if commmand is put or drop or whatever. new loc_is cur_loc
####                               if succesful
####  question is to what extent doe requirements for a command en1101ed with data and to what extent
###    are they coded into the program for tha paricular command and object....
                      
##              ["go homeRoom","move","homeRoom"],
##                          ["help","ask",
##"""Well done.  There is not much help available so far..
##but you can use 'go homeRoom' to go to that room
##from anywhere. """,
##                           ],
##                                ["look","ask","LOOK"]
##               ]
########
        an_obj_dict = load_obj_cmds_dict(list_of_cmd_lists, an_obj_dict)
                 
    
        objs_dict[cur_object] = an_obj_dict
        #return(objs_dict)

####################   end  hammer object      ######################################################
    
##########################  end of load_objs_dict  ############################################

###############################   SHOW ALL OBJECTS  ##############

def show_all_objects():
         global objs_dict
         print ("show all objects gives ")
         obj_list = list(objs_dict.keys())
         for obj in obj_list:
                 an_obj_dict = objs_dict[obj]
                 loc = an_obj_dict["obj_loc"]
                 print (obj, " is in ", loc)
         #end show_all_objects




    
############## start of objects part of data (hammer,  gold_medal, key  etc.  #############################################################
###########################################################################################################

def show_all_locs():
    
    #key_list = locs_dict.keys()
    #key_list = list(locs_dict)
    
    for dicts_key in locs_dict :
        print("\nin show_all_locs  key is ",dicts_key)
        a_loc_dict = locs_dict[dicts_key]
        name_in_dict = a_loc_dict["name"]
        print("\nlocation key is ",dicts_key, " and name in dictionary is ", name_in_dict)
    #end of show_all_locs
    

    
def show_all_loc_data():
    global locs_dict
    for dict_key in locs_dict:
        print("\nlocation is ",dict_key)
        dict2 = locs_dict[dict_key]
    
        for dict2_key in dict2:
            print("  dict_2_key :    ",dict2_key,  end="")
            if (dict2_key == "commands"):
                print("\n")
                cmds_dict = dict2[dict2_key]
                
                for cmds_dict_key in cmds_dict :
                        cmd_dict = cmds_dict[cmds_dict_key]
                        print("  Command is ", cmds_dict_key)
                        
                        for cmd_dict_key in cmd_dict:
                                if (cmd_dict_key == "ans"):
                                        print ("           :",cmd_dict_key, " = ","\n",cmd_dict[cmd_dict_key])
                                else : print("           :",cmd_dict_key, " = ",cmd_dict[cmd_dict_key])
                                
            elif (dict2_key == "loc_msg"): print("\n", dict2[dict2_key])
                
            else: print(" = ",dict2[dict2_key])
               
       

###########################################################  replace_command  #############

def replace_command( in_cmd):
    #print("in replace_command, in_cmd = >"+in_cmd+"< ",end="")
    out_cmd = in_cmd
    if (in_cmd == "south"): out_cmd = "go south"
    elif (in_cmd == "north"): out_cmd = "go north"
    elif (in_cmd == "west"): out_cmd = "go west"
    elif (in_cmd == "east"): out_cmd = "go east"
    elif (in_cmd == "up"): out_cmd = "go up"
    elif (in_cmd == "down"): out_cmd = "go down"
    elif (in_cmd == "quit"): out_cmd = "exit"
    
    #print(" out_cmd = >"+out_cmd+"<")
    return(out_cmd)


##############################################    get_command ########################################
def get_command():
      
    good_command = "false"
    
    while(good_command == "false"):
        #  prompt the user to enter something:
        print("\nEnter one or two words : ", end="")

        #  get value from user
        words = sys.stdin.readline()
        words = words.strip()

        #print("You entered : >",words,"<\n")
        word_list = list(words.split())

        num_words = len(word_list)

        #print("word_list = ",word_list," and this is ",num_words,"words")
        

        num_words = len(word_list)
     
        if ((num_words > 0) and (num_words < 3)):
           good_command = "true"

        #print("good_command is now ",good_command)
        
        if (good_command == "true"):
            if (num_words == 1):
                command = word_list[0]
                #print("one word command is ",command)
                break
            else:
                command = word_list[0]+" "+word_list[1]
                #print("two word command is ", command)
                break
        else :
            good_command = "false"
            command = "not valid"
            print ("\nNot a valid command, must be one or two words\n")
            
    #print("before replace command is >"+command+"<")
    command = replace_command(command)
    #print("before replace command is >"+command+"<")
    return(command)
    # end of get_command function

################################################# auto functions ###########################

def show_inventory():
        
        print("\nshow_inventory functions started")
        loc = "gen"
        a_loc_dict_si = locs_dict[loc].copy()
        player_inv_si_list = a_loc_dict_si["loc_inv"]   #list of items in inventory
        num_items = len(player_inv_si_list)
        if (num_items) > 0 :
                print ("\nYou are carring the following", num_items," items : ",end = "")
                for obj in player_inv_si_list:
                        print(obj+", ",end="")
                print("\n\n")
        else:
                print("\nYou are not carrying anything\n")
        return("done")
        #end show_inventory
		
###############################################   func_valley *******************		

def func_valley():

	def user_entered(prompt_str):
		#prompt the user to enter something:
		print(prompt_str+" : ", end="")
		#get value from user
		in_str = sys.stdin.readline()
		#to remove the trailing "\n",  use rstrip()
		in_str = in_str.rstrip()
		#the trailing "\n" is now gone
	   
		return(in_str)
		# end of user_entered function

	def get_yes_no():
		ans_good = "bad"
		
		while (ans_good == "bad"):
			user_ans  = user_entered(" : yes or no")
			if ( (user_ans == "yes") or (user_ans == "no") ):
				ans_good = "good"
				return(user_ans)
			else:
				print("\nYou entered >"+user_ans+"<")
				print( "\nPlease enter yes or no, all lower case \n")
		# end of while loop
		#end of get_yes_no function
		
	print ("\n\n      Welcome!   You are under the control of a wizard.   ")
	print ("\n        If you can answer his questions... you can go on to a beautiful valley")
	print ("\n        Otherwise, you are stuck here forever !\n\n")

	print ("Would you like to play a game? ",end = "")

	yes_no_str = get_yes_no()  #ask user to enter yes or no
							   # get_yes_no function returns  yes or no in a tring
							   # This statement sets the variable yes_no_str
							   # equal to whatever is returned (i.e yea or no)

	if (yes_no_str == "yes"):
		print("\n    Good!   Here we go ! \n")
	else:
		print("\n    Too bad,    You have to play anyway.\n")

	print("""\nTo win this game  you must answer
	the question correctly.""")

	# NOTE:  using tripple quotes, i.e """, permits
	#        entering text to be printed that
	#        is entered on more than one line
	#
	#        To include a " inside a quoted line, use \"
	#        example:  print ("This is a quote  \"  inside a quoted line")

	winner = "no"

	while (winner == "no"):
		  print(
	"""\nWhat are the two kinds of loops we
	have learned in Python.  Enter two words, no commas.""")
		  
		  user_ans = user_entered("\nEnter two words")
		  
		  if ((user_ans == "while for") or (user_ans == "for while")):
			   print("\n     Yae!  You win!  That is correct!")
			   winner = "yes"
		  else:
			  print("\n    You entered : >"+user_ans+"<")
			  print("\n    That is incorrect.   Try again ! ")
		  #end of while loop

	print("\nCongratulations!  You can now enter the valley !\n\n")
	
	return ("completed")                       
    #end of func_valley
        
#########################################################################################

# def func_valley():
        # print ("\nWelcome to a test function")
        # print (
# """This function does nothing right now
# but it could be a test that you would have to past to location.

              # stay tuned for future developments!
# """
# )
        # result = "completed"
        # return(result)



######################################################## do func ######################

def do_func(func_to_run):
        #print("\ndo_func called- mot programmed yet.. you are can't go this way ")
        #print("in do_func, func_to_run = :",func_to_run)
       
        if (func_to_run == "inventory"): result =   show_inventory()
        elif (func_to_run == "func_valley"): result = func_valley()
        elif (func_to_run == "heather_func"): result = heather_func()
        elif (func_to_run == "adam_func"): result = adam_func()
        elif (func_to_run == "evan_func"): result = evan_func()
        elif (func_to_run == "dylan_func"): result = dylan_func()
        else:  return("func_failed")

#def do_func_direct(func_to_run):
########################################################## print_loc_msg ########################

def print_loc_msg(loc_for_msg):
                my_loc_dict_i = locs_dict[loc_for_msg].copy()
                
                loc_message = my_loc_dict_i["loc_msg"]
                print("\n",loc_message,"\n")
                # end of print_loc_msg

def print_loc_inv(loc_for_inv):
        my_loc_dict_p = locs_dict[loc_for_inv].copy()
        #a_loc_dict["loc_inv"]
        loc = my_loc_dict_p["name"]
        #print("in print_loc_inv, loc = ",loc, end="")
        loc_obj_list = my_loc_dict_p["loc_inv"]
        num_objs = len(loc_obj_list)
        #print(" and num of objs is ",num_objs)
        if (num_objs > 0):
                print("\nThings in this location are : ",end= "")
                for loc_obj in loc_obj_list:
                        print (loc_obj," ",end="")
                print("\n")



############################################    enter_loc ############################################
                
def enter_loc( target_loc):  #enter into location,   calling function,
        # do_move, aready verified that the target_loc exists
        # already checked that target_loc is not "exit"
        global locs_dict

        global cur_loc
        
        new_loc_dict = locs_dict[target_loc]   #note locs_dict should be accessible as long as it is not changed
                
        auto_func = new_loc_dict["auto_func"]  #name of function to be run

        #print("in enter_loc,  target is ", target_loc, " and auto_func is ",auto_func)
        cur_loc_dict =  locs_dict[cur_loc]
         
        if (auto_func=="none"):
                #print("auto_func = \"none\",", "should print loc_msg ")
                print_loc_msg(target_loc)
                print_loc_inv(target_loc )
        else :
                #print("do_func called from enter_loc for ", auto_func)
                
                func_return = do_func(auto_func)
                #print("do_func returned ", func_return)
                if (func_return == "func_failed"):    # do not permit entry, stay in the old room 
                       
                        print_loc_msg(cur_loc)
                        print_loc_inv(cur_loc)
                        return(func_return)
                else:
                       print_loc_msg(target_loc)
                       print_loc_inv(target_loc )  
        
        
        old_loc = cur_loc
        cur_loc = target_loc
    
        #print("\n",old_loc, " changed to ",cur_loc," in do_move/enter_loc")
          
        result = "cmd done"
        return(result)

    
def do_look():  #looks in current locations
            a_loc_dict_l = locs_dict[cur_loc].copy()
            a_loc_msg = a_loc_dict_l["loc_msg"]
            print("\n",a_loc_msg)
            print_loc_inv(cur_loc )
            ans_msg = a_loc_msg
  
#################################################  do_move,  give_ans,   ############################

def do_move(to_loc):
    global locs_dict
    #print("in do_move, to_loc is ",to_loc)
    if (to_loc == "exit"): return("exit")
          
    all_locs = list (locs_dict.keys())
          
    if (to_loc in all_locs):
            #print("\nin do_move, target_loc is ", target_loc,"\n")
            result = enter_loc( to_loc)  #returns "cmd done"  is move is successful 
    else :
        #print("\n Could not move to ", to_loc,", location does not exist!")
        result = "to_loc not found"
    return(result)
    #end of do_move function

def give_ans(ans_msg):
    #print("\nin give_ans\n")
     
    if (ans_msg == "LOOK"):
            a_loc_dict = locs_dict[cur_loc]
            a_loc_msg = a_loc_dict["loc_msg"]
            print_loc_inv(a_loc_dict )
            ans_msg = a_loc_msg
            #end of if block
    print("\n",ans_msg,"\n")
    result = "cmd done"
    return (result)
    #end of give_ans function

########################################################  do_command  #####################################
def do_command ( a_cmd_dict ):
    #def do_command ( cmd_rec_in ):
    #a_loc_dict = locs_dict[cur_loc]  #not used here so far, but good to have availalble
        
    #print("\nin do_command, cur_loc pre command is ",cur_loc)
    cmd_type = a_cmd_dict["type"]
    #print(", cmd_type is ",cmd_type," from ",cur_loc, "\n")
    result= "cmd failed"  #just in case funciton exist without resetting this
    
    if (cmd_type == "move"):
        to_loc = a_cmd_dict["to_loc"]
        #print("in do_command/move to_loc = ",to_loc, " and cur_loc is ",cur_loc)
        #print("move to", cmd_rec_in[2],"from ",cur_loc,"\n")              
        result = do_move(to_loc)         
        
    elif (cmd_type == "ask"):
        
        answer = a_cmd_dict["ans"]
        print("give answer : ",answer,"\n")
        result = give_ans(answer)

    elif (cmd_type == "func"):
          #print("in do_command, type = func, command = ",a_cmd_dict["command"])
          func_to_run = a_cmd_dict["func"]
          do_func(func_to_run)
        
    else: result = "no command"

    return(result)
    # end of do_command function

######################################  get_locs_dict ##################
##
##def show_all_locs():
##    
##    #key_list = locs_dict.keys()
##    #key_list = list(locs_dict)
##    
##    for dicts_key in locs_dict :
##        print("\nin show_all_locs  key is ",dicts_key)
##        a_loc_dict = locs_dict[dicts_key]
##        name_in_dict = a_loc_dict["name"]
##        print("\nlocation key is ",dicts_key, " and name in dictionary is ", name_in_dict)
##    #end of show_all_locs
    

    
def get_locs_dict(get_loc):
    global locs_dict
    key_list = list (locs_dict.keys() )
    #print("in get_locs_dict, get_loc is >"+get_loc+"< and keys are : ", key_list)
    my_loc_dict = locs_dict[get_loc]
    loc_name = my_loc_dict["name"]
    #print("in get_locs_dict, get_loc is ",get_loc, "name in dict is ", loc_name)
    return(my_loc_dict)

##############################################################   check commmand ######################
    
def check_command(loc_to_check,command):
    global locs_dict
    #print ("started check_command")
    result = "cmd_done"
    # checks to see if command is in either in commands for  loc_to_check  send to do_command
    #print("\nIn check_command, loc_to_check = ",loc_to_check," and check_command is ",command)
    loc_to_check = str(loc_to_check)
                
    #a_loc_dict = locs_dict[loc_to_check]   #locs_dict  should be globaaly available if not changed
                                          # inside function
    a_loc_dict = get_locs_dict(loc_to_check)
    #print("in check_command checking for", loc_to_check," new a_loc_dict  has location name = ",a_loc_dict["name"])                                          
    
    cmds_dict = a_loc_dict["commands"]
    cmd_list = list(cmds_dict.keys())
    #print("\nin check commands for location = ",loc_to_check,",  command is ", command)
    #print("    commands are :",cmd_list,"\n")
    
    if (command in cmd_list):
            a_cmd_dict = cmds_dict[command]
            result = do_command(a_cmd_dict)
            #print("command was found in cmmds for current loc")
    else : result =  result = "not_found"
                                        
    return(result)
    # end of check_command function

def show_all_commands(loc_to_check):
    #print("\nIn Show all commands")
    print("\nGlobal commands are :   locations, objects, commmands, locfull")
    print("\nCommands in ",loc_to_check," are :")
    a_loc_dict_4cmd =  locs_dict[loc_to_check]
    cmds_dict = a_loc_dict_4cmd["commands"]
    for cmds_dict_key in cmds_dict :
                        cmd_dict = cmds_dict[cmds_dict_key]
                        print("  Command is ", cmds_dict_key)
                        
                        for cmd_dict_key in cmd_dict:
                                if (cmd_dict_key == "ans"):
                                        print ("           :",cmd_dict_key, " = ","\n",cmd_dict[cmd_dict_key])
                                else : print("           :",cmd_dict_key, " = ",cmd_dict[cmd_dict_key])
    print("\n")
        

def check_global_commands( command ):
    msg = "\nIn check_global_commands"
    result = "done"
    if (command == "locations"):
        print(msg)
        show_all_locs()
    elif (command == "objects"):
         print(msg)
         how_all_objects()
    elif(command == "commands"):
        print(msg)
        print("calls to show_all_commands for ", cur_loc, " and    gen ")
        show_all_commands(cur_loc)  # from cur_loc, gen, and global
        show_all_commands("gen")
    elif (command == "locfull" ) :
         print(msg)
         show_all_loc_data()
    elif (command == "look"):
        do_look()
    elif (command == "inventory"):
        print("\nin check_global_commands, ccommand is ",command)
        show_inventory()
    else :
        result = "none"

    return(result)
          
    
    ###########################  possible results of checkd_command are :
##            "not found"
##            if move :   "to_loc not found")
##                and a printed message that target location
##                for move does not exist
##            if move to_loc -- "exit" then result =  "exit"
##            if move is successful : result = "move done"

def make_global():
    global cur_loc
    temp = 0
          
#######################################################################################################################
###################################################################################################################
############################### start statements in main program  ###############
make_global()

print("program started \n")

#variables used, and sometimes changed, globally`` 
cur_loc = "homeRoom"
locs_dict = {}
objs_dict = {}



cur_loc = "homeRoom"
cur_obj = ""



get_data()  # loads a_loc_rec for each location.
#print("get_data() completed")


#print("before call to get_locs_dict")
my_loc_dict = get_locs_dict("homeRoom")

        
#show_all_locs()



load_objs_dict()
#print("load_objs_dict  ran")
#show_all_objects()
                   
enter_loc(cur_loc)   #function enter a location,  start of game...start in this location, with message

#print("initial entry to homeRoom completed")

game_on = True

my_loc_dict = locs_dict["gen"]
loc_name = my_loc_dict["name"]

#show_all_locs()

#print("\n name in my_loc_dict for gen is ",loc_name,"\n")
#show_all_loc_data()

while(game_on) :
    #print ("your location name is ",cur_loc)
    command = get_command()  #runs replace_command
    command = str(command)

    
    #print("after get_command, command is ", command)
            
    if (command == "exit"):
        print("\nUser has exited the game!\n")
        break
    
    result = check_global_commands ( command)
    if (result == "done"):
        continue   # goes to end of this loop.

    result  =  check_command(cur_loc,command)  # check commands in current location first
    #print("after check_command, command is ",command)
    #result = str(result)
    
    #print("after check_commands for ", cur_loc," result is >"+result+"<")
    ##print("after call to check_command")

    if (result == "not_found"):
            #print("command not in ",cur_loc," commands")
            #print("\nnow ckecking  commands for gen")
            result = check_command("gen",command)
    
    if (result == "exit"):
            print("\nUser has exited the game!\n")
            break
        
    elif (result == "not_found"):
        #print("command not found in gen set ")
        #print("before check for obj w/command = ",command)
        result = check_for_obj_cmd( command)
        if (result == "not_found"):
            #print ("command not found by check_for_obj_cmd")
            temp = 0


    #end of loop, may be in a new location, (cur_loc may have changed
    # get new command
    
