Ejemplo n.º 1
0
def get(body_id: int,
        primary_color: int = None,
        body_paint: int = None,
        team: int = None):
    """
    :param body_id: The ID of the body used in replay files
    :param primary_color: The primary color of the body in 0xFFFFFF integer format. If not provided, the default blue is applied.
    :param body_paint: The color of the paint applied to the body
    :param team: If this is set, the default blue (0) or the default orange(0) color will be used. This is ignored if primary_color is set.
    """
    body = body_dao.get(body_id)

    if body is None:
        raise NotFoundException('Body not found')

    if primary_color is None:
        if team == TEAM_ORANGE:
            primary_color = 0xFC7C0C
        else:
            primary_color = 0x0C88FC

    static_skin = BodyTexture(get_asset_url(body.base_skin),
                              get_asset_url(body.blank_skin), primary_color,
                              body_paint)

    static_skin.load()
    static_skin.update()

    image = Image.fromarray(static_skin.data)

    return serve_pil_image(image)
Ejemplo n.º 2
0
def update(wheel_id):
    item = wheel_dao.get(wheel_id)

    if item is None:
        raise NotFoundException('Wheel not found')

    item.update(request.json)
    return '', 200
Ejemplo n.º 3
0
def update_antenna(antenna_id):
    item = antenna_dao.get(antenna_id)

    if item is None:
        raise NotFoundException('Antenna stick not found')

    item.update(request.json)
    return '', 200
Ejemplo n.º 4
0
def update(decal_detail_id):
    item = decal_dao.get_detail(decal_detail_id)

    if item is None:
        raise NotFoundException('Decal detail not found')

    item.update(request.json)
    return '', 200
Ejemplo n.º 5
0
def update_body(body_id):
    item = body_dao.get(body_id)

    if item is None:
        raise NotFoundException('Body not found')

    item.update(request.json)
    return '', 200
Ejemplo n.º 6
0
def update(topper_id):
    item = topper_dao.get(topper_id)

    if item is None:
        raise NotFoundException('Decal detail not found')

    item.update(request.json)
    return '', 200
Ejemplo n.º 7
0
def get_by_id(id: int):
    """
    :param id: ID of the item (in-game item ID).
    """
    decal = decal_dao.get(id)

    if decal is None:
        raise NotFoundException('Wheel not found')

    return jsonify(decal.to_dict()), 200
Ejemplo n.º 8
0
def get_by_id(id: int):
    """
    :param id: ID of the item (in-game item ID).
    """
    topper = topper_dao.get(id)

    if topper is None:
        raise NotFoundException('Wheel not found')

    return jsonify(topper.to_dict()), 200
Ejemplo n.º 9
0
def add_antenna():
    antenna = Antenna()
    antenna.apply_dict(request.json)
    stick = database.get_antenna_stick(antenna.stick_id)
    if stick is None:
        raise NotFoundException('Antenna stick ID does not exist')
    antenna.stick = stick
    antenna_dao.add(antenna)
    database.commit()
    return jsonify(antenna.to_dict())
Ejemplo n.º 10
0
def get_by_id(id: int):
    """
    :param id: ID of the item (in-game item ID).
    """
    body = body_dao.get(id)

    if body is None:
        raise NotFoundException('Body not found')

    return jsonify(body.to_dict()), 200
Ejemplo n.º 11
0
def get_by_id(id: int):
    """
    :param id: ID of the item (in-game item ID).
    """
    antenna = antenna_dao.get(id)

    if antenna is None:
        raise NotFoundException('Wheel not found')

    return jsonify(antenna.to_dict()), 200
Ejemplo n.º 12
0
def get(product_id):
    try:
        product_id = int(product_id)
    except ValueError:
        raise BadRequestException('product id must be an integer')

    product = product_dao.get(product_id)

    if product is None:
        raise NotFoundException('Product not found')

    return jsonify(product.to_dict())
Ejemplo n.º 13
0
def put(key_id):
    key = key_dao.get(key_id)

    if key is None:
        raise NotFoundException('API key not found')

    key.name = request.json['name']
    key.description = request.json['description']
    key.active = request.json['active']

    database.commit()

    return '', 200
Ejemplo n.º 14
0
def get(body_id: int, body_paint: int = None):
    """
    :param body_id: The ID of the body used in replay files
    :param body_paint: The color of the paint applied to the body
    """
    body = body_dao.get(body_id)

    if body is None:
        raise NotFoundException('Body not found')

    if body.chassis_base is None:
        raise NotFoundException(
            'Body has no chassis textures. This is most likely because the chassis is not paintable.'
        )

    texture = ChassisTexture(get_asset_url(body.chassis_base),
                             get_asset_url(body.chassis_n), body_paint)

    texture.load()
    texture.update()

    image = Image.fromarray(texture.data)

    return serve_pil_image(image)
Ejemplo n.º 15
0
def add_decal():
    decal = Decal()
    decal.apply_dict(request.json)

    detail = database.get_decal_detail(decal.decal_detail_id)
    if detail is None:
        raise NotFoundException('Decal detail ID does not exist')

    if decal.body_id:
        body = body_dao.get(decal.body_id)
        if body is not None:
            decal.body = body

    decal.decal_detail = detail
    decal_dao.add(decal)
    database.commit()
    return jsonify(decal.to_dict())