如何确保即使满足第一个语句,缩进的if语句仍然会触发



如果我存活下来,我的游戏似乎在模块1之后就停止了,我看不出问题是什么。游戏应该一个接一个地进行。但是,当您在模块中幸存时,它不会继续。这是代码:

#CAVEGAME
#Import
import random
import pickle
#Introduction
print("--------CaveGame V.4.1----------")
print("Credits - Rhys")
#Name loading
account_name = pickle.load(open( "caveuser1.pickle", "rb" ))
if account_name == 'Rhys':
print("Welcome Rhys. Dev mode active")
elif account_name == 'Dev':
print("Welcome developer. Dev mode active")
elif account_name == 'Mannat':
print("You are not authorised to access this game.")
quit()
elif account_name == 'Tammana':
print("You are not authorised to access this game.")
quit()
elif account_name == 'Yameen':
print("You are not authorised to access this game - YAMEEN. ")
quit()
elif account_name == 'CroissantMafia':
print("Weclome Croissant Disciples. Go to this link for the code: https://github.com/DominionGaming/CaveGame")
else:
print("Welcome to CaveGame")
#Stats
health = 20
damage = 1.5
points = 0
#PART1
print(account_name, "you are travelling down a cave and come to a fork in the cave. There are two paths - which do you choose?")
guess = int(input("Make a guess"))
tnl1 = random.randint(1,2)
if guess == tnl1:
print('You survived')
points = points + 50
elif guess != tnl1:
print("You found a drakon")
drakon1_health1 = 6
drakon1_health2 = drakon1_health1 - damage
drakon1_damage = 0.5
health = health - drakon1_damage
print("Your health is",health, "and the drakon's health is", drakon1_health2)
health = health - drakon1_damage
print("The drakon is defeated and your health is", health)
points = points - 50
#PART2
print("Well", account_name, "you are travelling down a cave and come to another fork in the cave. There are two paths - which do you choose?")
guess2 = int(input("Make a guess"))
tnl2 = random.randint(1,2)
if guess2 == tnl2:
print('You survived')
print("You recieved a combat upgrade. You now deal more damage")
points = points + 50
damage = damage + 2
elif guess2 != tnl2:
print("A wave of fire rolls through the tunnel. You lose 5 health")
health = health - 5
points = points - 50
#PART3
print("Well", account_name, "you are travelling down a cave and come to another fork in the cave. This time there are three paths - which do you choose?")
guess3 = int(input("Make a guess"))
tnl3 = random.randint(1,3)
if guess3 == tnl3:
print('You survived')
print("You recieved a health upgrade.")
health = health + 1.4
points = points + 50
elif guess3 != tnl3:
print("There was a cave in. You lost")
points = points - 50
quit()
#PART4
print("Well", account_name, "you are travelling down a cave and come to another fork in the cave. This time there are three paths - which do you choose?")
guess4 = int(input("Make a guess"))
tnl4 = random.randint(1,3)
if guess4 == tnl4:
print('You survived')
points = points + 50
elif guess4 != tnl4:
print("You found Cleo. Your damage has been increased but at a cost of some health")
health = health - 2
damage = damage + 1.4
points = points - 50
#PART5
print("Well", account_name, "you are travelling down a cave and come to another fork in the cave. This time there are three paths - which do you choose?")
guess5 = int(input("Make a guess"))
tnl5 = random.randint(1,3)
if guess5 == tnl5:
print('You survived')
print("You got 50 extra points!")
points = points + 100
elif guess5 != tnl5:
print("You encounter a demigorgon")
demigorgon1_health1 = 8
demigorgon1_damage = 2.5
demigorgon1_health2 = demigorgon1_health1 - damage
health = health - demigorgon1_damage
print("Your health is", health, "and the demigorgon's is", demigorgon1_health2)
demigorgon1_health3 = 0
health = health - demigorgon1_damage
print("The demigorgon is defearted but your health is", health)
points = points - 50
#PART6
print("Well", account_name, "you are travelling down a cave and come to another fork in the cave. This time there are three paths - which do you choose?")
guess6 = int(input("Make a guess"))
tnl6 = random.randint(1,3)
if guess6 == tnl6:
print('You survived')
points = points + 50
print("These are your final points:", points," and this is your final health:", health)
elif guess6 != tnl6:
print("You fell into a pool of acid. You lost health and extra points")
health = health - 4
points = points - 100
print("These are your final points:", points," and this is your final health:", health)

我试着让它在选择一条隧道后发生不同的事件,然后你会进入下一条隧道,但没有成功。

