#!/usr/bin/env python
import time
import random
# Game Function
def game():
print ("Welcome to the cavern of secrets!")
time.sleep(3)
print("You enter a dark cavern out of curiosity. It is dark and you can't see much. You notice a sword on the ground.")
part1 = input("which do you take The Sword or not?.")
# sword taken
if part1 == "Sword" or part1 == "sword":
print ("You have taken the sword")
sword = 1
# sword not taken
if part1 == "not" or part1 == "no":
print ("You have taken nopthing")
sword = 0
time.sleep(3)
print ("You've come to a crosspath, in the distance to the left there is a small glowing object, the right just looks dark.")
part2 = input("Which way do you wish to go, Left or Right?")
# left
if part2 == "Left" or part2 == "left":
print ("you have gone left")
time.sleep(5)
print ("You approach the object......")
time.sleep(2)
print ("As you get closer to the object you notice that the glowing object is actually an eye!!!!!!")
time.sleep(2)
print("you look below the eye and see 2 fangs. TYou now see that the3 glowing object and the fangs are actually a spider.")
part3 = input("Do you try to fight it, Yes or No?")
# fight spider
if part3 == "yes" or part3 == "Yes":
# With sword
if sword == 1:
print("You have a sword to fight the spider with!")
time.sleep(1)
print("You quickly jab the spider in the eye to take the advantage!")
time.sleep(3)
print("FIGHTING.............")
print ("YOU MUST HIT ABOVE A FIVE TO KILL THE SPIDER!!!!!!")
print(" IF THE SPIDER HITS HIGHER THAN YOU, YOU WILL DIE!!!!!!!!")
time.sleep(5)
mydmg = int(random.randint(3, 10))
spiderdmg = int(random.randint(1, 6))
print ("You hit a", mydmg)
time.sleep(2)
print("The spider hit a", spiderdmg)
if spiderdmg > mydmg:
print ("The spider has dealt more damage than you!!!! You DIE!!!!!")
complete = 1
return complete
elif mydmg < 5:
print ("You didn't manage to kill the spider but you did manage to escape!!!")
complete = 1
return complete
# Without Sword
else:
print ("You don't have anything to fight with!!")
time.sleep(2)
print("FIGHTING.............")
print ("YOU MUST HIT ABOVE A FIVE TO KILL THE SPIDER!!!!!!")
print(" IF THE SPIDER HITS HIGHER THAN YOU, YOU WILL DIE!!!!!!!!")
time.sleep(5)
mydmg = int(random.randint(3, 7))
spiderdmg = int(random.randint(1, 6))
print("You hit a", mydmg)
time.sleep(2)
print ("The spider hits a", spiderdmg)
time.sleep(2)
if spiderdmg > mydmg:
print ("The spider has dealt more damage than you!!!! You DIE!!!!!")
complete = 0
return complete
elif mydmg < 5:
print ("You didn't manage to kill the spider but you did manage to escape!!!")
complete = 1
return complete
# DONT FIGHT SPIDER
elif mydmg:
print("You try to leave the spider alone....")
time.sleep(6)
print("As you start to walk away the spider ambushes you and impales you with its FANGS!!!!!!")
complete = 0
return complete
#turn right
if part2:
print(" You turn right, away from the glowing object, and attempt to leave the cave.")
time.sleep(1)
print("But something won't let you......")
complete = 0
return complete
# game loop
alive = true
while alive:
complete = game()
if complete == 1:
alive = input("You managed to escape the cavern alive :) Would you like to play again, yes or no?")
if alive == "yes" or alive == "Yes":
alive
else:
break
if complete == 0:
alive = input("You have DIED, Would you like to play again, Yes or No?")
if alive == "yes" or alive == "Yes":
alive
else:
break
未知语法错误
•
python