Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import sys
- greetings = ["'How can I help you?'", "'...'", "'Next!'"]
- positive_reactions = ["No worries, here's what you need to do.",
- "Let me help you with that."
- ]
- negative_reactions = ["I'm having a snack here, you'll have to wait.",
- "Go to hell.",
- "Do you really think it will work on me?",
- "Who do you think you are?"
- "..."
- ]
- MOODS = ('bad', 'average', 'good')
- RANKS = ('low', 'medium', 'high')
- ACTIONS = '[A]sk, [B]ribe, [E]ntreat, [P]ress, [T]hreaten: '
- class Bureaucrat:
- '''A government employee who works in the Institution.'''
- def __init__(self):
- self.rank = random.choice(RANKS)
- self.mood = random.choice(MOODS)
- self.negative = False
- def greet(self):
- '''A random greeting from the government employee.'''
- print(random.choice(greetings))
- print('The bureaucrat is of a {} rank.'.format(self.rank))
- print('Its mood seems to be {}.'.format(self.mood))
- def react_positively(self):
- '''A positive reaction to the choice of the player.'''
- self.negative = False
- print(random.choice(positive_reactions))
- def react_negatively(self):
- '''A negative reaction to the choice of the player.'''
- self.negative = True
- print(random.choice(negative_reactions))
- def act(self):
- self.action = input("What will you do? {} ".format(ACTIONS))
- if self.action == 'Q':
- print('Thank you for playing LAM-40.')
- sys.exit()
- elif self.action == 'W':
- self.negative = False
- else:
- self.react()
- def react(self):
- '''A reaction to the choice of the player.'''
- if self.mood == 'good' and self.rank == 'low':
- if self.action == "A":
- self.react_positively()
- else:
- self.react_negatively()
- elif self.mood == 'good' and self.rank == 'high':
- if self.action == "B":
- self.react_positively()
- else:
- self.react_negatively()
- elif self.mood == 'average' and self.rank == 'high':
- if self.action == "E":
- self.react_positively()
- else:
- self.react_negatively()
- elif self.mood == 'average' and self.rank == 'low':
- if self.action == "P":
- self.react_positively()
- else:
- self.react_negatively()
- elif self.mood == 'bad' and self.rank == 'low':
- if self.action == "T":
- self.react_positively()
- else:
- self.react_negatively()
- else:
- self.react_negatively()
- print('LAM-40')
- bureaucrat = Bureaucrat()
- bureaucrat.greet()
- while True:
- bureaucrat.act()
- if bureaucrat.negative is False:
- bureaucrat = Bureaucrat()
- bureaucrat.greet()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement