Changeset 548


Ignore:
Timestamp:
06/18/10 08:47:47 (9 years ago)
Author:
beliar
Message:

Renaming Controller to GameModel? to reflect its purpose.

Location:
branches/code-cleanup-and-refactoring/game
Files:
4 edited
1 moved

Legend:

Unmodified
Added
Removed
  • branches/code-cleanup-and-refactoring/game/local_loaders/xmlmap.py

    r547 r548  
    112112        self.data = data 
    113113        self.vfs = self.engine.getVFS() 
    114         self.controller = self.engine.getModel() 
     114        self.model = self.engine.getModel() 
    115115        self.pool = self.engine.getImagePool() 
    116116        self.anim_pool = self.engine.getAnimationPool() 
     
    149149        map = None 
    150150        try: 
    151             self.map = self.controller.createMap(str(id)) 
     151            self.map = self.model.createMap(str(id)) 
    152152            self.map.setResourceFile(self.source) 
    153153        # NameClash appears as general fife.Exception; any ideas? 
     
    241241 
    242242            allow_diagonals = pathing == "cell_edges_and_diagonals" 
    243             cell_grid = self.controller.getCellGrid(grid_type) 
     243            cell_grid = self.model.getCellGrid(grid_type) 
    244244            if not cell_grid: self._err('<layer> declared with invalid '\ 
    245245                                       'cell grid type. (%s)' % grid_type) 
     
    311311            self.n_space = n_space 
    312312 
    313             object = self.controller.getObject(str(object_id), str(n_space)) 
     313            object = self.model.getObject(str(object_id), str(n_space)) 
    314314            if not object: 
    315315                print ''.join(['Object with id=', str(object_id), ' ns=', \ 
  • branches/code-cleanup-and-refactoring/game/scripts/console.py

    r547 r548  
    2222        @type appListener: ApplicationListener 
    2323        @param appListener: ApplicationListener object providing a link with 
    24         the engine, the world and the controller""" 
     24        the engine, the world and the model""" 
    2525        exit_help   = "Terminate application" 
    2626        grid_help   = "Toggle grid display" 
     
    4646        self.app_listener = app_listener 
    4747        self.world = self.app_listener.world  
    48         self.engine = self.app_listener.controller 
     48        self.engine = self.app_listener.model 
    4949        self.game_state = self.app_listener.world.data.game_state 
    5050 
     
    7878           @param command: The command to run. 
    7979           @return: The response""" 
    80         if self.app_listener.controller.pc_run == 1: 
    81             self.app_listener.controller.pc_run = 0 
     80        if self.app_listener.model.pc_run == 1: 
     81            self.app_listener.model.pc_run = 0 
    8282            return "PC is now walking" 
    8383        else: 
    84             self.app_listener.controller.pc_run = 1 
     84            self.app_listener.model.pc_run = 1 
    8585            return "PC is now running" 
    8686             
     
    124124                l_args = command.lower()[end_load + 1:].strip() 
    125125                l_path, l_filename = l_args.split(' ') 
    126                 self.app_listener.controller.load_save = True 
    127                 self.app_listener.controller.savegame = os.path.join(l_path, l_filename) 
     126                self.app_listener.model.load_save = True 
     127                self.app_listener.model.savegame = os.path.join(l_path, l_filename) 
    128128                result = "Load triggered" 
    129129 
     
    146146                s_args = command.lower()[end_save+1:].strip() 
    147147                s_path, s_filename = s_args.split(' ') 
    148                 self.app_listener.controller.save(s_path, s_filename) 
     148                self.app_listener.model.save(s_path, s_filename) 
    149149                result = "Saved to file: " + s_path + s_filename 
    150150 
  • branches/code-cleanup-and-refactoring/game/scripts/gamemodel.py

    r547 r548  
    2424import yaml 
    2525 
    26 class Controller(object): 
    27     """Controller holds the logic for the game. 
     26class GameModel(object): 
     27    """GameModel holds the logic for the game. 
    2828       Since some data (object position and so forth) is held in the 
    2929       fife, and would be pointless to replicate, we hold a instance of 
     
    135135        # create the extra data 
    136136        extra = {} 
    137         extra['engine'] = self 
     137        extra['controller'] = self 
    138138        attributes = self.checkAttributes(attributes) 
    139139         
     
    163163        if layer is not None: 
    164164            extra['agent_layer'] = layer 
    165         extra['engine'] = self 
     165        extra['controller'] = self 
    166166        attributes = self.checkAttributes(attributes) 
    167167         
  • branches/code-cleanup-and-refactoring/game/scripts/map.py

    r547 r548  
    4040        self.agent_layer = None 
    4141        self.top_layer = None 
    42         self.controller = engine.getModel() 
     42        self.model = engine.getModel() 
    4343        self.transitions = [] 
    4444        self.cur_cam2_x = 0 
     
    5353        # We have to delete the map in Fife. 
    5454        if self.map: 
    55             self.controller.deleteObjects() 
    56             self.controller.deleteMap(self.map) 
     55            self.model.deleteObjects() 
     56            self.model.deleteMap(self.map) 
    5757        self.transitions = [] 
    5858        self.map = None 
     
    9797            y = float(self.data.target_position[1]) 
    9898            z = 0 
    99             pc_obj = self.controller.getObject("player", "PARPG") 
     99            pc_obj = self.model.getObject("player", "PARPG") 
    100100            inst = self.agent_layer.createInstance(pc_obj,\ 
    101101                                            fife.ExactModelCoordinate(x,y,z),\ 
  • branches/code-cleanup-and-refactoring/game/scripts/parpg.py

    r547 r548  
    1717from fife.extensions import pychan 
    1818from fife.extensions.basicapplication import ApplicationBase 
    19 from scripts import controller 
     19from scripts import gamemodel 
    2020 
    2121from scripts import world 
     
    3737 
    3838class ApplicationListener(eventlistenerbase.EventListenerBase): 
    39     def __init__(self, engine, world, controller): 
     39    def __init__(self, engine, world, model): 
    4040        """Initialise the instance. 
    41            @type engine: fife.Controller 
     41           @type engine: fife.GameModel 
    4242           @param engine: ??? 
    4343           @type world: world.World 
    4444           @param world: ??? 
    45            @type controller: engine.Controller 
    46            @param controller: an instance of PARPG's engine""" 
     45           @type model: engine.GameModel 
     46           @param model: an instance of PARPG's engine""" 
    4747        super(ApplicationListener, self).__init__(engine, 
    4848                                                  reg_keys=True,reg_cmd=True, 
     
    5252        self.engine = engine 
    5353        self.world = world 
    54         self.controller = controller 
     54        self.model = model 
    5555        keyfilter = KeyFilter([fife.Key.ESCAPE]) 
    5656        keyfilter.__disown__()         
     
    8787class PARPGApplication(ApplicationBase): 
    8888    """Main Application class 
    89        We use an MVC data controller. 
    90        self.world is our view,self.engine is our controller 
     89       We use an MVC data model. 
     90       self.world is our view,self.model is our model 
    9191       This file is the minimal controller""" 
    9292    def __init__(self, setting): 
     
    9595        super(PARPGApplication, self).__init__(setting) 
    9696        self.world = world.World(self.engine) 
    97         self.controller = controller.Controller(self.world) 
    98         self.controller.readObjectDB(self._setting.get("PARPG",  
     97        self.model = gamemodel.GameModel(self.world) 
     98        self.model.readObjectDB(self._setting.get("PARPG",  
    9999                                                  "ObjectDatabaseFile")) 
    100         self.world.data = self.controller 
     100        self.world.data = self.model 
    101101        self.world.initHud() 
    102         self.listener = ApplicationListener(self.engine, self.world, self.controller) 
     102        self.listener = ApplicationListener(self.engine, self.world, self.model) 
    103103        self.world.quitFunction = self.listener.quitGame 
    104         self.controller.loadMap("main-map", str(self._setting.get("PARPG",  
     104        self.model.loadMap("main-map", str(self._setting.get("PARPG",  
    105105                                                             "MapFile"))) 
    106106        pychan.init(self.engine, debug = True) 
     
    119119            self.breakRequested = True 
    120120        else: 
    121             self.controller.pump() 
     121            self.model.pump() 
    122122            self.world.pump() 
Note: See TracChangeset for help on using the changeset viewer.