首页 > 代码库 > Mac安装python的细节
Mac安装python的细节
from sys import exit from random import randint class Scene(object): def enter(self): print "This scene is not yet configured.Subclass it and implement enter()." exit(1) class Engine(object): current_scene=self.scene_map.opening_scene() while True: print "\n-------" next_scene_name=current_scene.enter() current_scene=self.scene_map.next_scene(next_scene_name) class Death(Scene): quips=[ "You died.You kinda suck at this.", "Your mom would be proud...if she were smarter.", "Such a luser.", "I have a small puppy that‘s better at this." ] def enter(self): print Death.quips[randint(0,len(quips)-1)] exit(1) class CentralCorridor(Scene): def enter(self): print "The Gothons of Plant #25 have invaded your ship and destoryed" print "your crew.you are the last surviving member and your last" print "mission is to get the neutron destruct bomb from the weapons armory," print "put it in the bridge,and blow the ship up after getting into an " print "escape pod." print "\n" print "your are running down the central corridor to the weapons armory when" print "a Gothon jumps out,red scaly skin,dark grimy teeth,and evil clown costume" print "flowing around his hate filled body. He is blocking the door to the " print "armory and about to pull a weapon tho blast you." action=raw_input("> ") if action=="shoot!": print "quick on the draw you yank out your blaster and fire it at th Gothon." return "death" elif action=="dodge!": print "like a world class boxer you dodge,weave,slip and slide right." return "death" elif action=="tell a joke": print "lucky for you they made you learn Gothon insults in the academy." return "laser_weapon_armory" else: print "does not compute!" return ‘central_corridor‘ class LaserWeaponArmory(Scene): def enter(self): print "you do a dive roll into the weapon armory,crouch and scan the room" guess=raw_input("[keypad]> ") guess=0 while guess != code and guess<10: print "BZZZZEDDD!" guesses+=1 guess=raw_input("[keypad]>") if guess==code: print "the container clicks open and the seal breaks,letting gas out." return "the bridge" else: print "the lock buzzes one last time then you hear a sickening" return "death" class TheBridge(Scene): def enter(self): print "you burst onto the bridge with the neutron destruct bomb" action=raw_input("> ") if action=="throw the bomb": print "in a panic you throw the bomb at the group of Gothons" return "death" elif action=="slowly place the bomb": print "you point out blaster at the bomb under your arm" return "escape_pod" else: print "does not compute!" return "the_bridge!" class EscapePod(Scene): def enter(self): print "you rush through the ship desperately trying to make it to " print "do you take?" good_pod=randint(1,5) guess=raw_input("[pod #]> ") if int(guess) !=good_pod: print "you jump into pod %s and hit teh eject button." %guess return "death" else: print "you jump into pod %s and hit the eject button."%guess print "time. you won!" return "finished" class Map(object): scene={ "central_corridor":CentralCorridor(), "laser_weapon_armory":LaserWeaponArmory(), "the_bridge":TheBridge(), "escape_pod":EscapePod(), "death":Death() } def __init__(self,start_scene): self.start_scene=start_scene def next_scene(self.start_scene): return Map.scenes.get(scene_name) def opening_scene(self): return self.next_scene(self.start_scene)
Mac安装python的细节
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。