只回答问题;您拥有的";第2部分";你应该全力以赴。

很难知道什么样的解释对你最有帮助,但有了这样的解释,我喜欢想到索引卡。

每";如果";创建两个索引卡。一个代表当它是真的,一个代表它是假的。

你有一张索引卡,上面有:

print('You survived')
points = points + 50

还有一张和其他所有东西的卡片。最轻的通行证修复方法是:

#CAVEGAME
#Import
import random
import pickle
#Introduction
print("--------CaveGame V.4.1----------")
print("Credits - Rhys")
#Name loading
account_name = pickle.load(open( "caveuser1.pickle", "rb" ))
if account_name == 'Rhys':
print("Welcome Rhys. Dev mode active")
elif account_name == 'Dev':
print("Welcome developer. Dev mode active")
elif account_name == 'Mannat':
print("You are not authorised to access this game.")
quit()
elif account_name == 'Tammana':
print("You are not authorised to access this game.")
quit()
elif account_name == 'Yameen':
print("You are not authorised to access this game - YAMEEN. ")
quit()
elif account_name == 'CroissantMafia':
print("Weclome Croissant Disciples. Go to this link for the code: https://github.com/DominionGaming/CaveGame")
else:
print("Welcome to CaveGame")
#Stats
health = 20
damage = 1.5
points = 0
#PART1
print(account_name, "you are travelling down a cave and come to a fork in the cave. There are two paths - which do you choose?")
guess = int(input("Make a guess"))
tnl1 = random.randint(1,2)
if guess == tnl1:
print('You survived')
points = points + 50
elif guess != tnl1:
print("You found a drakon")
drakon1_health1 = 6
drakon1_health2 = drakon1_health1 - damage
drakon1_damage = 0.5
health = health - drakon1_damage
print("Your health is",health, "and the drakon's health is", drakon1_health2)
health = health - drakon1_damage
print("The drakon is defeated and your health is", health)
points = points - 50

#PART2
print("Well", account_name, "you are travelling down a cave and come to another fork in the cave. There are two paths - which do you choose?")
guess2 = int(input("Make a guess"))
tnl2 = random.randint(1,2)
if guess2 == tnl2:
print('You survived')
print("You recieved a combat upgrade. You now deal more damage")
points = points + 50
damage = damage + 2
elif guess2 != tnl2:
print("A wave of fire rolls through the tunnel. You lose 5 health")
health = health - 5
points = points - 50
#PART3
print("Well", account_name, "you are travelling down a cave and come to another fork in the cave. This time there are three paths - which do you choose?")
guess3 = int(input("Make a guess"))
tnl3 = random.randint(1,3)
if guess3 == tnl3:
print('You survived')
print("You recieved a health upgrade.")
health = health + 1.4
points = points + 50
elif guess3 != tnl3:
print("There was a cave in. You lost")
points = points - 50
quit()
#PART4
print("Well", account_name, "you are travelling down a cave and come to another fork in the cave. This time there are three paths - which do you choose?")
guess4 = int(input("Make a guess"))
tnl4 = random.randint(1,3)
if guess4 == tnl4:
print('You survived')
points = points + 50
elif guess4 != tnl4:
print("You found Cleo. Your damage has been increased but at a cost of some health")
health = health - 2
damage = damage + 1.4
points = points - 50
#PART5
print("Well", account_name, "you are travelling down a cave and come to another fork in the cave. This time there are three paths - which do you choose?")
guess5 = int(input("Make a guess"))
tnl5 = random.randint(1,3)
if guess5 == tnl5:
print('You survived')
print("You got 50 extra points!")
points = points + 100
elif guess5 != tnl5:
print("You encounter a demigorgon")
demigorgon1_health1 = 8
demigorgon1_damage = 2.5
demigorgon1_health2 = demigorgon1_health1 - damage
health = health - demigorgon1_damage
print("Your health is", health, "and the demigorgon's is", demigorgon1_health2)
demigorgon1_health3 = 0
health = health - demigorgon1_damage
print("The demigorgon is defearted but your health is", health)
points = points - 50
#PART6
print("Well", account_name, "you are travelling down a cave and come to another fork in the cave. This time there are three paths - which do you choose?")
guess6 = int(input("Make a guess"))
tnl6 = random.randint(1,3)
if guess6 == tnl6:
print('You survived')
points = points + 50
print("These are your final points:", points," and this is your final health:", health)
elif guess6 != tnl6:
print("You fell into a pool of acid. You lost health and extra points")
health = health - 4
points = points - 100
print("These are your final points:", points," and this is your final health:", health)

最新更新