Friday, June 28, 2024

Here is a one day practice Clue game. It's not multiplayer yet, and I may never add that. Just for practice. Can be tested at https://www.programiz.com/python-programming/online-compiler/ (Remove the 3 lines of "stuff" on the left on their site, or it might not run properly. Also, the site seems to time out, but it's the only one I see that can run this one.)


import random

guess = "wrong"
progress_array = ["person", "place", "weapon"]
progress_counter = 2
progress_person = "no"
progress_place = "no"
progress_weapon = "no"
firstguess = 2
people = ("Colonel Mustard", "Miss Scarlet", "Mr. Green", "Mrs. Peacock", "Mrs. White", "Professor Plum")
places = ("hall", "lounge", "dining room", "kitchen", "ballroom", "conservatory", "billiard room", "library", "study")
weapons = ("candlestick", "dagger", "revolver", "lead pipe", "wrench", "rope")

people_random = (random.randint(0,5))
places_random = (random.randint(0,8))
weapons_random = (random.randint(0,5))
shuffle = (people [people_random], places [places_random], weapons [weapons_random])

#print (shuffle)

print ("List of people: Colonel Mustard, Miss Scarlet, Mr. Green, Mrs. Peacock, Mrs. White, Professor Plum\n")
print ("List of places: hall, lounge, dining room, kitchen, ballroom, conservatory, billiard room, library, study\n")
print ("List of weapons: candlestick, dagger, revolver, lead pipe, wrench, rope")
print ("---------------------------------------\n")


while guess == ("wrong"):
    
    if progress_person != "yes":
        person_guess = input ("Make your guess of the person: ")
    if progress_place != "yes":
        place_guess = input ("Make your guess of the place: ")
    if progress_weapon != "yes":
        weapon_guess = input ("Make your guess of the weapon: ")

    if progress_counter == 3:    

        if person_guess == (people [people_random]) and progress_person != "yes":
            print ("\nYou got the person right.\n")
            progress_person = "yes"
            progress_array.pop(progress_counter - 1)
            progress_counter = progress_counter - 1
            progress_array.pop(firstguess-2)
        if progress_person == "yes":
            firstguess = firstguess - 1
        if place_guess == (places [places_random]) and progress_place != "yes":
            print ("\nYou got the place right.\n")
            progress_place = "yes"
            progress_counter = progress_counter - 1
            progress_array.pop(firstguess-1)
        if progress_place == "yes" and progress_person != "yes":
            firstguess = firstguess - 1
        if weapon_guess == (weapons [weapons_random]) and progress_weapon != "yes":
            print ("\nYou got the weapon right.\n")
            progress_weapon = "yes"
            progress_counter = progress_counter - 1
            progress_array.pop(firstguess)
        if progress_weapon == "yes":
            firstguess = firstguess - 1
    else:

        if person_guess == (people [people_random]) and progress_person != "yes":
            print ("\nYou got the person right.\n")
            progress_person = "yes"
            progress_array.pop(progress_counter - 1)
            progress_counter = progress_counter - 1
        if place_guess == (places [places_random]) and progress_place != "yes":
            print ("\nYou got the place right.\n")
            progress_place = "yes"
            progress_array.pop(progress_counter - 1)
            progress_counter = progress_counter - 1
        if weapon_guess == (weapons [weapons_random]) and progress_weapon != "yes":
            print ("\nYou got the weapon right.\n")
            progress_weapon = "yes"
            progress_array.pop(progress_counter - 1)
            progress_counter = progress_counter - 1   
        
    if (progress_person == "yes" and progress_place == "yes" and progress_weapon == "yes"):
        print ("\n****YOU SOLVED IT!!!****")
        print (people [people_random], "did it in the", places [places_random], "with a", weapons [weapons_random])
        guess = "solved"
    else:
        tryagain = 2
        print ("Try Again\n")

No comments:

Post a Comment