Hi, I’m currently creating a GUI game using Tkinter, however I want each command to only be able to be used every 10 seconds, I have done this in the beg() command however during this 10 second timer I cannot interact with any other buttons, is there any way to counter this?
Here is the section of code:
def Beg():
End_game()
global Beg_timer
if Beg_timer == False:
print(“Nu!! You cant use this again for a specific time period”)
elif Beg_timer == True:
global beg_amount
global begging_level
beg_amount += 1
if beg_amount == 5:
beg_amount = 0
begging_level += 1
print(“Level Up!”)
# what could be said
for i in range(begging_level):
if begging_level >= 25:
beg_sentences = ["Sure...", "umm you never even saw me and therefore I never said no...",
"Of course.... theres £0.1", "Sure...",
"umm you never even saw me and therefore I never said no...", "Of course.... theres £0.1",
"Sure...", "umm you never even saw me and therefore I never said no...",
"Of course.... theres £0.1", "Sure...",
"umm you never even saw me and therefore I never said no...", "Of course.... theres £0.1",
"LUCKY! Sure here is £10"]
beg = random.choice(beg_sentences)
global money
if beg == "Sure...":
print("Sure...")
print("+£1")
money += 1
elif beg == "umm you never even saw me and therefore I never said no...":
print("umm you never even saw me and therefore I never said no...")
elif beg == "Of course.... theres £0.1":
print("Of course.... theres £0.1")
print("+£0.10")
money += 0.10
elif beg == "LUCKY! Sure here is £10":
print("LUCKY!")
print("Sure here is £10")
print("+£10")
money += 10
else:
print("error")
else:
beg_sentences = ["Not a chance!", "Sure...", "umm you never even saw me and therefore I never said no...",
"Of course.... theres £0.1", "Im not here to give you money im here to take it from you",
"Not a chance!", "Sure...", "umm you never even saw me and therefore I never said no...",
"Of course.... theres £0.1", "Not a chance!", "Sure...",
"umm you never even saw me and therefore I never said no...", "Of course.... theres £0.1",
"Not a chance!", "Sure...", "umm you never even saw me and therefore I never said no...",
"Of course.... theres £0.1", "LUCKY! Sure here is £10"]
beg = random.choice(beg_sentences)
if beg == "Not a chance!":
print("Not a chance!")
elif beg == "Sure...":
print("Sure...")
print("+£1")
money += 1
elif beg == "umm you never even saw me and therefore I never said no...":
print("umm you never even saw me and therefore I never said no...")
elif beg == "Of course.... theres £0.1":
print("Of course.... theres £0.1")
print("+£0.10")
money += 0.10
elif beg == "Im not here to give you money im here to take it from you":
print("Im not here to give you money im here to take it from you")
amount_stolen_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
amount_stolen = random.choice(amount_stolen_list)
print("-£{0}".format(amount_stolen))
money -= amount_stolen
elif beg == "LUCKY! Sure here is £10":
print("LUCKY!")
print("Sure here is £10")
print("+£10")
money += 10
else:
print("error")
Beg_timer = False
def reset_beg_timer():
global Beg_timer
Beg_timer = True
game_GUI.after(10000, reset_beg_timer())
This is the full code:
modules
import random
import time
import tkinter
create currency
global money
money = 0
create items
global Fishing_rod
global Sharp_stick
global Fizzy_drink
global Ice_cream
global Beer
global Scratch_card
global lives
global drunk
global Apartment_letter
global Swamp_house
global Village_round_house
global Small_house
global Medium_house
global City_apartment
global Large_house
global Flat_building
global Mansion
global beg_amount
global fish_amount
global hunt_amount
global begging_level
global fishing_level
global hunting_level
global skills
global properties
global result_list
global game_2
global Beg_timer
beg_amount = 0
fish_amount = 0
hunt_amount = 0
Fishing_rod = 0
Sharp_stick = 0
Fizzy_drink = 0
Ice_cream = 0
Beer = 0
Scratch_card = 0
lives = 2
drunk = 0
Apartment_letter = 0
Swamp_house = 0
Village_round_house = 0
Small_house = 0
Medium_house = 0
City_apartment = 0
Large_house = 0
Flat_building = 0
Mansion = 0
begging_level = 1
fishing_level = 1
hunting_level = 1
skills = 0
properties = 0
new_world = False
game_2 = False
Beg_timer = True
create GUI
game_GUI = tkinter.Tk()
game_GUI.title(“Game”)
def End_game():
global Apartment_letter
global Swamp_house
global Village_round_house
global Small_house
global Medium_house
global City_apartment
global Large_house
global Flat_building
global Mansion
global beg_amount
global fish_amount
global hunt_amount
global begging_level
global fishing_level
global hunting_level
global skills
global properties
global game_2
global new_world
if fishing_level >= 25 and begging_level >= 25 and hunting_level >= 25 and skills == 0:
skills = 1
print("You have unlocked level 25 in all skills available to you so far!")
print("Maybe you should try and buy the properties. Hint: Buy the apartment letter")
input("Press enter to continue")
elif Swamp_house == 1 and Village_round_house == 1 and Small_house == 1 and Medium_house == 1 and City_apartment == 1 and Large_house == 1 and Flat_building == 1 and Mansion == 1 and properties == 0:
properties = 1
print("You have bought all properties! You must be rich")
print("Maybe you should try and get all skills to level 25. Hint: !beg, !hunt and !fish are the only commands"
" with levels")
input("Press enter to continue")
elif skills == 1 and properties == 1:
print("....")
print("You walk into your mansion and here something calling you from upstairs...")
print("As you walk into the room a portal slowly emerges in front of the wardrobe, calling you inside")
print("Do you enter? (yes or no)")
choice = input("")
if choice == "yes":
print("You walk into the portal and everything goes white...")
elif choice == "no":
print("Too bad it pulls you in anyway and everything goes white...")
else:
print("the portal drags you in and everything goes white....")
new_world = True
game_GUI.destroy()
if new_world == True:
print("ITS A WHOLE NEW WORLD!!!!!!!")
print("The currency is different here, therefore what you own is completely worthless... Poor again, feels bad")
print("There are brand new activities here such as: mining, farming and driving!")
print("Good luck in your new world, everything you once knew is no longer true....")
game_2 = True
new_world = False
while game_2 == True:
input("Work in progress")
def Beg():
End_game()
global Beg_timer
if Beg_timer == False:
print(“Nu!! You cant use this again for a specific time period”)
elif Beg_timer == True:
global beg_amount
global begging_level
beg_amount += 1
if beg_amount == 5:
beg_amount = 0
begging_level += 1
print(“Level Up!”)
# what could be said
for i in range(begging_level):
if begging_level >= 25:
beg_sentences = ["Sure...", "umm you never even saw me and therefore I never said no...",
"Of course.... theres £0.1", "Sure...",
"umm you never even saw me and therefore I never said no...", "Of course.... theres £0.1",
"Sure...", "umm you never even saw me and therefore I never said no...",
"Of course.... theres £0.1", "Sure...",
"umm you never even saw me and therefore I never said no...", "Of course.... theres £0.1",
"LUCKY! Sure here is £10"]
beg = random.choice(beg_sentences)
global money
if beg == "Sure...":
print("Sure...")
print("+£1")
money += 1
elif beg == "umm you never even saw me and therefore I never said no...":
print("umm you never even saw me and therefore I never said no...")
elif beg == "Of course.... theres £0.1":
print("Of course.... theres £0.1")
print("+£0.10")
money += 0.10
elif beg == "LUCKY! Sure here is £10":
print("LUCKY!")
print("Sure here is £10")
print("+£10")
money += 10
else:
print("error")
else:
beg_sentences = ["Not a chance!", "Sure...", "umm you never even saw me and therefore I never said no...",
"Of course.... theres £0.1", "Im not here to give you money im here to take it from you",
"Not a chance!", "Sure...", "umm you never even saw me and therefore I never said no...",
"Of course.... theres £0.1", "Not a chance!", "Sure...",
"umm you never even saw me and therefore I never said no...", "Of course.... theres £0.1",
"Not a chance!", "Sure...", "umm you never even saw me and therefore I never said no...",
"Of course.... theres £0.1", "LUCKY! Sure here is £10"]
beg = random.choice(beg_sentences)
if beg == "Not a chance!":
print("Not a chance!")
elif beg == "Sure...":
print("Sure...")
print("+£1")
money += 1
elif beg == "umm you never even saw me and therefore I never said no...":
print("umm you never even saw me and therefore I never said no...")
elif beg == "Of course.... theres £0.1":
print("Of course.... theres £0.1")
print("+£0.10")
money += 0.10
elif beg == "Im not here to give you money im here to take it from you":
print("Im not here to give you money im here to take it from you")
amount_stolen_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
amount_stolen = random.choice(amount_stolen_list)
print("-£{0}".format(amount_stolen))
money -= amount_stolen
elif beg == "LUCKY! Sure here is £10":
print("LUCKY!")
print("Sure here is £10")
print("+£10")
money += 10
else:
print("error")
Beg_timer = False
def reset_beg_timer():
global Beg_timer
Beg_timer = True
game_GUI.after(10000, reset_beg_timer())
def Bank():
End_game()
cash = float("{0:.2f}".format(money))
print(“you have £{0}0… bye bye!”.format(cash))
def Shop():
End_game()
shop = True
global money
global Fishing_rod
global Sharp_stick
global Fizzy_drink
global Ice_cream
global Scratch_card
global Beer
global Apartment_letter
def not_enough_money():
print("you know how money works right.. YOU DON'T HAVE ENOUGH")
while shop == True:
Shop_GUI = tkinter.Tk()
Shop_GUI.title("Shop!")
global money, Fishing_rod, Sharp_stick, Fizzy_drink, Ice_cream, Beer, Scratch_card, Apartment_letter
cash = float("{0:.2f}".format(money))
print("You have £{0}0".format(cash))
def Fishing_Rod():
global money, Fishing_rod
if money >= 50:
if Fishing_rod >= 1:
print("You cant buy another one its one per person so scram")
print()
else:
print("here take the rod")
print("Fishing has been unlocked! type !fish to catch a fish and sell it for money!")
print()
Fishing_rod += 1
money -= 50
else:
not_enough_money()
def Sharp_Stick():
global money, Sharp_stick
if money >= 25:
if Sharp_stick >= 1:
print("You cant buy another one its one per person so scram")
print()
else:
print("Im surprised You would even buy a stick for that much")
print("Hunting has been unlocked! type !hunt to catch an animal and sell it for money!")
print()
Sharp_stick += 1
money -= 25
else:
not_enough_money()
def Fizzy_Drink():
global money, Fizzy_drink
if money >= 4.1:
print("If you don't feel to good after drinking that it has nothing to do with me...")
print()
Fizzy_drink += 1
money -= 4.1
else:
not_enough_money()
def Ice_Cream():
global money, Ice_cream
if money >= 4.5:
print("Its gonna melt so eat it fast boi")
print()
Ice_cream += 1
money -= 4.5
else:
not_enough_money()
def beer():
global money, Beer
if money >= 6:
print("don't drink too much...")
print()
Beer += 1
money -= 6
else:
not_enough_money()
def Scratch_Card():
global money, Scratch_card
if money >= 6.50:
print("Good luck!")
print()
Scratch_card += 1
money -= 6.5
else:
not_enough_money()
def Apartment_Letter():
global money, Apartment_letter
if money >= 500:
if Apartment_letter < 1:
print("You just spent £500 for a letter.. LOL")
print()
print("Apartment list unlocked! type !apartment to access this")
Apartment_letter += 1
money -= 500
elif Apartment_letter >= 1:
print("That would be a waste buying a second one")
else:
not_enough_money()
def exit_shop():
global shop
shop = False
Shop_GUI.destroy()
label_Fishing = tkinter.Label(Shop_GUI, text="£50 | Use to fish")
label_Fishing.grid(row=0, column=4, columnspan=4, rowspan=4)
button_Fishing_rod = tkinter.Button(Shop_GUI, text="Fishing rod", width=15, command=lambda: Fishing_Rod())
button_Fishing_rod.grid(row=0, column=0, rowspan=4, columnspan=3)
label_hunting = tkinter.Label(Shop_GUI, text="£25 | Use to hunt")
label_hunting.grid(row=4, column=4, columnspan=4, rowspan=4)
button_Sharp_stick = tkinter.Button(Shop_GUI, text="Sharp stick", width=15, command=lambda: Sharp_Stick())
button_Sharp_stick.grid(row=4, column=0, rowspan=4, columnspan=2)
label_Fizzy = tkinter.Label(Shop_GUI, text="£4.10 | GLUG!")
label_Fizzy.grid(row=8, column=4, columnspan=4, rowspan=4)
button_Fizzy_drink = tkinter.Button(Shop_GUI, text="Fizzy drink", width=15, command=lambda: Fizzy_Drink())
button_Fizzy_drink.grid(row=8, column=0, rowspan=4, columnspan=2)
label_Icecream = tkinter.Label(Shop_GUI, text="£4.50 | Its gonna melt so eat it fast!")
label_Icecream.grid(row=12, column=4, columnspan=4, rowspan=4)
button_Ice_cream = tkinter.Button(Shop_GUI, text="Ice cream", width=15, command=lambda: Ice_Cream())
button_Ice_cream.grid(row=12, column=0, rowspan=4, columnspan=2)
label_Beer = tkinter.Label(Shop_GUI, text="£6 | Don't drink too much...")
label_Beer.grid(row=16, column=4, columnspan=4, rowspan=4)
button_Beer_ = tkinter.Button(Shop_GUI, text="Beer", width=15, command=lambda: beer())
button_Beer_.grid(row=16, column=0, rowspan=4, columnspan=2)
label_Scratch = tkinter.Label(Shop_GUI, text="£6.50 | Good luck!")
label_Scratch.grid(row=20, column=4, columnspan=4, rowspan=4)
button_Scratch_card = tkinter.Button(Shop_GUI, text="Scratch card", width=15, command=lambda: Scratch_Card())
button_Scratch_card.grid(row=20, column=0, rowspan=4, columnspan=2)
label_apartment_letter = tkinter.Label(Shop_GUI,
text="£500 | You can buy apartments using this overpriced letter")
label_apartment_letter.grid(row=24, column=4, columnspan=4, rowspan=4)
button_apartment_letter = tkinter.Button(Shop_GUI, text="Apartment letter", width=15,
command=lambda: Apartment_Letter())
button_apartment_letter.grid(row=24, column=0, rowspan=4, columnspan=2)
label_exit = tkinter.Label(Shop_GUI, text="Leave the shop")
label_exit.grid(row=28, column=4, columnspan=4, rowspan=4)
button_exit = tkinter.Button(Shop_GUI, text="Exit", width=15, command=lambda: exit_shop())
button_exit.grid(row=28, column=0, rowspan=4, columnspan=2)
Shop_GUI.mainloop()
End_game()
def Item():
End_game()
global Fishing_rod
global Sharp_stick
global Fizzy_drink
global Ice_cream
global Beer
global Scratch_card
print("Fishing rod | | {0}".format(Fishing_rod))
print("Sharp stick | | {0}".format(Sharp_stick))
print("Fizzy drink | | {0}".format(Fizzy_drink))
print("Ice cream | | {0}".format(Ice_cream))
print("Beer | | {0}".format(Beer))
print("Scratch card | | {0}".format(Scratch_card))
def Levels():
End_game()
global begging_level
global fishing_level
global hunting_level
print(“begging level | | {0}”.format(begging_level))
print(“Fishing level | | {0}”.format(fishing_level))
print(“Hunting level | | {0}”.format(hunting_level))
def Fish():
End_game()
global Fishing_rod
if Fishing_rod == 0:
print(“You try to catch fish with your bare hands… it fails. Hint: Buy a fishing rod from the shop”)
else:
global fish_amount
global fishing_level
fish_amount += 1
for i in range(fishing_level):
global money
if Fishing_rod >= 1:
if fish_amount == 5:
fish_amount = 0
fishing_level += 1
print("Level Up!")
if fishing_level >= 25:
amount_of_fish_list = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2]
amount_of_fish = random.choice(amount_of_fish_list)
if amount_of_fish == 1:
fish_list = ["bass", "turbot", "pollack", "black bream", "salmon", "cod", "nessie", "nessie",
"nessie"]
fish_caught = random.choice(fish_list)
if fish_caught == "nessie":
print("WOW! You caught nessie... the museum buys nessie for £50!")
print("+£50")
money += 50
else:
print("You caught a {0}! worth £1.25".format(fish_caught))
print("+£1.25")
money += 1.25
elif amount_of_fish == 2:
fish_list = ["bass", "turbot", "pollack", "black bream", "salmon", "cod", "nessie", "nessie",
"nessie"]
fish_list_2 = ["bass", "turbot", "pollack", "black bream", "salmon", "cod", "nessie", "nessie",
"nessie"]
fish_caught = random.choice(fish_list)
fish_caught_2 = random.choice(fish_list_2)
print("How? you caught 2 fish at once!")
if fish_caught == "nessie":
if fish_caught_2 == "nessie":
print(
"OMG you caught two nessie in one cast... the museum buys both nessie for £50 each!")
print("+£50")
print("+£50")
money += 100
else:
print(
"WOW! you caught nessie and {0}... how is that fish still alive... the museum buys "
"nessie for £50 and the fish was sold for £1.25".format(fish_caught_2))
print("+£50")
print("+£1.25")
money += 51.25
else:
if fish_caught_2 == "nessie":
print(
"WOW! you caught nessie and {0}... how is that fish still alive... the museum buys "
"nessie for £50 and the fish was sold for £1.25".format(fish_caught))
print("+£50")
print("+£1.25")
money += 51.25
else:
print("Nice catch! You caught a {0} and a {1} both worth £1.25 each".format(fish_caught,
fish_caught_2))
print("+£1.25")
print("+£1.25")
money += 2.50
else:
amount_of_fish_list = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2]
amount_of_fish = random.choice(amount_of_fish_list)
if amount_of_fish == 1:
fish_list = ["salmon", "cod", "bass", "turbot", "pollack", "black bream", "nessie", "salmon",
"cod", "bass", "turbot", "pollack", "black bream", "salmon", "cod", "bass",
"turbot", "pollack", "black bream"]
fish_caught = random.choice(fish_list)
if fish_caught == "nessie":
print("WOW! You caught nessie... the museum buys nessie for £50!")
print("+£50")
money += 50
else:
print("You caught a {0}! worth £1.25".format(fish_caught))
print("+£1.25")
money += 1.25
elif amount_of_fish == 2:
fish_list = ["salmon", "cod", "bass", "turbot", "pollack", "black bream", "nessie", "salmon",
"cod", "bass", "turbot", "pollack", "black bream", "salmon", "cod", "bass",
"turbot", "pollack", "black bream"]
fish_list_2 = ["salmon", "cod", "bass", "turbot", "pollack", "black bream", "nessie", "salmon",
"cod", "bass", "turbot", "pollack", "black bream", "salmon", "cod", "bass",
"turbot", "pollack", "black bream"]
fish_caught = random.choice(fish_list)
fish_caught_2 = random.choice(fish_list_2)
print("How? you caught 2 fish at once!")
if fish_caught == "nessie":
if fish_caught_2 == "nessie":
print("OMG you caught two nessie in one cast... the museum buys both nessie for £50 "
"each!")
print("+£50")
print("+£50")
money += 100
else:
print("WOW! you caught nessie and {0}... how is that fish still alive... the museum "
"buys "
"nessie for £50 and the fish was sold for £1.25".format(fish_caught_2))
print("+£50")
print("+£1.25")
money += 51.25
else:
if fish_caught_2 == "nessie":
print("WOW! you caught nessie and {0}... how is that fish still alive... the museum "
"buys "
"nessie for £50 and the fish was sold for £1.25".format(fish_caught))
print("+£50")
print("+£1.25")
money += 51.25
else:
print("Nice catch! You caught a {0} and a {1} both worth £1.25 each".format(fish_caught,
fish_caught_2))
print("+£1.25")
print("+£1.25")
money += 2.50
def Hunt():
End_game()
global hunt_amount
global hunting_level
global Sharp_stick
global money
global lives
if Sharp_stick >= 1:
hunt_amount += 1
if hunt_amount == 5:
hunt_amount = 0
hunting_level += 1
print("Level Up!")
print("Lives: {0}".format(lives))
print("If your lives get to 0 you will die and lose some of your coins and a chance of losing an item "
"you own")
print("You lose lives by encountering a bear")
animal_list = ["rabbit", "fox", "raccoon", "squirrel", "badger", "bear", "rabbit", "fox",
"raccoon", "squirrel", "badger", "bear", "rabbit", "fox", "raccoon", "squirrel",
"badger", "rabbit", "fox", "raccoon", "bear", "squirrel", "badger"]
animal_encountered = random.choice(animal_list)
if lives >= 1:
if animal_encountered == "bear":
print("Oh no! You encountered a bear and lost one life")
print("-1 <3")
lives -= 1
if lives < 1:
print("Oh no... you lost all your lives and lost £30...")
print("-£30")
money -= 30
lose_item_list = ["lost item", "no item lost", "no item lost"]
lose_item = random.choice(lose_item_list)
if lose_item == "lost item":
print("oh no.. your Sharp stick fell out of your hand as you ran in fear")
print("-1 Sharp stick")
Sharp_stick -= 1
else:
print("Luckily you didn't let go of your Sharp stick and lost no items")
print("Your lives have been replenished!")
print("+2 lives")
lives = 2
else:
print("Well done you hunted a {0}".format(animal_encountered))
if animal_encountered == "squirrel":
print("that poor squirrel D:")
print("no one wanted the squirrel so you let it back into the wild.. some how it survived")
elif animal_encountered == "fox":
print("You take the fox to a pet shop and convince the owner its a dog")
win = 10 * hunting_level
print("+£{0}".format(win))
money += win
else:
print("You sell the {0} for £2".format(animal_encountered))
win = 2 * hunting_level
print("+£{0}".format(win))
money += win
else:
print("oh no you don't have any lives..")
print("+2 lives")
lives = 2
else:
print("Its way too dangerous out in the woods without a weapon! Hint: Buy a sharp stick from the shop")
def Drinks():
End_game()
global Fizzy_drink
global Beer
global drunk
global money
print(“Fizzy drink | | {0}”.format(Fizzy_drink))
print(“Beer | | {0}”.format(Beer))
if Fizzy_drink == 0 and Beer == 0:
print(“you don’t have any drinks…”)
else:
if Fizzy_drink and Beer >= 1:
drink = input(“What would you like to drink? (Fizzy drink, Beer) :”)
if drink == “Fizzy drink”:
print(“glug glug glug”)
print(“Fizzy drink -1”)
Fizzy_drink -= 1
chance_list = [“no”, “no”, “no”, “yes”, “no”, “no”, “no”, “no”, “no”, “no”, “no”, “no”, “no”, ]
chance = random.choice(chance_list)
if chance == “no”:
Fizzy_drink += 0
elif chance == “yes”:
print(“BURRRRP”)
elif drink == “Beer”:
print(“glug glug glug”)
print(“Beer -1”)
Beer -= 1
drunk += 1
if drunk == 10:
print(“BURPPP”)
print("…")
print(“I don’t feel to good”)
print(“you wake up in the middle of the street and you have lost £35”)
print("- £35")
money -= 35
else:
print(“That was not an option!”)
elif Fizzy_drink >= 1 and Beer == 0:
drink = input("Would you like to drink Fizzy drink? (yes, no) :")
if drink == "yes" or "Yes":
print("glug glug glug")
print("Fizzy drink -1")
Fizzy_drink -= 1
chance_list = ["no", "no", "no", "yes", "no", "no", "no", "no", "no", "no", "no", "no", "no", ]
chance = random.choice(chance_list)
if chance == "no":
Fizzy_drink += 0
elif chance == "yes":
print("BURRRRP")
elif drink == "No" or "no":
print("You do not drink anything...")
else:
print("That was not an option!")
elif Beer >= 1 and Fizzy_drink == 0:
drink = input("Would you like to drink Beer? (yes, no) :")
if drink == "yes" or drink == "Yes":
print("glug glug glug")
print("Beer -1")
Beer -= 1
drunk += 1
if drunk == 10:
print("BURPPP")
print("...")
print("I don't feel to good")
print("you wake up in the middle of the street and you have lost £35")
print("- £35")
money -= 35
elif drink == "no" or drink == "No":
print("You don't drink anything...")
else:
print("That was not an option!")
def Scratch():
End_game()
global money
global Scratch_card
print(“Scratch cards | | {0} “.format(Scratch_card))
if Scratch_card >= 1:
Scratch_card -= 1
win_chance = [“loss”, “loss”, “loss”, “loss”, “loss”, “loss”, “win”]
print(“scratch”)
time.sleep(1)
print(“scratch”)
time.sleep(1)
print(“scratch”)
win_loss = random.choice(win_chance)
if win_loss == “win”:
amount_list = [“1”, “1”, “1”, “1”, “1”, “1”, “1”, “2”, “2”, “2”, “2”, “2”, “2”, “5”, “5”, “5”, “5”,
“5”, “10”, “10”, “10”, “10”, “20”, “20”, “20”, “50”, “50”, “100”, “250”]
win = random.choice(amount_list)
if win == “250”:
print(“OMG you won the top prize of {0}”.format(win))
money += 250
else:
print(“wow you won £{0}”.format(win))
print(”+£{0}”.format(win))
money += int(win)
elif win_loss == “loss”:
print(“Oh no… you won nothing…”)
else:
print(“error”)
else:
print(“You have no scratch cards…”)
def Food():
End_game()
global Ice_cream
print(“Ice cream | | {0}”.format(Ice_cream))
if Ice_cream == 0:
print(“Oh you have no food D:”)
else:
Ice_cream_yes_no = input(“Would you like to eat ice cream? (yes, no) : “)
if Ice_cream_yes_no == “yes” or Ice_cream_yes_no == “Yes”:
print(“OM”)
time.sleep(1)
print(“NOM”)
time.sleep(1)
print(“NOM”)
print(“Yum that was good”)
print(”-1 Ice cream”)
Ice_cream -= 1
brain_freeze_chance = [“yes”, “no”, “no”, “no”]
if brain_freeze_chance == “yes”:
print(“BRAIN FREEZEEE”)
elif brain_freeze_chance == “no”:
brain = “yes”
elif Ice_cream_yes_no == “no” or Ice_cream_yes_no == “No”:
print(“You don’t eat the ice cream…”)
def Apartment():
End_game()
global Apartment_letter
buying = True
if Apartment_letter >= 1:
Apartment_Letter = tkinter.Tk()
Apartment_Letter.title(“Apartment shop”)
def Swamp_House():
global money
global Swamp_house
if Swamp_house == 0:
if money >= 500:
print("That house has been on the market for years, finally its gone!")
print("Swamp house +1")
money -= 500
Swamp_house += 1
else:
print("You don't have enough money for this, sorry!")
elif Swamp_house >= 1:
print("You have already bought this house! I wonder why its still on the market...")
def Village_Round_house():
global money
global Village_round_house
if Village_round_house == 0:
if money >= 750:
print("Great choice! The people around there are so nice!")
print("Village round house +1")
money -= 750
Village_round_house += 1
else:
print("You don't have enough money for this, sorry!")
elif Village_round_house >= 1:
print("You have already bought this house! I wonder why its still on the market...")
def Small_House():
global money
global Small_house
if Small_house == 0:
if money >= 1500:
print("I was thinking of buying that myself D:")
print("Small house +1")
money -= 1500
Small_house += 1
else:
print("You don't have enough money for this, sorry!")
elif Small_house >= 1:
print("You have already bought this house! I wonder why its still on the market...")
def Medium_House():
global money
global Medium_house
if Medium_house == 0:
if money >= 2500:
print("Nice house! Good for its price too")
print("Medium house +1")
money -= 2500
Medium_house += 1
else:
print("You don't have enough money for this, sorry!")
elif Medium_house >= 1:
print("You have already bought this house! I wonder why its still on the market...")
def City_Apartment():
global money
global City_apartment
if City_apartment == 0:
if money >= 3000:
print("Its busy round there, lots of jobs though!")
print("City apartment +1")
money -= 3000
City_apartment += 1
else:
print("You don't have enough money for this, sorry!")
elif City_apartment >= 1:
print("You have already bought this house! I wonder why its still on the market...")
def Large_House():
global money
global Large_house
if Large_house == 0:
if money >= 4500:
print("Good luck finding anything in this house, ITS HUGE!")
print("Large house +1")
money -= 4500
Large_house += 1
else:
print("You don't have enough money for this, sorry!")
elif Large_house >= 1:
print("You have already bought this house! I wonder why its still on the market...")
def Flat_Building():
global money
global Flat_building
if Flat_building == 0:
if money >= 10000:
print("What are you going to use all those apartments for??")
print("Flat building +1")
money -= 10000
Flat_building += 1
else:
print("You don't have enough money for this, sorry!")
elif Flat_building >= 1:
print("You have already bought this building! I wonder why its still on the market...")
def mansion():
global money
global Mansion
if Mansion == 0:
if money >= 50000:
print("WOW your rich!!")
print("Mansion +1")
money -= 50000
Mansion += 1
else:
print("You don't have enough money for this, sorry!")
elif Mansion >= 1:
print("You have already bought this building! I wonder why its still on the market...")
label_Swamp_House = tkinter.Label(Apartment_Letter, text="1 floor | £500")
label_Swamp_House.grid(row=0, column=4, columnspan=4, rowspan=4)
button_SwampHouse = tkinter.Button(Apartment_Letter, text="Swamp house", width=15, command=lambda: Swamp_House())
button_SwampHouse.grid(row=0, column=0, rowspan=4, columnspan=3)
label_Village_Round_house = tkinter.Label(Apartment_Letter, text="1 floor | £750")
label_Village_Round_house.grid(row=4, column=4, columnspan=4, rowspan=4)
button_Village_Round_House = tkinter.Button(Apartment_Letter, text="Village round house", width=15, command=lambda: Village_Round_house())
button_Village_Round_House.grid(row=4, column=0, rowspan=4, columnspan=2)
label_Small_House = tkinter.Label(Apartment_Letter, text="2 floors | £1,500")
label_Small_House.grid(row=8, column=4, columnspan=4, rowspan=4)
button_SmallHouse = tkinter.Button(Apartment_Letter, text="Small house", width=15, command=lambda: Small_House())
button_SmallHouse.grid(row=8, column=0, rowspan=4, columnspan=2)
label_Medium_House = tkinter.Label(Apartment_Letter, text="2 floors | £2,500")
label_Medium_House.grid(row=12, column=4, columnspan=4, rowspan=4)
button_MediumHouse = tkinter.Button(Apartment_Letter, text="Medium house", width=15, command=lambda: Medium_House())
button_MediumHouse.grid(row=12, column=0, rowspan=4, columnspan=2)
label_City_Apartment = tkinter.Label(Apartment_Letter, text="1 floor | £3,000")
label_City_Apartment.grid(row=16, column=4, columnspan=4, rowspan=4)
button_CityApartment = tkinter.Button(Apartment_Letter, text="City apartment", width=15, command=lambda: City_Apartment())
button_CityApartment.grid(row=16, column=0, rowspan=4, columnspan=2)
label_Large_House = tkinter.Label(Apartment_Letter, text="3 floors | £4,500")
label_Large_House.grid(row=20, column=4, columnspan=4, rowspan=4)
button_LargeHouse = tkinter.Button(Apartment_Letter, text="Large house", width=15, command=lambda: Large_House())
button_LargeHouse.grid(row=20, column=0, rowspan=4, columnspan=2)
label_Flat_Building = tkinter.Label(Apartment_Letter, text="8 apartments | £10,000")
label_Flat_Building.grid(row=24, column=4, columnspan=4, rowspan=4)
button_FlatBuilding = tkinter.Button(Apartment_Letter, text="Flat building", width=15, command=lambda: Flat_Building())
button_FlatBuilding.grid(row=24, column=0, rowspan=4, columnspan=2)
label_mansion = tkinter.Label(Apartment_Letter, text="4 floors | £50,000")
label_mansion.grid(row=28, column=4, columnspan=4, rowspan=4)
button_Mansion = tkinter.Button(Apartment_Letter, text="Mansion", width=15, command=lambda: mansion())
button_Mansion.grid(row=28, column=0, rowspan=4, columnspan=2)
else:
print("You have not unlocked this command yet! Hint: buy the apartment letter")
End_game()
label_result = tkinter.Label(game_GUI, text=“Use this to earn small amounts of cash!”)
label_result.grid(row=0, column=4, columnspan=4, rowspan=4)
button_Beg = tkinter.Button(game_GUI, text=“Beg”, width=15, command=lambda: Beg())
button_Beg.grid(row=0, column=0, rowspan=4, columnspan=3)
label_result = tkinter.Label(game_GUI, text=“Check out your moneys!”)
label_result.grid(row=4, column=4, columnspan=4, rowspan=4)
button_Bank = tkinter.Button(game_GUI, text=“Bank”, width=15, command=lambda: Bank())
button_Bank.grid(row=4, column=0, rowspan=4, columnspan=2)
label_result = tkinter.Label(game_GUI, text=“Buy useful items!”)
label_result.grid(row=8, column=4, columnspan=4, rowspan=4)
button_Shop = tkinter.Button(game_GUI, text=“Shop”, width=15, command=lambda: Shop())
button_Shop.grid(row=8, column=0, rowspan=4, columnspan=2)
label_result = tkinter.Label(game_GUI, text=“See your items!”)
label_result.grid(row=12, column=4, columnspan=4, rowspan=4)
button_Item = tkinter.Button(game_GUI, text=“Items”, width=15, command=lambda: Item())
button_Item.grid(row=12, column=0, rowspan=4, columnspan=2)
label_result = tkinter.Label(game_GUI, text=“Catch fish and sell them for quick cash!”)
label_result.grid(row=16, column=4, columnspan=4, rowspan=4)
button_Fish = tkinter.Button(game_GUI, text=“Fish”, width=15, command=lambda: Fish())
button_Fish.grid(row=16, column=0, rowspan=4, columnspan=2)
label_result = tkinter.Label(game_GUI, text=“Hunt animals and sell them, be ware there is a bear!”)
label_result.grid(row=20, column=4, columnspan=4, rowspan=4)
button_Hunt = tkinter.Button(game_GUI, text=“Hunt”, width=15, command=lambda: Hunt())
button_Hunt.grid(row=20, column=0, rowspan=4, columnspan=2)
label_result = tkinter.Label(game_GUI, text=“Check your skill levels!”)
label_result.grid(row=24, column=4, columnspan=4, rowspan=4)
button_Levels = tkinter.Button(game_GUI, text=“Levels”, width=15, command=lambda: Levels())
button_Levels.grid(row=24, column=0, rowspan=4, columnspan=2)
label_result = tkinter.Label(game_GUI, text=“Drink!”)
label_result.grid(row=28, column=4, columnspan=4, rowspan=4)
button_Drinks = tkinter.Button(game_GUI, text=“Drinks”, width=15, command=lambda: Drinks())
button_Drinks.grid(row=28, column=0, rowspan=4, columnspan=2)
label_result = tkinter.Label(game_GUI, text=“Foooood!”)
label_result.grid(row=32, column=4, columnspan=4, rowspan=4)
button_Food = tkinter.Button(game_GUI, text=“Food”, width=15, command=lambda: Food())
button_Food.grid(row=32, column=0, rowspan=4, columnspan=2)
label_result = tkinter.Label(game_GUI, text=“Scratch your cards for cash”)
label_result.grid(row=36, column=4, columnspan=4, rowspan=4)
button_Scratch = tkinter.Button(game_GUI, text=“Scratch”, width=15, command=lambda: Scratch())
button_Scratch.grid(row=36, column=0, rowspan=4, columnspan=2)
label_result = tkinter.Label(game_GUI, text=“Buy apartments/buildings!”)
label_result.grid(row=40, column=4, columnspan=4, rowspan=4)
button_Apartment = tkinter.Button(game_GUI, text=“Apartment”, width=15, command=lambda: Apartment())
button_Apartment.grid(row=40, column=0, rowspan=4, columnspan=2)
game_GUI.mainloop()