Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. '''game.py: This is the main class of the game.'''
  2.  
  3. import os
  4. import sys
  5. from blessings import Terminal
  6.  
  7. from bureaucrat import Bureaucrat
  8.  
  9. t = Terminal()
  10.  
  11.  
  12. class Game:
  13.     '''The main logic of the game'''
  14.     def __init__(self):
  15.         self.clear_screen()
  16.         print(t.underline('LAM-40 0.2'))
  17.         self.bureaucrat = Bureaucrat()
  18.         self.bureaucrat.greet()
  19.         while True:
  20.             self.act()
  21.             if self.bureaucrat.negative is False:
  22.                 self.bureaucrat = Bureaucrat()
  23.                 self.bureaucrat.greet()
  24.  
  25.     def clear_screen(self):
  26.         if os.name == 'nt':
  27.             os.system('cls')
  28.         else:
  29.             os.system('clear')
  30.  
  31.     def act(self):
  32.         '''An action taken by the player.'''
  33.         self.actions = ['[A]sk', '[B]ribe', '[E]ntreat',
  34.                         '[P]ress', '[T]hreaten',
  35.                         '[W]ait', '[Q]uit']
  36.         for number, action in enumerate(self.actions):
  37.             number = str(number + 1)
  38.             print(number + '. ' + action)
  39.         self.action = input('\nWhat will you do? ').lower()
  40.         if self.action == 'q' or self.action == '7':
  41.             self.clear_screen()
  42.             print('Thank you for playing LAM-40.\n')
  43.             sys.exit()
  44.         elif self.action == 'w' or self.action == '6':
  45.             self.bureaucrat.negative = False
  46.         else:
  47.             self.react()
  48.  
  49.     def react(self):
  50.         '''A reaction to the choice of the player.'''
  51.         if self.bureaucrat.mood == 'good' and self.bureaucrat.rank == 'low':
  52.             if self.action == 'a' or self.action == '1':
  53.                 self.bureaucrat.react_positively()
  54.             else:
  55.                 self.bureaucrat.react_negatively()
  56.         elif self.bureaucrat.mood == 'good' and self.bureaucrat.rank == 'high':
  57.             if self.action == 'b' or self.action == '2':
  58.                 self.bureaucrat.react_positively()
  59.             else:
  60.                 self.bureaucrat.react_negatively()
  61.         elif self.bureaucrat.mood == 'average' and self.bureaucrat.rank == 'high':
  62.             if self.action == 'e' or self.action == '3':
  63.                 self.bureaucrat.react_positively()
  64.             else:
  65.                 self.bureaucrat.react_negatively()
  66.         elif self.bureaucrat.mood == 'average' and self.bureaucrat.rank == 'low':
  67.             if self.action == 'p' or self.action == '4':
  68.                 self.bureaucrat.react_positively()
  69.             else:
  70.                 self.bureaucrat.react_negatively()
  71.         elif self.bureaucrat.mood == 'bad' and self.bureaucrat.rank == 'low':
  72.             if self.action == 't' or self.action == '5':
  73.                 self.bureaucrat.react_positively()
  74.             else:
  75.                 self.bureaucrat.react_negatively()
  76.         else:
  77.             self.bureaucrat.react_negatively()
  78.  
  79. Game()