好的,所以我试图设置一个布尔值,这样如果一个项目被取走,它就会变成 True,下一次如果它是 True,那么它会采用不同的路径,这是我第一次用 Python 编写东西,所以请原谅糟糕的代码约定。无论如何,在记笔记之前,我需要布尔为 False,当它是时,我希望它变为 True。我将来可能会遇到的一个问题是,有一部分玩家回到了这个房间,当他们回到这个房间时,我怎样才能让布尔值保持真实?
def first_room(Note):
choice1_1 = raw_input('The house looks much larger than it did from the outside. You appear in a room, to your left is a closet, to your right is a pile of junk, in front of you is a door, and behind you is the exit.')
choice1_1 = choice1_1.lower()
if choice1_1 == 'left' or choice1_1 == 'l' or choice1_1 == 'closet':
if note == False:
choice1_c = raw_input('You open the closet and check inside, there is a note. Do you take the note? (Y/N)')
choice1_c = choice1_c.lower()
if choice1_c == 'y':
print 'You took the note.'
first_room(True)
if choice1_c == 'n':
print 'You leave the note alone.'
first_room(False)
else:
print 'The closet is empty.'
first_room(True)
first_room(False)