蓝天,小湖,湖水中一方小筑

[剧透] Inception

晚上去看了传说中的 Inception,先不涉及情节的小评论一下:情节中上(因为几年前就看过这类的小说),场面一般(不知道IMAX会不会好些),别的没啥了吧 。然后,现在正式开始剧透,而且本文属于纯无聊加剧透的产物,所以无论看过还是没看过的都要慎入啊~

其实真的是无聊了,等程序的过程中写了这个玩意,嗯,所以就表再说我无聊鸟,哈哈~

首先是主线~

def main():
  # 下面开始主循环~
  while True:
    # 首先要去偷那个日本老板的梦
    try:
      extract(objective = 'Saito')
    except missionFailException:
      # 结果被识破
      if not accept_offer(offer_from = 'Saito'):
        # 任务失败了就只有挂了嘛
        game_over(objective = 'Cobb')
      else:
        # 不过那个老板能量很大
        try:
          inception(objective = 'Robert Fischer')
        except missionFailException:
          game_over(objective = 'Cobb')

        # 任务完成了,木有犯罪记录了,可以回家了
        clean_criminal_rcds(owner = 'Cobb')
        back_home(objective = 'Cobb')

    # 最后那个扣子留的啊......
    to_be_continued('dreaming or not dreaming, that is the question')

然后是inception的过程

def inception(person):
  # 找forger,为了在梦里变形,找到Eames
  # 找architect,构建梦境,找到Ariadne
  # 找chemist,配镇静剂,找到Yusuf
  (forger, architect, chemist) = find_teammember()

  # 开始查资料
  #  Robert Fischer: 被inception的目标,被改造成败家子
  #  Maurice Fischer: 败家子(筹)他爹,挂ing
  #  Peter Browning: 败家子(筹)的教父,被forger假份后用来策反败家子
  background_info = collect_info(['Robert Fischer', 'Maurice Fischer', 'Peter Browning'])

  init_members = {
        'Cobb': 'health',
        'Arthur': 'health',
        'Eames': 'health',
        'Yusuf': 'health',
        'Saito': 'health',
        'Ariadne': 'health',
        'Robert Fischer': 'health',
      }

  # 一些前期工作,如要收买空姐地勤结果把航空公司收买了之类
  pre_inception()

  try:
    while True:
      # 在飞机上开始折腾,第一层梦(如果不算最外面一层的话)
      anaesthetize('Robert Fischer')
      dream_scene = DreamSence(scene = 'flight from Sydeny to Los Angel',
          team = init_members, depth = 1, owner = 'Yusuf')
      dream_scene.dream_in_flight()
  except AnMaNiBaMiHong:
    # 男猪脚都跳出来了,自然就结束了啦~
    return 

最后是那个做梦的类,有些地方用程序不好表示啊,凑合看吧,嘿嘿。男猪脚最后退出的方式很牛,可惜Python中木有goto,只好用exception代替了~

class DreamSence:
  def __init__(self, scene, team, depth, owner):
    self.scene = scene # 场景
    self.team = team  # 梦中人
    self.depth = depth # 深度
    self.owner = owner # 梦境的所有人

  def dream_in_flight(self):
    # 唔,一堆defender,还都是武装过的
    self.fight_with_defenders(owner = 'Robert Fischer', level = 'armed')
    # 于是日本老板中弹了,但还不能让他死
    self.team['Saito'] = 'dying'
    # 开始夺命狂奔
    self.start_running()
    # 第二层梦
    # Yusuf留在外面开车
    self.team.pop('Yusuf')
    dream_scene = DreamSence(scene = 'Running Car', team = self.team,
        depth = 2, owner = 'Arthur')
    dream_scene.dream_in_car()

  def dream_in_car(self):
    # 告诉Fischer丫在梦里
    invokeMrSecure(objective = 'Robert Fischer')
    # 第三层梦
    # Arthur留外面叫他们起床
    self.team.pop('Arthur')
    dream_scene = DreamSence(scene = 'Hotel', team = self.team, depth = 3,
        owner = 'Eames')
    dream_scene.dream_in_hotel()
    # 被叫醒~
    self.be_kicked()

  def dream_in_hotel(self):
    # 还是要和那帮defender打啊,而且武器更精良了
    self.fight_with_defenders(owner = 'Robert Fischer', level = 'army')
    # Fischer挂了,被Cobb老婆Mal杀的
    self.kill_person(killer = 'Mal', objective = 'Robert Fischer')
    self.team['Robert Fischer'] = 'dead'
    # Saito也挂了,也算在Mal头上吧
    self.kill_person(killer = 'Mal', objective = 'Saito')
    self.team['Saito'] = 'dead'
    # 第四层梦
    # Eames留上面电Fischer玩
    self.team.pop('Eames')
    dream_scene = DreamSence(scene = 'SnowMountain', team = self.team,
        depth = 4, owner = 'Cobb')
    dream_scene.dream_in_mountain()
    # 被叫醒
    self.be_kicked()

  def dream_in_mountain(self):
    # 先找老婆
    find_person(objective = 'Mal')
    # 认清身处梦中
    clearify_state(objective = 'Cobb')
    # 救Fischer
    self.be_kicked('Robert Fischer')
    # Ariadne自己出去了
    self.be_kicked('Ariadne')
    # 救Saito
    self.be_kicked('Saito')
    # 唔,男猪脚终于牛了一把,直接跳出这一堆梦中
    if self.owner == 'Cobb':
      raise AnMaNiBaMiHong

  def be_kicked(objective = None):
    # 被踢醒之前还是需要恢复健康滴~
    if objective == None:
        for i in self.team:
            self.team[i] = 'health'
    else:
        self.team[objective] = 'health'

    wake_up()