Wiki Warframe

Utilisation du Wiki

Pour une meilleure utilisation du Wiki Warframe FR, merci d'activer les scripts Javascript lors de la consultation de certains pages, pour assurer le fonctionnement de certaines fonctionnalités.
Si vous souhaitez contribuer au Wiki, rejoignez-nous sur le Discord Warframe FR (espace wiki)

- Yazu 17:00 01/10/2022

EN SAVOIR PLUS

Wiki Warframe
Advertisement

La documentation pour ce module peut être créée à Module:Weapons/compare/doc

---	Contains comparison string builders to be used on weapon articles under 
--	Characteristics sections. Invoked on [[Template:WeaponComparison]].
--	
--	@module		weapons/compare
--	@alias		p
--	@attribution		[[User:Cephalon Scientia]]
--	@attribution		[[User:Falterfire]]
--	@attribution		[[User:Flaicher]]
--	@attribution		[[User:Gigamicro]]
--	@require			[[Module:Weapons]]
--	@require			[[Module:DamageTypes]]
--	@require			[[Module:Tooltips]]
--	@require			[[Module:Table]]
--	@release			stable
--	<nowiki>

local p = {}

local Weapon = require('Module:Weapons')	-- Using p._getWeapon(), p._statRead() and p._statFormat()
local DamageType = require('Module:DamageTypes')	-- Using p.iterationOrderArray
local Tooltip = require('Module:Tooltips')	-- Using p.getFullTooltip()
local Table = require('Module:Table')	-- Using p.size()

---	Builds comparison string between two values.
--	@function		compareStr
--	@param			{table} weap1 A table used to find the comparing values
--	@param			{table} atk1 A table used to find the comparing values
--	@param			{table} weap2 A table used to find the comparing values
--	@param			{table} atk2 A table used to find the comparing values
--	@param			{string} valName Name of statistic that values represent (e.g. "Critical Damage")
--	@param			{string} var Name of statistic that values are (e.g. "CritDamage")
--	@param[opt]		{table}  compareAdjs Two element table that contains the greater than and less than comparative adjectives (e.g. {"Higher", "Lower", "Different"}) 
--	@param[opt]		{string} prefix What to start the comparison string with if you want to increase the bullet level (e.g. "***")
--	@returns		{string} Resultant wikitext of comparison string (e.g. '**Higher Critical Damage (1.2x vs. 1.1x)')
local function compareStr(weap1, atk1, weap2, atk2, valName, var, compareAdjs, prefix)
	local val1, val2 = Weapon._statRead(weap1, atk1, var), Weapon._statRead(weap2, atk2, var)
	if (val1 == val2) or (val1 ~= val1) or (val2 ~= val2) or not (val1 and val2) then
		return ''
	end

	if type(val1) == 'table' then
		local a, b = val1, val2
		val1, val2 = Table.size(val1), Table.size(val2)
		if val1 == val2 and not (function()
			for k, v in pairs(a) do
				if b[k] ~= v then
					return true
				end
			end
		end)() then
			return ''
		end
	end

	local adj = compareAdjs
	if type(compareAdjs) == 'table' or not compareAdjs then
		adj = (compareAdjs or { "+", "-", "Différence de" })[
			val1 == val2 and 3 or
			val1 > val2 and 1 or
			val1 < val2 and 2 or 0
		] or error('compareStr: vals are without compare: '..mw.dumpObject{ val1=val1, val2=val2, compareAdjs=compareAdjs, adj=adj })
		-- local bigWord, smallWord = table.unpack(compareAdjs or {"Higher","Lower"})
		-- adj = bigWord~=smallWord and adj>0 and (bigWord or "Higher") or (smallWord or "Lower")
	end

	return ('%s %s %s (%s vs. %s)'):format(prefix or '**', adj, valName, Weapon._statFormat(weap1, atk1, var), Weapon._statFormat(weap2, atk2, var))
end

