Warframe Wiki
Advertisement

Die Dokumentation für dieses Modul kann unter Modul:VoidByReward/Doku erstellt werden

-- WARFRAME Wiki Sorted Void Drop Table By Rewards 
-- http://warframe.wikia.com/
-- Originally written by User:NoBrainz
-- Heavily modified by User:Falterfire <-- The person to message if something goes wrong
-- Modified by User:Magiczocker01 on 2021-08-05

-- Pulls from Module:Void/data
-- Data in Void:data is structure as
-- local tierCol = 1 -- [1] = Tier (ex "Lith")
-- local nameCol = 2 -- [2] = Name (ex "A1 Common*") (* means vaulted)
-- local itemCol = 3 -- [3] = Item (ex "VASTO")
-- local partCol = 4 -- [4] = Part (ex "RECEIVER")

local p = {}

local VoidData = mw.loadData( 'Module:Void/data' )
local script = require( "Module:Icon" )
local Shared = require( "Module:Shared" )

-- Converts item names in data to proper names
-- So for example 'LATRON' becomes 'Latron Prime'
function p.getItemName(itemStr)
	local caseItem = string.gsub(itemStr, "(%a)([%w_']*)", Shared.titleCase)
	if itemStr ~= "FORMA" then
		caseItem = caseItem .. " Prime"
	end
	return caseItem
end

-- Converts part names in data to proper casing
function p.getPartName(partStr)
    return string.gsub(partStr, "(%a)([%w_']*)", Shared.titleCase)
end

