Question: My code needs fixed so it runs properly. And I'd like to add in more Super Potions that will display at the end. import random
My code needs fixed so it runs properly. And I'd like to add in more Super Potions that will display at the end.
import random
# game function
def game():
print ("Welcome to The Metropolis, Superman. A Ms. Lane needs help in Gotham.")
print ("You travel to Gotham to search for the Ms. Lane. You see a Super Potion.")
ch1 = str(input("Do take the Super Potion? [y/n]: "))
if ch1 in ['y', 'Y', 'Yes', 'YES', 'yes']:
print("You pick up the Super Potion!")
Super Potion = 1
#no Super Potion
else:
print("You left the Super Potion")
Super Potion = 0
print ("As you move further into Gotham you see a person in the distance. Could it be the Ms. Lane?")
ch2 = str(input("Do you approach the shadow? [y/n]"))
#The Joker action
if ch2 in ['y', 'Y', 'Yes', 'YES', 'yes']:
print ("You approach the Ms. Lane...")
print ("You walk closer to the person.")
print ("It's not the Ms. Lane! It's a The Joker!!!")
ch3 = str(input("Do you stay and fight it? [Y/N]"))
# FIGHT The Joker
if ch3 in ['y', 'Y', 'Yes', 'YES', 'yes']:
# WITH Super Potion
if Super Potion == 1:
print ("You have the Super Potion to fight with!")
print ("You swing the fiery stick at the The Joker as it fights back")
print (" THE FIGHT IS CLOSE ")
print (" YOU MUST HIT ABOVE A 5 TO KILL THE THE JOKER ")
print ("IF THE THE JOKER HITS MORE THAN YOU, YOU DIE!")
fdmg1 = int(random.randint(3, 10))
edmg1 = int(random.randint(1, 5))
print ("You hit a", fdmg1)
print ("The The Joker hits a", edmg1)
if edmg1 > fdmg1:
print ("The The Joker has dealt more damage than you!")
complete = 0
return complete
elif fdmg1 < 5:
print ("You hurt the The Joker but didn't kill it, you manage to escape")
complete = 1
return complete
else:
print ("You killed the The Joker!")
complete = 1
return complete
# WITHOUT STICK
else:
print ("You don't have anything to fight with!")
print (" THE THE JOKER HAS THE UPPER HAND ")
print (" YOU MUST HIT ABOVE A 5 TO KILL THE THE JOKER ")
print ("IF THE THE JOKER HITS MORE THAN YOU, YOU DIE!")
fdmg1 = int(random.randint(1, 8))
edmg1 = int(random.randint(1, 5))
print ("You hit a", fdmg1)
print ("The The Joker hits a", edmg1)
if edmg1 > fdmg1:
print ("The The Joker has dealt more damage than you!")
complete = 0
return complete
elif fdmg1 < 5:
print ("You fought bravely without a weapon and hurt the The Joker but didn't kill it, you manage to escape")
complete = 1
return complete
else:
print ("You killed the The Joker!")
complete = 1
return complete
#DON'T FIGHT The Joker
print ("You choose to sneak around the The Joker.")
time.sleep(1)
print ("As you sneak away you step on a stick, the The Joker shoots you!")
complete = 0
return complete
# DON'T APPROACH The Joker
else:
print ("You turn away from the shadow, and attempt to continue the voyage...")
complete = 0
return complete
# game loop
alive = True
while alive:
complete = game()
if complete == 1:
alive = input('You managed to find the Ms. Lane! Would you like to play again? [y/n]: ')
if alive in ['y', 'Y', 'YES', 'yes', 'Yes',]:
alive
else:
break
else:
alive = input('You have died! Would you like to play again? [y/n]: ')
if alive in ['y', 'Y', 'YES', 'yes', 'Yes',]:
alive
else:
break
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
