Exemplo n.º 1
0
 def load_setup(self, data):
     # Load abilities
     for type_name, type_data in data['abilities'].items():
         self.ability_types[type_name] = type_data
     
     # Load actors
     for type_name, type_data in data['actors'].items():
         actor_lib.build_template_cache(type_data, self.engine)
         self.actor_types[type_name] = type_data
Exemplo n.º 2
0
    def load_setup(self, data):
        # Load resources
        # Currently we're using a dictionary with only 1 entry
        # per key but it's possible we'll need to start using more
        # values per key so we're using a dictionary
        for res_data in data['resources']:
            self.resources[res_data['name']] = res_data
        
        # Function to handle ability inheritance
        def _get_ability_data(type_name):
            type_data = data['abilities'][type_name]

            if "inherits_from" in type_data:
                combined_data = dict(_get_ability_data(type_data['inherits_from']))
                for k, v in type_data.items():
                    combined_data[k] = v

                return combined_data
            return type_data
        
        # Load abilities
        for type_name in data['abilities'].keys():
            type_data = _get_ability_data(type_name)
            self.ability_types[type_name] = _get_ability_data(type_name)
        
        
        # Function to handle actor inheritance
        def _get_actor_data(type_name):
            type_data = data['actors'][type_name]
            
            if "inherits_from" in type_data:
                combined_data = dict(_get_actor_data(type_data['inherits_from']))
                for k, v in type_data.items():
                    combined_data[k] = v
                
                return combined_data
            return type_data
        
        # Load actors
        for type_name in data['actors'].keys():
            type_data = _get_actor_data(type_name)
            actor_lib.build_template_cache(type_data, self.engine)
            
            self.actor_types[type_name] = type_data
            self.actor_types[type_name]['name'] = type_name
        
        # Load tech trees
        for tree_name, tree_data in data['tech_trees'].items():
            self.tech_trees[tree_name] = tree_data
        
        # Load build dicts
        for build_name, build_list in data['build_lists'].items():
            self.build_lists[build_name] = build_list