local _G = _G
local type = _G.type
local tonumber = _G.tonumber
local tinsert = _G.table.insert

local sets, set, piece, maxPiece
local setPiece, setMaxPiece = {}, {}

InvenSimulatorUI.setList = {}

function InvenSimulatorUI:SaveSetInfo()
	for p in pairs(setPiece) do
		setPiece[p] = nil
		setMaxPiece[p] = nil
	end
	for p in pairs(self.setList) do
		self.setList[p] = nil
	end
	if type(self.set) == "string" then
		sets = { ("/"):split(self.set) }
		for _, s in ipairs(sets) do
			set, piece, maxPiece = s:match("(.+)_(%d+)_(%d+)")
			if set then
				tinsert(self.setList, set)
				setPiece[set] = tonumber(piece)
				setMaxPiece[set] = tonumber(maxPiece)
			end
		end
		sort(self.setList)
	end
end

function InvenSimulatorUI:GetSetItemPiece(setName)
	return setPiece[setName] or 0, setMaxPiece[setName] or 0
end