---	Builds damage comparison string between two attacks.
--	@function		damageComparisonStr
--	@param			{table} Attack1 Attack used for comparison
--	@param			{table} Attack2 Attack used to compare the first attack against
--	@returns		{string} Resultant wikitext of comparison string
local function damageComparisonStr(weap1, atk1, weap2, atk2)
	local result = {}
	for _, dt in ipairs(DamageType.iterationOrderArray) do
		result[#result+1] = compareStr(weap1, atk1, weap2, atk2, "de Dégâts : "..Tooltip.full(dt, 'DamageTypes'), dt, nil, "***")
		-- local damage1 = ('%.2f'):format(Attack1.Damage[element] or 0)
		-- local damage2 = ('%.2f'):format(Attack2.Damage[element] or 0)
		-- result = result..bulidCompareString(damage1, damage2, Tooltip.full(element, 'DamageTypes').." damage", nil, nil, {"Higher", "Lower"}, "\n***")
	end
	return table.concat(result,'\n')
end

---	Builds comparison list between two weapons in PvE.
--	@function		p.buildComparison
--	@param			{table} frame Frame object
--	@returns		{string} Resultant wikitext of comparison list
function p.buildComparison(frame, getConclave)
	local weapon1Name = frame.args[1] or ''
	local weapon2Name = frame.args[2] or ''

	assert(weapon1Name ~= '' and weapon2Name ~= '', 'p.buildComparison(frame): Must compare two weapons')

	local weap1 = Weapon._getWeapon(weapon1Name, getConclave)
	local weap2 = Weapon._getWeapon(weapon2Name, getConclave)

	local atk1 = Weapon._getAttack(weap1)
	local atk2 = Weapon._getAttack(weap2)

	local result = {
		-- support method chaining w/ colon syntax
		insert = function(self, elem)
			table.insert(self, elem)
			return self
		end,
		insertcompare = function(self, ...)
			return self:insert(compareStr(weap1, atk1, weap2, atk2, ...))
		end
	}

	result:insert(("* [[%s]] (%s), comparée à l'arme [[%s]] (%s):"):format(
		weapon1Name, Weapon._statRead(weap1, atk1, 'AttackName'),
		weapon2Name, Weapon._statRead(weap2, atk2, 'AttackName'),
	nil))

	local progenitorBonusNote = (
		Weapon._statRead(weap1, atk1, 'IsLichWeapon') or
		Weapon._statRead(weap2, atk1, 'IsLichWeapon') )
	and " (utilise le bonus max de +60% des [[Liche_Kuva#Warframes_Responsables|Warframes Responsables]] si applicable)" or ""

	result
		:insert(compareStr(weap1, atk1, weap2, atk2, "dégâts de base par projectile", "BaseDamage"):gsub('^$','**Dégâts de base identiques, mais de composition différente :'))
		:insert(damageComparisonStr(weap1, atk1, weap2, atk2))
		:insertcompare("Dégâts totaux", "TotalDamage", {"Meilleurs", "Plus faibles"})
		:insertcompare("[[Chances de Critique]]", "CritChance", {"Meilleures", "Plus faibles"})
		:insertcompare("[[Multiplicateur de Critique]]", "CritMultiplier", {"Plus grand", "Plus petit"})
		:insertcompare("[[Chances de Statut]]", "StatusChance", {"Meilleures", "Plus faibles"})
		:insertcompare("[[Dégâts|Dégâts approx. par coup]]"..progenitorBonusNote, "AvgTapDmg", {"Moins de", "Plus de"})
		:insertcompare("[[Dégâts|Dégâts par /s (Rafale)]]"..progenitorBonusNote, "BurstDps", {"Moins de", "Plus de"})
		:insertcompare("[[Dégâts|Dégâts par /s (en continu)]]"..progenitorBonusNote, "SustainedDps", {"Moins de", "Plus de"})
	
	if Weapon._statRead(weap1, atk1, "IsMelee") then
		result -- melee
			:insertcompare("Portée", "MeleeRange", {"Plus grande","Plus petite"})
			:insertcompare("[[Vitesse d'Attaque]]", "FireRate", {"Meilleure", "Plus faible"})
			:insertcompare("[[Mêlée|Durée de Combo]]", "ComboDur", {"Plus grande", "Plus faible"})
			:insertcompare("Angle de Parade", "BlockAngle", {"Plus grand", "Plus petit"})
			:insertcompare("Polarité de [[Posture]]", "StancePolarity", "Différente")
	else
		result -- gun
			:insertcompare("Début de la distance de [[Diminution|Diminution des dégâts]]", "FalloffStart", {"Éloignée", "Proche"})
			:insertcompare("Distance max. de [[Diminution|Diminution des dégâts]]", "FalloffEnd", {"Éloignée", "Proche"})
			:insertcompare("Réduc. max à la fin de de la distance de Diminution", "FalloffReduction", {"Plus importante", "Plus faible"})
			:insertcompare("[[Cadence de Tir]]", "FireRate", {"Meilleure", "Plus faible"})
			:insertcompare("[[Tir Multiple]]", "Multishot")
			:insertcompare("Chargeur", "Magazine", {"Plus grand", "Plus petit"})
			:insertcompare("Capacité max. de munitions", "MaxAmmo", {"Plus grande", "Plus petite"})
			:insertcompare("[[Rechargement|Temps de Rechargement]]", "Reload", {"Plus long", "Plus court"})
			:insertcompare("Cadence progressive", "Spool", {"Plus rapide", "Plus faible"})
			:insertcompare("[[Précision|Précision]]", "Accuracy", {"Meilleure", "Plus faible"})
	end
	
	result
		:insertcompare("[[Polarité|Polarités]]", "Polarities", {"Plus de", "Moins de", "Différence de"})
		:insertcompare("[[Palier de Maîtrise]] requis", "Mastery", {"Moins de", "Plus de"})
		:insertcompare("[[Mod_Riven#Disposition|Disposition]]", "Disposition", {"Meilleure", "Plus faible"})

	local se1, se2 = weap1.SyndicateEffect, weap2.SyndicateEffect
	if se1 and not se2 then
		result:insert("\n** Effet [["..se1.."]] inné")
	elseif se2 and not se1 then
		result:insert("\n** Aucun effet [["..se2.."]] inné")
	elseif se1 and se2 and se1 ~= se2 then
		result:insert("\n** Différents [[Effet Radial de Syndicat|Effets de Syndicat]] innés ([["..se1.."]] vs. [["..se2.."]])")
	end

	-- mw.log(mw.dumpObject{['M:Weapon cache']=cache})
	return table.concat(result, '\n'):gsub('\n\n+', '\n')..'[[Catégorie:Comparaison Automatique]]'
end

---	Builds comparison list between two weapons in PvP ([[Conclave]]).
--	@function		p.buildComparison
--	@param			{table} frame Frame object
--	@returns		{string} Resultant wikitext of comparison list
function p.buildConclaveComparison(frame)
	return p.buildComparison(frame, true)
end

return p
Advertisement