WARFRAME Wiki

Read about the future of the Fandom platform and the WARFRAME wiki! Any feedback would be appreciated! User blog:Cephalon Scientia/2022 Fandom Community Connect. - 06:11, 6 June 2022 (UTC)

READ MORE

WARFRAME Wiki
Advertisement
WARFRAME Wiki

Documentation for this module may be created at Module:Mods/infobox/doc

--	<nowiki>
local Polarity = require([[Module:Polarity]])
local Table = require([[Module:Table]])
local Tooltip = require([[Module:Tooltips]])
local DropTable = require([[Module:DropTables]])
local Vendor = require([[Module:Vendors]])
local Baro = require([[Module:Baro]])
local InfoboxBuilder = require([[Module:InfoboxBuilder]])
local Lang = mw.language.new('en')	-- Using for number formatting
local ModData = mw.loadData([[Module:Mods/data]])
local DropData = mw.loadData([[Module:DropTables/data]])

local function makeMTooltip(modTable)
	local str = {}
	for _, modIndex in ipairs(modTable) do
		table.insert(str, Tooltip.getFullTooltip(modIndex, 'Mods'))
	end
	return table.concat(str, '<br />')
end

-- For calculating Endo cost to max a mod
local RARITY_EMUM = {
	Common = 1,
	Uncommon = 2,
	Rare = 3,
	Legendary = 4,
}

-- Trading tax of mod in Credits
local TAX_MAP = {
	Common = 2000,
	Uncommon = 4000,
	Rare = 8000,
	Legendary = 1000000,
}

-- Mapping internal icon text to file links as stored on the wiki
local ICON_TEXT_MAP = {
	['<DT_IMPACT>'] = '[[File:Impact_b.png|x16px|class=dark-invert]]',
	['<DT_PUNCTURE>'] = '[[File:Puncture_b.png|x16px|class=dark-invert]]',
	['<DT_SLASH>'] = '[[File:Slash_b.png|x16px|class=dark-invert]]',
	['<DT_FIRE>'] = '[[File:Heat_b.png|x16px|class=dark-invert]]',
	['<DT_FREEZE>'] = '[[File:Cold_b.png|x16px|class=dark-invert]]',
	['<DT_ELECTRICITY>'] = '[[File:Electricity_b.png|x16px|class=dark-invert]]',
	['<DT_POISON>'] = '[[File:Toxin_b.png|x16px|class=dark-invert]]',
	['<DT_EXPLOSION>'] = '[[File:Blast_b.png|x16px|class=dark-invert]]',
	['<DT_RADIATION>'] = '[[File:Radiation_b.png|x16px|class=dark-invert]]',
	['<DT_GAS>'] = '[[File:Gas_b.png|x16px|class=dark-invert]]',
	['<DT_MAGNETIC>'] = '[[File:Magnetic_b.png|x16px|class=dark-invert]]',
	['<DT_VIRAL>'] = '[[File:Viral_b.png|x16px|class=dark-invert]]',
	['<DT_CORROSIVE>'] = '[[File:Corrosive_b.png|x16px|class=dark-invert]]',
	['<DT_RADIANT>'] = '[[File:VoidTearIcon_b.png|x16px|class=dark-invert]]',
	['<DT_SENTIENT>'] = '[[File:Tau_b.png|x16px|class=dark-invert]]',
	['<AMMO_MUTATION>'] = '[[File:AmmoMutation.png|x16px|class=dark-invert]]',
	['<LINE_SEPARATOR>'] = '<hr />',
	['<ENERGY>'] = '[[File:IconEnergy.gif|x16px]]',
	['<SHIELD>'] = '[[File:IconShield.png|x16px]]',
	['<SECONDARY_FIRE>'] = '&lt;SECONDARY_FIRE&gt;'
}

