ex35
from sys import exit def gold_room(): print("This room is full of gold. How much do you take?") #这个房间装满了金币 你要拿多少? choice = input(">>>") if "0" in choice or "1" in choice: how_much = int(choice) else: dead("Man, learn to type a number.")#小伙子,学一下怎么输入个数字吧 if how_much < 50: print("Nice, you're not greedy, you win!")#不错,你不贪心,你赢了! exit(0)#程序正常退出 else: dead("You greedy bastard!")#你这个贪婪的混蛋! def bear_room(): print("There is a bear here.")#那儿有只熊 print("The bear has a bunch of honey.")#这只熊有一堆蜂蜜。 print("The fat bear is in front of another door.")#这只肥熊在另一扇门前。 print("How are you going to move the bear?")#你打算怎样移动熊? bear_moved = False #移动熊是错的 while True: choice = input(">>>") if choice == "take honey": dead("The bear looks at you then slaps your face off.")#熊看着你,然后拍打你的脸。 elif choice == "taunt bear" and not bear_moved:#嘲笑熊,而且并不是False(不移动熊) print("The bear has moved from the door.")#熊从门口移开了,你可以通过了 print("You can go through it now.") bear_moved = True #移动熊=True elif choice == "taunt bear" and bear_moved: dead("The bear gets pissed off and chews your leg off.")#熊被激怒了,咬掉了你的腿。 elif choice == "open door" and bear_moved:#打开门并且没有移动熊 gold_room()#进了金子屋 else: print("I got no idea what that means.")#我不知道那是什么意思。 def cthulhu_room(): print("Here you see the great evil Cthulhu.")#这里你可以看到个大恶魔 print("He, it, whatever stares at you and you go insane.")#他,不管你怎么盯着你,你都会发疯。 print("Do you flee for your life or eat your head?")#你是逃命还是吃了你的头? choice = input(">>>") if "flee" in choice:#如果逃命 start()#执行start()函数 elif "head" in choice:#选头 dead("Well that was tasty!")#嗯,那很好吃 else: cthulhu_room()#都不是就困在屋子里 def dead(why):#死亡函数 print(why, "Good job!") exit(0) def start(): print("You are in a dark room.")#你在一个黑暗的房间里,现在你左右都有门 print("There is a door to your right and left.") print("Which one do you take?") choice = input(">>>") if choice =="left": bear_room()#选左是熊 elif choice == "right": cthulhu_room()#选右是恶魔 else: dead("You stumle around the room until you starve.")#都不是,你在房间里跌跌撞撞地走来走去,直到饿死。 start()#最先执行start()函数