Пример #1
0
    def get_awards(self):
        '''
        Provides an index of available awards.

        Args:
            None

        Returns:
            awards (list): Returns the list of all awards.
        '''

        # Get a list of all the award processors
        processors = stat_mgr.get_processors('awards')

        # Build an index of the available awards
        awards = list()
        for processor in processors:
            awards.append({
                'id': processor.id,
                'name': processor.name,
                'desc': processor.desc
            })

        # Sort the index by award name
        awards.sort(key=lambda a: a['name'].lower())
        return awards
Пример #2
0
    def get_award(self, id):
        '''
        Provides details for a specific award based on the given award
        identifier.

        Args:
           id (string): The unique identifier of an award.

        Returns:
            award (object): Detailed information for a specific award.
        '''

        # Get the processor for the requested award
        processor = stat_mgr.get_processor(id)
        if not processor: raise cherrypy.HTTPError(404)

        processors = stat_mgr.get_processors(processor.processor_type)
        prev_id = None
        if processor.type_index > 0:
            prev_id = processors[processor.type_index - 1].id
        next_id = None
        if processor.type_index < len(processors) - 1:
            next_id = processors[processor.type_index + 1].id

        # Respond with a summary of the award information
        return {
            'id': processor.id,
            'name': processor.name,
            'desc': processor.desc,
            'columns': processor.columns,
            'notes': processor.notes,
            'rows': processor.get_results(),
            'prev_id': prev_id,
            'next_id': next_id
        }
Пример #3
0
    def get_awards(self):
        """
        Provides an index of available awards.

        Args:
            None

        Returns:
            awards (list): Returns the list of all awards.
        """

        # Get a list of all the award processors
        processors = stat_mgr.get_processors("awards")

        # Build an index of the available awards
        awards = list()
        for processor in processors:
            awards.append({"id": processor.id, "name": processor.name, "desc": processor.desc})

        # Sort the index by award name
        awards.sort(key=lambda a: a["name"].lower())
        return awards
Пример #4
0
    def post_process(self):

        # Get a list of all the award processors
        processors = stat_mgr.get_processors('awards')

        # Skip the current award
        processors.remove(self)

        for processor in processors:
            results = processor.get_results()
            if len(results) > 0:
                player_id = results[0][0]['id']
                gold = model_mgr.get_player( player_id )
                self.results[gold] += 1

            if len(results) > 1:
                player_id = results[1][0]['id']
                silver = model_mgr.get_player( player_id )
                self.results[silver] += 1

            if len(results) > 2:
                player_id = results[2][0]['id']
                bronze = model_mgr.get_player( player_id )
                self.results[bronze] += 1
Пример #5
0
    def get_award(self, id):
        """
        Provides details for a specific award based on the given award
        identifier.

        Args:
           id (string): The unique identifier of an award.

        Returns:
            award (object): Detailed information for a specific award.
        """

        # Get the processor for the requested award
        processor = stat_mgr.get_processor(id)
        if not processor:
            raise cherrypy.HTTPError(404)

        processors = stat_mgr.get_processors(processor.processor_type)
        prev_id = None
        if processor.type_index > 0:
            prev_id = processors[processor.type_index - 1].id
        next_id = None
        if processor.type_index < len(processors) - 1:
            next_id = processors[processor.type_index + 1].id

        # Respond with a summary of the award information
        return {
            "id": processor.id,
            "name": processor.name,
            "desc": processor.desc,
            "columns": processor.columns,
            "notes": processor.notes,
            "rows": processor.get_results(),
            "prev_id": prev_id,
            "next_id": next_id,
        }