Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class GAME():
- def __init__(self, input_handler, output_handler):
- self.input = input_handler
- self.output = output_handler
- def run(self):
- # start
- mode = self.get_mode()
- self.output.display('chosen mode is: %s' % mode)
- # the rest....
- return 0
- def get_mode(self):
- self.output.display('Please select a game mode:\n\
- [1] Human vs Human\n\
- [2] Human vs PC\n\
- [3] PC vs PC')
- chosen = self.input.query('your option is: ')
- return chosen
- class INPUT():
- def __init__(self):
- pass
- def query(self, query):
- return input(query)
- class OUTPUT():
- def __init__(self):
- pass
- def display(self, content):
- print content
- class CHARACTER():
- def __init__(self, game, **kwargs):
- self.game = game
- self.name = kwargs.pop('name')
- self.life = kwargs.pop('life')
- self.attacks = kwargs.pop('attacks')
- def get_attack(self, chosen_attack):
- return self.attacks[chosen_attack]
- def display_attacks(self, filter_name):
- for k, v in self.attacks.items():
- if filter_name in k:
- self.game.output.display('%s: %s' % k, v.description)
- class ATTACK():
- def __init__(self, name, damage, description):
- self.name = name
- self.damage = damage
- self.description = description
- class PUNCH(ATTACK):
- def __init__(self):
- ATTACK.__init__(self, 'punch', 10, 'punches for 10 damage')
- import sys
- def main(*args, **kwargs):
- i = INPUT()
- o = OUTPUT()
- return GAME(i, o)
- m = main(sys.argv)
- sys.exit(m.run())
Advertisement
Add Comment
Please, Sign In to add comment