-- If there is only one item, any HP above that will be set to that color.

local SPECIAL_BALL_COLORS = {
    Tank = {
        [6] = Color3.fromRGB(135, 133, 146);
    },
    Summoner = {
        [1] = Color3.fromRGB(216, 144, 144);
    }
}

local BallColors = {}

function BallColors.Get(BallObject: Part)
    local HitPoints = math.ceil(BallObject:GetAttribute("HitPoints"))
    local Type = BallObject:GetAttribute("Type")

    if (Type and SPECIAL_BALL_COLORS[Type]) then
        local SpecialColors = SPECIAL_BALL_COLORS[Type]

        if (HitPoints >= next(SpecialColors)) then
            if (next(SpecialColors, next(SpecialColors)) == nil) then
                local _, Color = next(SpecialColors)
                return Color
            else
                for Threshold, Color in pairs(SpecialColors) do
                    if (HitPoints <= Threshold) then
                        return Color
                    end
                end
            end
        end
    end

    for Threshold, Color in pairs(DEFAULT_BALL_COLORS) do
        if (HitPoints == Threshold) then
            return Color
        end
    end
end

function BallColors.Fade(Color: Color3, Hits: number)
    return Color:Lerp(Color3.new(0, 0, 0), Hits / 7.5)
end

return BallColors
