因此,我有一个文本冒险游戏的intr计算机科学类&;我需要把东西放进去。在定义中,我有一个全局变量刀。但是我需要这样做,这样它就不会在你每次走进房间(或者需要定义)时要求你拿起刀,如果你已经拿起了刀
global knife
global knife_val
if knife_val = 1
knife = input("You step on the handle of a knife when walking into the room. Do you wish to pick it up?").lower()
if knife == "yes":
print("You picked up the Knife!")
knife_val = 0
后来它问你
attack = input("Do you wish to attack?")
if attack == "yes":
move_miss = random.randint(1,5)
if move_miss == 1:
miss = True
else:
miss = False
if miss:
print("You missed!")
print("You are bitten by the monster and you die. Goodbye")
quit()
elif attack == "no":
print("You are bitten by the monster and you die. Goodbye")
quit()
print("You beat the monster!")
elif knife_val = 1:
print("You are bitten by the monster and you die. Goodbye")
quit()
我如何才能使其仅在满足条件时发生?当我尝试之前,有一个错误
目前没有回答
相关问题 更多 >
编程相关推荐