ElEditors, Interface administrators, Administrators
70,866
edits
No edit summary |
No edit summary |
||
Line 22: | Line 22: | ||
-- Dictionary for headers | -- Dictionary for headers | ||
local prop = {'MP Usage', 'Cooldown', 'Duration', 'MP Recovery', 'Max Hits'} | local prop = { 'MP Usage', 'Cooldown', 'Duration', 'MP Recovery', 'Max Hits' } | ||
if is_rose then | if is_rose then | ||
for k, v in ipairs(prop) do | for k, v in ipairs(prop) do | ||
Line 29: | Line 29: | ||
end | end | ||
local prop_short = {'mp', 'cd', 'duration', 'mp_recovery', 'hits', 'chance'} | local prop_short = { 'mp', 'cd', 'duration', 'mp_recovery', 'hits', 'chance' } | ||
local STR = { | local STR = { | ||
Line 49: | Line 49: | ||
} | } | ||
local details = {{STR.LIGHT, STR.CRITICAL, STR.REVERSED}, | local details = { { STR.LIGHT, STR.CRITICAL, STR.REVERSED }, | ||
{ STR.HEAVY, STR.HASTE, STR.REGEN2, STR.RUTHLESS, STR.POWERFUL, STR.REVERSED }, { STR.KB1 }, | |||
{ STR.REGEN1 }, { STR.USEFUL } } | |||
-- Default values | -- Default values | ||
Line 112: | Line 112: | ||
local tr2 = new_row() | local tr2 = new_row() | ||
local tr3 = new_row() | local tr3 = new_row() | ||
local has_pvp_values = false | |||
for k, v in pairs(args) do | |||
if string.find(k, '_pvp') then | |||
has_pvp_values = true | |||
break | |||
end | |||
end | |||
local tr4 | |||
-- If pvp values exist, we need the row to place them. | |||
if has_pvp_values and not tr4 then | |||
tr4 = new_row() | |||
-- Add indicator headers | |||
tr1:tag('th'):wikitext('Mode'):attr('rowspan', 2) | |||
tr3:tag('td'):wikitext(frame:expandTemplate { | |||
title = 'PvE' | |||
}) | |||
tr4:tag('td'):wikitext(frame:expandTemplate { | |||
title = 'PvP' | |||
}) | |||
end | |||
-- Loop through 2 input traits. | -- Loop through 2 input traits. | ||
Line 133: | Line 155: | ||
-- Unnamed argument. | -- Unnamed argument. | ||
local unnamed = split(args[3 + trait_count]); | local unnamed = split(args[3 + trait_count]); | ||
local MP_ARG = args['mp' .. trait_count] or args['mp_recovery' .. trait_count] or default_value['mp_recovery'] or | local MP_ARG = args['mp' .. trait_count] or args['mp_recovery' .. trait_count] or default_value['mp_recovery'] or | ||
default_value['mp']; | |||
local ECP_ARG = nil | local ECP_ARG = nil | ||
Line 145: | Line 168: | ||
for detail_key, detail in ipairs(details) do | for detail_key, detail in ipairs(details) do | ||
if not th_skilltext then | if not th_skilltext then | ||
th_skilltext = tr3:tag('td'):wikitext(frame:expandTemplate{ | th_skilltext = tr3:tag('td'):attr('rowspan', has_pvp_values and 2 or 1):wikitext(frame:expandTemplate { | ||
title = 'SkillText', | title = 'SkillText', | ||
args = { | args = { | ||
Line 160: | Line 183: | ||
}); | }); | ||
end | end | ||
-- Fix Regen 1. | function doDetail() | ||
for _, modeSuffix in ipairs({ '', '_pvp' }) do | |||
if indexOf(trait_name, detail) then | |||
local short_detail = prop_short[detail_key] | |||
local short_detail_improved = short_detail | |||
local is_pvp = modeSuffix == '_pvp' | |||
-- Fix Regen 1. | |||
if short_detail == 'mp_recovery' then | |||
short_detail_improved = 'mp' | |||
end | |||
local detail_content = args[short_detail_improved .. trait_count] | |||
local multiplier = detail_content or default_value[short_detail_improved] or 100 | |||
local suffix = '' | |||
if short_detail_improved == 'mp' then | |||
suffix = STR.MP | |||
if is_rose then | |||
suffix = STR.ECP | |||
end | |||
elseif short_detail == 'cd' or short_detail == 'duration' then | |||
suffix = STR.SEC | |||
end | |||
local base_detail = args[short_detail_improved .. modeSuffix] | |||
local function calcEndValue(base) | |||
local end_value; | |||
if short_detail == 'hits' then | |||
end_value = base or 0 | |||
else | |||
end_value = (tonumber(multiplier) / 100) * tonumber(base or 0) | |||
end | |||
if tonumber(end_value) ~= nil and tonumber(end_value) <= 0 then | |||
end_value = '-' | |||
end | |||
return end_value .. suffix | |||
end | |||
local end_value = calcEndValue(base_detail) | |||
local enhanced_detail = args[short_detail_improved .. modeSuffix .. '_enhanced'] | |||
if enhanced_detail ~= nil then | |||
end_value = end_value .. "<br/>'''" .. frame:expandTemplate { | |||
title = 'Tt', | |||
args = { calcEndValue(enhanced_detail) .. "'''", | |||
"Final Enhanced Skill" } | |||
} | |||
end | |||
if (is_pvp and base_detail) or not is_pvp then | |||
local detail_text = end_value | |||
if end_value == '-' and args['detail' .. trait_count] then | |||
detail_text = args | |||
['detail' .. trait_count] | |||
end | |||
local detail_cell = (is_pvp and tr4 or tr3):tag('td'):wikitext(detail_text):attr('rowspan', (not args[short_detail_improved .. '_pvp']) and 2 or 1); | |||
end | |||
end | |||
end | end | ||
end | |||
doDetail() | |||
end | end | ||
end | end | ||
return tostring(trait_table); | return tostring(trait_table); | ||
end | end | ||
return p | return p | ||
-- pyend | -- pyend |