Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. '''bureaucrat.py: This class describes government officials, the only enemies of the game.'''
  2.  
  3. import random
  4. from blessings import Terminal
  5.  
  6. import text
  7.  
  8. t = Terminal()
  9.  
  10.  
  11. class Bureaucrat:
  12.     '''A government employee who works at the Institution.'''
  13.     def __init__(self):
  14.         self.gender = random.random()
  15.         if self.gender >= 0.505:
  16.             self.gender = 'Her'
  17.         elif self.gender < 0.505 and self.gender >= 0.01:
  18.             self.gender = 'His'
  19.         else:
  20.             self.gender = "The bureaucrat's"
  21.         self.rank = random.choice(['low', 'medium', 'high'])
  22.         self.mood = random.choice(['bad', 'average', 'good'])
  23.         self.negative = False
  24.  
  25.     def greet(self):
  26.         '''A random greeting from the government employee.'''
  27.         print('\n' + random.choice(text.greetings) +
  28.               '\nA wild bureaucrat of a {} rank appears!\n'.format(
  29.               t.bold(self.rank)) +
  30.               '{} mood seems to be {}.\n'.format(
  31.               self.gender, t.bold(self.mood)))
  32.  
  33.     def react_positively(self):
  34.         '''A positive reaction to the choice of the player.'''
  35.         self.negative = False
  36.         print(t.bold("\nIt's super effective!\n") +
  37.               random.choice(text.positive_reactions))
  38.  
  39.     def react_negatively(self):
  40.         '''A negative reaction to the choice of the player.'''
  41.         self.negative = True
  42.         print(t.bold("\nIt doesn't affect the bureaucrat!\n") +
  43.               random.choice(text.negative_reactions)  + '\n')