コード例 #1
0
ファイル: tasks.py プロジェクト: slyons/udbraaains
def process_data(data, ip):
    """Processes a data set from the UD plugin for a given IP address."""
    
    # Grab the goon category to auto-tag plugin users
    goon = Category.objects.get(name=u'Goon')
    
    # Get coordinates and location of the current player
    coords = (data['surroundings']['position']['coords']['x'], 
                data['surroundings']['position']['coords']['y'])

    p_location = Location.objects.get(x=coords[0], y=coords[1])
    
    # Grab the player object, update is dead flag
    player = get_player(data['user']['id'], category=goon)
    player.is_dead = not data['user']['alive']
    player.save()


    position = data['surroundings']['position']
    
    # Build primary report
    report = Report()
    report.location = p_location
    report.inside = data['surroundings']['inside']
    report.has_tree = position['christmasTree']
    report.barricade_level = position.get('barricades')
    report.is_ruined = position['ruined']
    report.is_illuminated = position['illuminated']
    report.zombies_present = position['zombies']
    report.zombies_only = False
    report.reported_by = player
    report.origin = ip
    report.save()
    
    # Add players to the primary report
    results = []
    for profile in position['survivors']:
        results.append(get_player.delay(profile['id'], report))
    
    # Throw away the middle cell, we've already processed it
    del data['surroundings']['map'][1][1]

    if not report.inside:
        for row in data['surroundings']['map']:
            for col in row:
                location = Location.objects.get(x=col['coords']['x'], y=col['coords']['y'])
                secondary = Report()
                secondary.reported_by = player
                secondary.zombies_present = col['zombies']
                secondary.location = location
                secondary.origin = ip
                secondary.save()
                build_annotation.delay(location)

        
    build_annotation.delay(p_location)
コード例 #2
0
def process_data(data, ip):
    """Processes a data set from the UD plugin for a given IP address."""

    # Grab the goon category to auto-tag plugin users
    goon = Category.objects.get(name=u'Goon')

    # Get coordinates and location of the current player
    coords = (data['surroundings']['position']['coords']['x'],
              data['surroundings']['position']['coords']['y'])

    try:
        p_location = Location.objects.get(x=coords[0], y=coords[1])
    except Location.DoesNotExist:
        CONN.lpush('location-errors', json.dumps(dict(data=data, ip=ip)))
        raise

    # Grab the player object, update is dead flag. We save right here,
    # so avoid extra save
    player = get_player(data['user']['id'], category=goon, save=False)
    player.is_dead = not data['user']['alive']
    player.save()

    position = data['surroundings']['position']

    # Build primary report
    report = Report()
    report.location = p_location
    report.inside = data['surroundings']['inside']
    report.has_tree = position['christmasTree']
    report.barricade_level = position.get('barricades')
    report.is_ruined = position['ruined']
    report.is_illuminated = position['illuminated']
    report.zombies_present = position['zombies']
    report.zombies_only = False
    report.reported_by = player
    report.origin = ip
    report.save()

    # Add players to the primary report
    results = []
    for profile in position['survivors']:
        try:
            results.append(get_player.delay(profile['id'], report))
        except KeyError:
            print data, ip
            CONN.lpush('errors', json.dumps(dict(data=data, ip=ip)))
            raise

    if not report.inside:
        for row in data['surroundings']['map']:
            for col in row:
                location = Location.objects.get(x=col['coords']['x'],
                                                y=col['coords']['y'])
                if location == p_location:
                    continue
                secondary = Report()
                secondary.reported_by = player
                secondary.zombies_present = col['zombies']
                secondary.location = location
                secondary.origin = ip
                secondary.save()
                CONN.sadd('rebuild', location.id)

    CONN.sadd('rebuild', p_location.id)
コード例 #3
0
ファイル: tasks.py プロジェクト: slyons/udbraaains
def process_data(data, ip):
    """Processes a data set from the UD plugin for a given IP address."""

    # Grab the goon category to auto-tag plugin users
    goon = Category.objects.get(name=u'Goon')

    # Get coordinates and location of the current player
    coords = (data['surroundings']['position']['coords']['x'],
              data['surroundings']['position']['coords']['y'])

    p_location = Location.objects.get(x=coords[0], y=coords[1])

    # Grab the player object, update is dead flag
    player = get_player(data['user']['id'], category=goon)
    player.is_dead = not data['user']['alive']
    player.save()

    position = data['surroundings']['position']

    # Build primary report
    report = Report()
    report.location = p_location
    report.inside = data['surroundings']['inside']
    report.has_tree = position['christmasTree']
    report.barricade_level = position.get('barricades')
    report.is_ruined = position['ruined']
    report.is_illuminated = position['illuminated']
    report.zombies_present = position['zombies']
    report.zombies_only = False
    report.reported_by = player
    report.origin = ip
    report.save()

    # Add players to the primary report
    results = []
    for profile in position['survivors']:
        results.append(get_player.delay(profile['id'], report))

    # Throw away the middle cell, we've already processed it
    del data['surroundings']['map'][1][1]

    if not report.inside:
        for row in data['surroundings']['map']:
            for col in row:
                location = Location.objects.get(x=col['coords']['x'],
                                                y=col['coords']['y'])
                secondary = Report()
                secondary.reported_by = player
                secondary.zombies_present = col['zombies']
                secondary.location = location
                secondary.origin = ip
                secondary.save()
                build_annotation.delay(location)

    build_annotation.delay(p_location)