function p.byReward(frame)
	local data = {}

	-- collect data
	for _, relic in pairs(VoidData.Relics) do
		for _, drop in pairs(relic.Drops) do
			local newObj = {Tier = relic.Tier, Name = relic.Name, Rarity = drop.Rarity, IsVaulted = relic.IsVaulted == 1}
			data[drop.Item] = data[drop.Item] or {}
			data[drop.Item][drop.Part] = data[drop.Item][drop.Part] or {}
			table.insert(data[drop.Item][drop.Part], newObj)
		end
	end

	local fullStr = {"{|class=\"bigmodtable\" style=\"line-height:13px;\""}
	for item, parts in Shared.skpairs(data) do
		fullStr[#fullStr + 1] = "\n|-\n"
		fullStr[#fullStr + 1] = "|rowspan=\"" .. Shared.tableCount(parts) .. "\"|"
		local image = script._Prime(item, nil, "200x100")
		fullStr[#fullStr + 1] = image .. "<br/>"
		
		local itemName = p.getItemName(item)
		fullStr[#fullStr + 1] = "[[" .. itemName .. "]]"
		
		local firstRow = true
		for part, drops in Shared.skpairs(parts) do
			if firstRow then
				firstRow = false
			else
			   fullStr[#fullStr + 1] = "\n|-"
			end
			fullStr[#fullStr + 1] = "\n|" .. script.Deutsch(p.getPartName(part)) .. "\n|"
			for i, drop in pairs(drops) do
				if i > 1 then
					fullStr[#fullStr + 1] = "<br/>"
				end
				fullStr[#fullStr + 1] = drop.Tier .. " " .. drop.Name .. " " .. drop.Rarity
				if drop.IsVaulted then
					fullStr[#fullStr + 1] = " ([[Prime Vault|V]])"
				end
			end
		end
	end

	fullStr[#fullStr + 1] = "\n|}"
	
	return table.concat(fullStr, "")
end


--New function written by User:Falterfire
--For Void Relics/ByRewards/SimpleTable
function p.simpleRewardTable(frame)
	local data = {}

	--Collect data for each relic
	for _, relic in pairs(VoidData.Relics) do
		local vault = "Nein"
		if relic.IsVaulted == 1 then
			vault = "Ja"
		end
		
		--For each relic, need each drop
		for _, drop in pairs(relic.Drops) do
			--Custom objects are great
			local thisObj = {Item = drop.Item, Part = script.Deutsch(drop.Part), Tier = relic.Tier,
			Name = relic.Name, Rarity = script.Deutsch(drop.Rarity), IsVaulted = vault}
			table.insert(data, thisObj)
		end
	end

	local function sorter(r1, r2)
		if r1.Item == r2.Item then
			if r1.Part == r2.Part then
				return r1.IsVaulted < r2.IsVaulted
			else
				return r1.Part < r2.Part
			end
		else
			return r1.Item < r2.Item
		end
	end
	
	table.sort(data, sorter)

	-- Just manually sending back all table data
	-- Because this is easier than trying to format just rows
	local strTable = {
		"{| class=\"article-table sortable\"",
		"\n|-",
		"\n! scope=\"col\"|Objekt",
		"\n! scope=\"col\"|Teil",
		"\n! scope=\"col\"|Tier",
		"\n! scope=\"col\"|Name",
		"\n! scope=\"col\"|Seltenheit",
		"\n! scope=\"col\"|Vault?"
	}
	
	for _, Row in pairs(data) do
		local rowStr = "\n|- \n|"
		local ItemName = "[[" .. p.getItemName(Row.Item) .. "]]"
		local PartName = script.Deutsch(p.getPartName(Row.Part))
		rowStr = rowStr .. ItemName .. "||" .. PartName .. "||" .. Row.Tier .. "||" .. Row.Name
		rowStr = rowStr .. "||" .. Row.Rarity .. "||" .. Row.IsVaulted
		strTable[#strTable + 1] = rowStr
	end
	--Add final closing bracket and send it back
	strTable[#strTable + 1] = "\n|}"
	return table.concat(strTable, "")
end

function p.vaultedRelicsTable(frame)
	--Function by User:Falterfire
	--Finds all currently vaulted relics and auto-generates a table

	--Just hardcoding in the four types
	--Fine as long as somebody knows how to fix this if DE introduces 5th rarity
	local data = {["Lith"] = {}, ["Meso"] = {}, ["Neo"] = {}, ["Axi"] = {}}

	-- collect data
	for _, relic in pairs(VoidData.Relics) do
		if relic.IsVaulted == 1 then
			table.insert(data[relic.Tier], relic)
		end
	end

	--Setting up the table properly
	local tableStr = {
		"{| class=\"article-table\"",
		"\n! scope=\"col\" style=\"width:25%;\" | Lith",
		"\n! scope=\"col\" style=\"width:25%;\" | Meso",
		"\n! scope=\"col\" style=\"width:25%;\" | Neo",
		"\n! scope=\"col\" style=\"width:25%;\" | Axi",
		"\n|-"
	}
	
	--Loop through each tier
	--And add all the relics for each one
	for tier in Shared.relicLoop() do
		tableStr[#tableStr + 1] = "\n|"
		for _, relic in pairs(data[tier]) do
			tableStr[#tableStr + 1] = "\n*" .. relic.Tier .. " " .. relic.Name
		end
	end

	--then just close out the table
	tableStr[#tableStr + 1] = "\n|}"

	--and send it back
	return table.concat(tableStr, "")
end

function p.byRelic(frame)
	--Added by User:Falterfire

	--First, setting up the table columns.
	local tableStr = {
		"{| class=\"article-table sortable\"",
		"\n! Tier",
		"\n! Typ",
		"\n! Gewöhnliche Belohnung",
		"\n! Ungewöhnliche Belohnung",
		"\n! Seltene Belohnung"
	}

	--Now the fun part: Building each table row
	for _, relic in pairs(VoidData.Relics) do
		--First, new row indicator
		tableStr[#tableStr + 1] = "\n|-"
		--Tier & Relic are easy
		tableStr[#tableStr + 1] = "\n| " .. relic.Tier
		tableStr[#tableStr + 1] = "\n| " .. relic.Name
	
		local commonStr = "\n| "
		local uncommonStr = "\n| "
		local rareStr = "\n| "
		for _, drop in pairs(relic.Drops) do
			local itemName = p.getItemName(drop.Item)
			local partName = script.Deutsch(p.getPartName(drop.Part))
			if drop.Rarity == "Common" then
				commonStr = commonStr .. "\n* [[" .. itemName .. "|" .. itemName .. " " .. partName .. "]]"
			elseif drop.Rarity == "Uncommon" then
				uncommonStr = uncommonStr .. "\n* [[" .. itemName .. "|" .. itemName .. " " .. partName .. "]]"
			else
				rareStr = rareStr .. "\n* [[" .. itemName .. "|" .. itemName .. " " .. partName .. "]]"
			end
		end
		
		tableStr[#tableStr + 1] = commonStr .. uncommonStr .. rareStr
	end
	--Close out the table
	tableStr[#tableStr + 1] = "\n|}"

	--And send it back
	return table.concat(tableStr, "")
end

function p.byRarity(frame)
	--Added by User:Falterfire
	--Twoooo Grakata. Or arguments. Whichever.
	local checkTier = frame.args and frame.args[2] or "Lith"

	local data = {["Common"] = {}, ["Uncommon"] = {}, ["Rare"] = {}}

	-- collect data
	for _, relic in pairs(VoidData.Relics) do
		--So first make sure this row is the right tier
		if relic.Tier == checkTier then
			for _, drop in pairs(relic.Drops) do
				local rarity = drop.Rarity
				local name = drop.Item .. "|" .. drop.Part
				if not data[rarity][name] then
					data[rarity][name] = 1
				end
			end
		end
	end

	--Now we can actually format the table
	--Starting with all the column headers
	local tableStr = {
		"{| class=\"article-table\"",
		"\n! style=\"width:33%;text-align:center;\" | Gewöhnlich",
		"\n! style=\"width:33%;text-align:center;\" | Ungewöhnlich",
		"\n! style=\"width:33%;text-align:center;\" | Selten"
	}
	--Then go through each rarity
	tableStr[#tableStr + 1] = "\n|-\n|"
	--Each rarity is the same steps:
	--1. Loop through each item in that rarity
	for itemStr in Shared.skpairs(data.Common) do
		--2. Get the item & part
		local sp1 = string.find(itemStr, "|")
		local itemName = p.getItemName(string.sub(itemStr, 1, sp1 - 1))
		local partName = script.Deutsch(p.getPartName(string.sub(itemStr, sp1 + 1)))
		--3. Add the appropriate link to the table
		tableStr[#tableStr + 1] = "\n* [[" .. itemName .. "|" .. itemName .. " " .. partName .. "]]"
	end
	tableStr[#tableStr + 1] = "\n|"
	for itemStr in Shared.skpairs(data.Uncommon) do
		local sp1 = string.find(itemStr, "|")
		local itemName = p.getItemName(string.sub(itemStr, 1, sp1 - 1))
		local partName = script.Deutsch(p.getPartName(string.sub(itemStr, sp1 + 1)))
		tableStr[#tableStr + 1] = "\n* [[" .. itemName .. "|" .. itemName .. " " .. partName .. "]]"
	end
	tableStr[#tableStr + 1] = "\n|"
	for itemStr in Shared.skpairs(data.Rare) do
		local sp1 = string.find(itemStr, "|")
		local itemName = p.getItemName(string.sub(itemStr, 1, sp1 - 1))
		local partName = script.Deutsch(p.getPartName(string.sub(itemStr, sp1 + 1)))
		tableStr[#tableStr + 1] = "\n* [[" .. itemName .. "|" .. itemName .. " " .. partName .. "]]"
	end
	
	--Finally, add the end of the table
	tableStr[#tableStr + 1] = "\n|}"

	--and send it back
	return table.concat(tableStr, "") --, debugStr
end

return p
Advertisement