InbarRose

Game Sample

May 9th, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.76 KB | None | 0 0
  1. class GAME():
  2.     def __init__(self, input_handler, output_handler):
  3.         self.input = input_handler
  4.         self.output = output_handler
  5.  
  6.     def run(self):
  7.         # start
  8.         mode = self.get_mode()
  9.         self.output.display('chosen mode is: %s' % mode)
  10.         # the rest....
  11.         return 0
  12.        
  13.     def get_mode(self):
  14.         self.output.display('Please select a game mode:\n\
  15.                            [1] Human vs Human\n\
  16.                            [2] Human vs PC\n\
  17.                            [3] PC vs PC')
  18.         chosen = self.input.query('your option is: ')
  19.         return chosen
  20.        
  21. class INPUT():
  22.     def __init__(self):
  23.         pass
  24.     def query(self, query):
  25.         return input(query)
  26.        
  27. class OUTPUT():
  28.     def __init__(self):
  29.         pass
  30.     def display(self, content):
  31.         print content
  32.  
  33. class CHARACTER():
  34.     def __init__(self, game, **kwargs):
  35.         self.game = game
  36.         self.name = kwargs.pop('name')
  37.         self.life = kwargs.pop('life')
  38.         self.attacks = kwargs.pop('attacks')
  39.  
  40.     def get_attack(self, chosen_attack):
  41.         return self.attacks[chosen_attack]
  42.  
  43.     def display_attacks(self, filter_name):
  44.         for k, v in self.attacks.items():
  45.             if filter_name in k:
  46.                 self.game.output.display('%s: %s' % k, v.description)
  47. class ATTACK():    
  48.     def __init__(self, name, damage, description):
  49.         self.name = name
  50.         self.damage = damage
  51.         self.description = description
  52.  
  53. class PUNCH(ATTACK):
  54.     def __init__(self):
  55.         ATTACK.__init__(self, 'punch', 10, 'punches for 10 damage')
  56.  
  57. import sys
  58.  
  59. def main(*args, **kwargs):
  60.     i = INPUT()
  61.     o = OUTPUT()
  62.     return GAME(i, o)
  63.  
  64. m = main(sys.argv)
  65. sys.exit(m.run())
Advertisement
Add Comment
Please, Sign In to add comment