local GlobalAddonName, E = ...
----------------------------------------------------------------
local function Collect_All_BfA_Cloaklvl()
	local collectPlayerData = Octo_ToDo_DB_Levels[E.curGUID].PlayerData
	if not collectPlayerData then return end
	local hasItem = E.func_GetItemQuantity(169223, false, false, false, false)
	if hasItem == 0 then
		collectPlayerData.cloak_lvl = nil
		return
	end
	local itemLink = GetInventoryItemLink("player", 15)
	if itemLink and itemLink:find("item:169223:") then
		local itemLevel = select(4, E.func_GetItemData(itemLink))
		if itemLevel then
			collectPlayerData.cloak_lvl = math.min(15, math.max((itemLevel - 125) / 2 + 1, 1))
		end
		return
	end
	for bag = BACKPACK_CONTAINER, NUM_TOTAL_EQUIPPED_BAG_SLOTS do
		local numSlots = C_Container.GetContainerNumSlots(bag)
		for slot = 1, numSlots do
			local containerInfo = C_Container.GetContainerItemInfo(bag, slot)
			if containerInfo and containerInfo.itemID == 169223 then
				local itemLevel = select(4, E.func_GetItemData(containerInfo.hyperlink))
				if itemLevel then
					collectPlayerData.cloak_lvl = math.min(15, math.max((itemLevel - 125) / 2 + 1, 1))
					return
				end
			end
		end
	end
end
----------------------------------------------------------------
function E.Collect_All_BfA_Cloaklvl()
	E.func_SpamBlock(Collect_All_BfA_Cloaklvl, true)
end