Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. import random
  2. import sys
  3.  
  4. greetings = ["'How can I help you?'", "'...'", "'Next!'"]
  5. positive_reactions = ["No worries, here's what you need to do.",
  6.                       "Let me help you with that."
  7.                       ]
  8. negative_reactions = ["I'm having a snack here, you'll have to wait.",
  9.                       "Go to hell.",
  10.                       "Do you really think it will work on me?",
  11.                       "Who do you think you are?"
  12.                       "..."
  13.                       ]
  14. MOODS = ('bad', 'average', 'good')
  15. RANKS = ('low', 'medium', 'high')
  16. ACTIONS = '[A]sk, [B]ribe, [E]ntreat, [P]ress, [T]hreaten: '
  17.  
  18.  
  19. class Bureaucrat:
  20.     '''A government employee who works in the Institution.'''
  21.  
  22.     def __init__(self):
  23.         self.rank = random.choice(RANKS)
  24.         self.mood = random.choice(MOODS)
  25.         self.negative = False
  26.  
  27.     def greet(self):
  28.         '''A random greeting from the government employee.'''
  29.  
  30.         print(random.choice(greetings))
  31.         print('The bureaucrat is of a {} rank.'.format(self.rank))
  32.         print('Its mood seems to be {}.'.format(self.mood))
  33.  
  34.     def react_positively(self):
  35.         '''A positive reaction to the choice of the player.'''
  36.  
  37.         self.negative = False
  38.         print(random.choice(positive_reactions))
  39.  
  40.     def react_negatively(self):
  41.         '''A negative reaction to the choice of the player.'''
  42.  
  43.         self.negative = True
  44.         print(random.choice(negative_reactions))
  45.  
  46.     def act(self):
  47.         self.action = input("What will you do? {} ".format(ACTIONS))
  48.         if self.action == 'Q':
  49.             print('Thank you for playing LAM-40.')
  50.             sys.exit()
  51.         elif self.action == 'W':
  52.             self.negative = False
  53.         else:
  54.             self.react()
  55.  
  56.     def react(self):
  57.         '''A reaction to the choice of the player.'''
  58.  
  59.         if self.mood == 'good' and self.rank == 'low':
  60.             if self.action == "A":
  61.                 self.react_positively()
  62.             else:
  63.                 self.react_negatively()
  64.         elif self.mood == 'good' and self.rank == 'high':
  65.             if self.action == "B":
  66.                 self.react_positively()
  67.             else:
  68.                 self.react_negatively()
  69.         elif self.mood == 'average' and self.rank == 'high':
  70.             if self.action == "E":
  71.                 self.react_positively()
  72.             else:
  73.                 self.react_negatively()
  74.         elif self.mood == 'average' and self.rank == 'low':
  75.             if self.action == "P":
  76.                 self.react_positively()
  77.             else:
  78.                 self.react_negatively()
  79.         elif self.mood == 'bad' and self.rank == 'low':
  80.             if self.action == "T":
  81.                 self.react_positively()
  82.             else:
  83.                 self.react_negatively()
  84.         else:
  85.             self.react_negatively()
  86.  
  87. print('LAM-40')
  88. bureaucrat = Bureaucrat()
  89. bureaucrat.greet()
  90. while True:
  91.     bureaucrat.act()
  92.     if bureaucrat.negative is False:
  93.         bureaucrat = Bureaucrat()
  94.         bureaucrat.greet()