码迷,mamicode.com
首页 > 其他好文 > 详细

ex35.py

时间:2016-11-24 07:51:55      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:nice   false   bsp   ber   number   next   port   for   else   

 1 from sys import exit
 2 
 3 def gold_room():
 4     print ("This room is full of gold. how much do you take?")
 5     
 6     
 7     next = input(">")
 8     if "0" in next or "1"in next:
 9         how_much = int(next)
10     
11     else:
12         dead("Man, learn to type a number.")
13     
14     if how_much < 50:
15         print ("Nice. you‘re not greedy, you win!")
16         exit(0)
17     else:
18         dead("You greedy bastard!")
19 
20 def bear_room():
21     print ("This is a bear here.")
22     print ("the bear has a bunch of honey.")
23     print ("The fat bear is in front of another door")
24     print ("How are you going to move the bear?")
25     bear_moved = False
26 
27     while True:
28         next = input(">")
29         
30         if next == "take honey":
31             dead("The bear looks at you then slaps your face off.")
32         elif next == "Taunt bear" and not bear_moved:
33             print ("The bear has moved from the door. You can go through it now.")
34             bear_moved = True
35         elif next == "taunt bear" and  bear_moved:
36             dead("The bear gets pissed off and chews your leg off.")
37         elif next == "open door" and bear_moved:
38             gold_room()
39         else:
40             print ("I got no idea what that means.")
41 
42 def cthulhu_room():
43     print ("Here you see the great evil cthulhu.")
44     print ("He, it, whatever stares at you and you go insane.")
45     print ("Do you flee for your life or eat your head?")
46     
47     next = input (">")
48     
49     if "flee" in next:
50         start()
51     elif "head" in next:
52         dead("Well that was tasty!")
53     else:
54         cthulhu_room()
55 
56 def dead(why):
57     print (why, "Good job!")
58     exit(0)
59 
60 def start():
61     print ("You are in a dark room.")
62     print ("There is a door to your right and left.")
63     print("Which one do you take?")
64     
65     next = input(">")
66     
67     if next == "left":
68         bear_room()
69     elif next == "right":
70         cthulhu_room()
71     else:
72         dead("You stumble around the room until you starve.")
73     
74 start()
75 
76     
77         
78         
79         
80         
81         
82         
83         
84         
85     

 

ex35.py

标签:nice   false   bsp   ber   number   next   port   for   else   

原文地址:http://www.cnblogs.com/jiangzhipeng/p/6096045.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!