Exemplo n.º 1
0
    def read(self, request, player_id=None):
        if player_id:
            try:
                player = Player.objects.get(pk=player_id)
            except Player.DoesNotExist:
                return rc.NOT_FOUND
        else:
            try:
                player = request.user.get_profile()
            except Player.DoesNotExist:
                return rc.NOT_FOUND

        level = {
            'name': player.level.name,
            'title': player.level.title,
            'image': player.level.image,
            'id': player.level.id,
        } if player.level else {}

        group = player.group
        gold = player.coins['gold'] if 'gold' in player.coins.keys() else 0
        topuser = player.get_extension(TopUser)

        return {
            'username':
            player.user.username,
            'nickname':
            player.nickname,
            'first_name':
            player.user.first_name,
            'last_name':
            player.user.last_name,
            'email':
            player.user.email,
            'avatar':
            player_avatar(player),
            'points':
            player.points,
            'gold':
            gold,
            'race':
            player.race_name,
            'race_slug':
            player.race.name.lower()
            if player.race and player.race.name else '',
            'race_id':
            player.race.id if player.race else 0,
            'group':
            group,
            'level_no':
            player.level_no,
            'level':
            level,
            'level_progress':
            God.get_level_progress(player),
            'rank':
            topuser.position,
        }
Exemplo n.º 2
0
    def read(self, request, player_id=None):
        if player_id:
            try:
                player = Player.objects.get(pk=player_id)
            except Player.DoesNotExist:
                return rc.NOT_FOUND
        else:
            try:
                player = request.user.get_profile()
            except Player.DoesNotExist:
                return rc.NOT_FOUND

        level = {
            'name': player.level.name,
            'title': player.level.title,
            'image': player.level.image,
            'id': player.level.id,
            } if player.level else {}

        group = player.group
        gold = player.coins['gold'] if 'gold' in player.coins.keys() else 0
        topuser = player.get_extension(TopUser)

        return {'username': player.user.username,
                'nickname': player.nickname,
                'first_name': player.user.first_name,
                'last_name': player.user.last_name,
                'email': player.user.email,
                'avatar': player_avatar(player),
                'points': player.points,
                'gold': gold,
                'race': player.race_name,
                'race_slug': player.race.name.lower() if player.race and player.race.name else '',
                'race_id': player.race.id if player.race else 0,
                'group': group,
                'level_no': player.level_no,
                'level': level,
                'level_progress': God.get_level_progress(player),
                'rank': topuser.position,
                }
Exemplo n.º 3
0
 def level_progress(self):
     """ Return a dictionary with: points_gained, points_left, next_level """
     return God.get_level_progress(self)
Exemplo n.º 4
0
 def level_progress(self):
     """ Return a dictionary with: points_gained, points_left, next_level """
     return God.get_level_progress(self)