return {
buildInfobox = function(frame)
	local args = frame.args;
	local name = mw.text.decode(args['Name']);
	local modData = ModData.Mods[name];
	
	local formattedModDesc = modData.Description
	local damageTypeName = formattedModDesc:match('<[A-Z_]+>')	-- Matching strings in the form of "<DT_TYPE>"
	if (damageTypeName ~= nil) then
		formattedModDesc = formattedModDesc:gsub(damageTypeName, ICON_TEXT_MAP[damageTypeName])
		
		-- Matching a second different icon text like in the case of Rending Strike mod
		if (formattedModDesc:match('<[A-Z_]+>') ~= nil) then
			damageTypeName = formattedModDesc:match('<[A-Z_]+>')
			formattedModDesc = formattedModDesc:gsub(damageTypeName, ICON_TEXT_MAP[damageTypeName])
		end
	end
	
	local Infobox = InfoboxBuilder('MediaWiki:Custom-General/i18n.json')
		:tag('title')
			:tag('default')
				:tag('b'):wikitext(name..'[[Category:Mods]]'):done()
			:done()
		:done()
		:tag('image'):attr('source', 'Image')
			:tag('default'):wikitext(modData.Image or 'Panel.png'):done()
		:done()
		:group()
			:caption('Exilus', modData.IsExilus and '[[:Category:Exilus Mods|{{text|green|EXILUS}}]][[Category:Exilus Mods]]' or nil)
			:caption('Transmutable', modData.Transmutable and '[[Transmutation|{{text|green|Transmutable}}]][[Category:Transmutable Mods]]' or '[[Transmutation|{{text|red|Untransmutable}}]][[Category:Untransmutable Mods]]')
			:caption('Tradeable', modData.Tradable and '[[File:TradableIcon.png|x32px|class=icon dark-invert]] [[Trading|{{text|green|Tradeable}}]][[Category:Tradeable Mods]]' or '{{text|red|Untradeable}}[[Category:Untradeable Mods]]')
			:caption('CodexSecret', modData.CodexSecret and '[[Codex|%s]][[Category:Codex Secret]]' or nil, 'codex-secret')
		:done()
		
		:group():header('%s', 'max-rank-description')
			:caption('Description', formattedModDesc)
		:done()

		:group():header('%s', 'general-information')
			:row('Type', '%s', modData.Type and modData.Type..'[[Category:'..modData.Type..' Mods]]', 'type')
			:row('Polarity', '[[Polarity|%s]]', modData.Polarity and Polarity._polarity(modData.Polarity)..' '..modData.Polarity..'[[Category:'..modData.Polarity..' Mods]]', 'polarity')
			:row('Rarity', '%s', modData.Rarity and modData.Rarity..'[[Category:'..modData.Rarity..' Mods]]', 'rarity')
			:row('Class', '%s', modData.Class and modData.Class..'[[Category:'..modData.Class..' Mods]]', 'class')
			:row('Incompatible', 'Incompatible Mods', modData.Incompatible and makeMTooltip(modData.Incompatible))
			:row('MaxRank', '%s', modData.MaxRank, 'max-rank')
			:row('EndoCost', '[[Endo]] Required To Max', (modData.Rarity ~= nil and not modData.NotUpgradable) and Lang:formatNum(10 * RARITY_EMUM[modData.Rarity] * (math.pow(2, modData.MaxRank) - 1)) or nil)
			:row('CreditCost', '[[Credits]] Required To Max', (modData.Rarity ~= nil and not modData.NotUpgradable) and Lang:formatNum(483 * RARITY_EMUM[modData.Rarity] * (math.pow(2, modData.MaxRank) - 1)) or nil)
			:row('BaseDrain', 'Base Capacity Cost', modData.BaseDrain)
			:row('TradingTax', '[[Trade System|%s]]', modData.Tradable and '[[File:Credits64.png|x20px|link=Credits]]&nbsp;'..Lang:formatNum(TAX_MAP[modData.Rarity]) or nil, 'trading-tax')
			:row('Introduced', '%s', modData.Introduced and '{{ver|'..modData.Introduced..'}}[[Category:Update '..modData.Introduced:sub(1, (string.find(modData.Introduced, '%.') or 0) - 1)..']]', 'introduced')
		:done()
		--[[
		:group():header('%s', 'internal-name')
			:caption('InternalName', modData.InternalName and '<code>'..modData.InternalName..'</code>' or nil)
		:done()
		--]]
	-- Make an exception for Endo page to avoid adding source header and drop table data
	-- as there are lots of sources for Endo and it takes up lots of scroll space
	if (name ~= 'Endo') then
		local missionStr, enemyStr, containerStr = DropTable._buildDropTableSourceStrings(name)
		
		Infobox:group():header('%s', 'drop-table-sources')
			:tag('data'):attr('source', 'Drops')
				:tag('default')
					:tag('div'):addClass('tabber-borderless')
						:wikitext(('<tabber>%s%s%s</tabber>'):format(
						(missionStr ~= '') and '|-|Missions='..missionStr..'\n' or '',
						(enemyStr ~= '') and '|-|Enemies='..enemyStr..'\n' or '',
						(containerStr ~= '') and '|-|Containers='..containerStr..'\n' or ''
					)):done()
				:done()
			:done()
		:done()
	end
	
	local vendorStr = Vendor._buildVendorSourceStrings(name)
	local baroStr = Baro._buildBaroSourceStrings(name)
	
	Infobox:group():header('%s', 'vendor-sources')
		:tag('data'):attr('source', 'Offerings')
			:tag('default')
				:tag('div'):addClass('tabber-borderless')
					:wikitext(('<tabber>%s%s</tabber>'):format(
					(vendorStr ~= '') and '|-|Vendors='..vendorStr..'\n' or '',
					(baroStr ~= '') and '|-|Baro Ki\'Teer='..baroStr..'\n' or ''
				)):done()
			:done()
		:done()
	:done()
	
	return frame:preprocess(tostring(Infobox))
end
}
Advertisement