Module:Sandbox/User:Sfoxrs/luckyabsorbative: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (1 revision imported) |
(No difference)
|
Latest revision as of 21:23, 4 November 2021
Documentation for this module may be created at Module:Sandbox/User:Sfoxrs/luckyabsorbative/doc
-- <pre>
local p = {}
local perk_link = require('Module:Perk link')._main
local htnmlext = require('Module:Mw.html extension')
local yesno = require ("Module:Yesno")
local lang = mw.getContentLanguage()
function p.main(frame)
local args = frame:getParent().args
local luckyRank = tonumber(args.luckyRank) or 0
local level20lucky = yesno(args.level20lucky) or false
local absorbativeRank = tonumber(args.absorbativeRank) or 0
local level20absorbative = yesno(args.level20absorbative) or false
--calculate probabilites
local pL = 0.005*luckyRank -- 0.5% chance to proc per rank
local pA = 0.20 -- 20% chance to proc
if(level20lucky) then pL = pL*1.1 end
if(level20absorbative) then pA = pA*1.1 end
--calculate damage reduction
--calculation assumes damage taken is normally much higher than the damage reduced from a lucky proc (which is a 1)
local damageReduction = pL + 0.05*pA*absorbativeRank - 0.05*pA*absorbativeRank*pL
--table for output
local resultsDiv = mw.html.create( 'div' )
local resultsTable = mw.html.create( 'table' )
resultsTable:addClass( 'wikitable' )
:addClass( 'align-center-1 align-center-2' )
:tag( 'caption' )
:wikitext( '' )
:tag( 'tr' )
:tag( 'th' )
:wikitext( 'Perk(s)' )
:done()
:tag( 'th' )
:wikitext( 'PvM Average Damage Reduction' )
:done()
:done()
:tag( 'tr' )
:tag( 'td' )
:IF(luckyRank~=0)
:wikitext(perk_link{ 'Lucky', luckyRank, link = 'no' } )
:IF(level20lucky=="Yes")
:wikitext( string.format("[[File:Perk_increased_activation_chance.png|link=Equipment_level#Perk_benefits]]") )
:END()
:END()
:IF(absorbativeRank~=0)
:wikitext(perk_link{ 'Absorbative', absorbativeRank, link = 'no' } )
:IF(level20absorbative=="Yes")
:wikitext( string.format("[[File:Perk_increased_activation_chance.png|link=Equipment_level#Perk_benefits]]") )
:END()
:END()
:IF(luckyRank==0 and absorbativeRank==0)
:wikitext("None")
:END()
:done()
:tag( 'td' )
:wikitext(string.format("%.2f",damageReduction*100) .. "%")
:done()
:done()
:done()
--return results (table)
resultsDiv:node(tostring(resultsTable))
return resultsDiv
end
return p
-- </pre>