Wowpedia
Advertisement

local data = {
	a = {
		retail = mw.loadData("Module:API_info/patch/api_retail"),
		classic = mw.loadData("Module:API_info/patch/api_classic"),
	},
	e = {
		retail = mw.loadData("Module:API_info/patch/event_retail"),
		classic = mw.loadData("Module:API_info/patch/event_classic"),
	}
}

local m = {}

local function GetLink(patch)
	return string.format("[[Patch_%s/API_changes|%s]]", patch, patch)
end

function m:GetPatches(apiType, name)
	local addedTbl, removedTbl = {}, {}
	local patch = {
		retail = data[apiType].retail[name],
		classic = data[apiType].classic[name],
	}
	if patch.retail then
		if patch.retail[1] then
			table.insert(addedTbl, GetLink(patch.retail[1]))
		end
		if patch.retail[2] then
			table.insert(removedTbl, GetLink(patch.retail[2]))
		end
	end
	if patch.classic then
		if patch.classic[1] then
			table.insert(addedTbl, GetLink(patch.classic[1]))
		end
		if patch.classic[2] then
			table.insert(removedTbl, GetLink(patch.classic[2]))
		end
	end
	local addedStr = table.concat(addedTbl, " / ")
	local removedStr = table.concat(removedTbl, " / ")
	return addedStr, removedStr
end

return m
Advertisement