Refactored to stop passing game around.
[realism.git] / ui / ui.py
blob5862fce11773eb03aad0c1ed75ed40f773ce37da
1 class NotImplementedException(Exception): pass
3 class UI(object):
4 '''The generic user interface.'''
5 class_name = "Generic UI"
7 def ni(self, function = None):
8 '''Throws a "not implemented" exception. If function name is provided, it is included in the exception.'''
9 if function:
10 raise NotImplementedException(function + " is not implemented by " + self.class_name)
11 raise NotImplementedException("This function is not implemented by " + self.class_name)
13 def __init__(self):
14 '''Iself.nitializes the user interface.'''
15 self.ni('__init__')
17 def main_loop(self):
18 '''Invokes the main control loop.'''
19 self.ni('main_loop')
21 def map_mode(self, map):
22 '''Puts the UI in map mode.'''
23 self.ni('map_mode')
25 def shop_mode(self, shop):
26 '''Puts the UI in shop mode.'''
27 self.ni('shop_mode')
29 def battle_mode(self, battle):
30 '''Puts the UI in battle mode.'''
31 self.ni('battle_mode')
33 def conversation_mode(self, conversation):
34 '''Puts the UI in conversation mode.'''
35 self.ni('conversation_mode')
37 def hp_tick(self, character, amount):
38 '''Reports a gain in health.'''
39 self.ni('hp_tick')
41 def mp_tick(self, character, amount):
42 '''Reports a gain in mana.'''
43 self.ni('mp_tick')
45 def gained_ability_level(self, character, ability):
46 '''Reports an ability level gain.'''
47 self.ni('gained_ability_level')
49 def gained_level(self, character):
50 '''Reports a level gain.'''
51 self.ni('gained_level')