local _,ns = ...
ns.AutoScrapItemClass = {
    [0] = false, --consumable
    [1] = true,  --container (i think no market price)
    [2] = true,  --weapon
    [3] = true,  --gemas
    [4] = true,  --Armor
    [7] = { --tradeskill
        [5] = false, --cloth
        [6] = false, --leather
        [7] = false, --metal y stone
        [8] = false, --cooking
        [9] = false, --herbs
    },
    [8] = true,  --item  Enhancement
    [9] = true,  --recipe
    [12] = false, --quest
    [15] = {      --miscellaneous
        [0] = false, --junk
        [1] = false, --reagents
        [5] = false, --mount
        [6] = true, --mount equipment
    }, --miscellaneous
    [16] = false, --glyph
    [17] = false, --battlepets
    [18] = false, --wow token
}


--Return true if you can Scrap it, false otherwise
--Actually looks for a valid true or false on the table
--if nill its a item no setup in the table, so false by missing or skipped to enter all subcategories
function ns.CheckItemTypeSubtype (class,subClass)
    for key,value in pairs(ns.AutoScrapItemClass) do
        if (key==class) then
            if (type (value) == "boolean") then
                return value
            elseif (type (value) =="table")then
                for k,v in pairs (ns.AutoScrapItemClass[key]) do
                    if (k==subClass) then
                        if (type (v) == "boolean") then
                            return v
                        else
                            --return nil
                            return false
                        end
                    end
                end
            else
                --return nil
                return false
            end
        end
    end
    --return nil
    return false
end

function ns.changeItemClass(class,value)
    if class == "Consumables" then
        ns.AutoScrapItemClass[0]=value
    elseif class == "Recipes" then
        ns.AutoScrapItemClass[9]=value
    elseif class == "Cooking" then
        ns.AutoScrapItemClass[7][8]=value
    elseif class == "Leather" then
        ns.AutoScrapItemClass[7][6]=value
    elseif class == "Cloths" then
        ns.AutoScrapItemClass[7][5]=value
    elseif class == "Herbs" then
        ns.AutoScrapItemClass[7][9]=value
    elseif class == "Mining" then
        ns.AutoScrapItemClass[7][7]=value
    elseif class == "Jewelry" then
        ns.AutoScrapItemClass[7][4]=value
    elseif class == "Inscription" then
        ns.AutoScrapItemClass[7][16]=value
    end
end
