ElEditors, Interface administrators, Administrators
70,975
edits
No edit summary |
No edit summary |
||
(36 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
-- pystart | -- pystart | ||
require('Module:CommonFunctions') | require('Module:CommonFunctions') | ||
local i18n = require('Module:I18n') | |||
local getArgs = require('Module:Arguments').getArgs | local getArgs = require('Module:Arguments').getArgs | ||
local inspect = require('Module:Inspect').inspect | local inspect = require('Module:Inspect').inspect | ||
local getTranslations = i18n.getTranslations | |||
local p = {} | local p = {} | ||
Line 8: | Line 10: | ||
function p.main(frame) | function p.main(frame) | ||
local args = getArgs(frame) | local args = getArgs(frame) | ||
local tr = getTranslations(frame, 'Template:Damage', args.lang, true) | |||
local out | local out | ||
function translate(key) | |||
return i18n.translate(tr, key) | |||
end | |||
function inArgs(key) | function inArgs(key) | ||
Line 51: | Line 58: | ||
do_table = args[1] == 'true', | do_table = args[1] == 'true', | ||
character = args[2] or args.char or 'Elsword', | character = args[2] or args.char or 'Elsword', | ||
lang_suffix = args.lang and ('/' .. args.lang) or '', | |||
lang_append = args.lang ~= nil and args.lang ~= '', | |||
format = args.format ~= 'false', | format = args.format ~= 'false', | ||
no_max = args.no_max == 'true', | no_max = args.no_max == 'true', | ||
Line 91: | Line 100: | ||
{ | { | ||
key = '', | key = '', | ||
name = 'Normal', | name = translate('Normal'), | ||
value = 1 | value = 1 | ||
}, | }, | ||
{ | { | ||
key = 'enhanced', | key = 'enhanced', | ||
name = 'Enhanced (Trait)', | name = translate('Enhanced (Trait)'), | ||
value = args.enhanced ~= nil and 0.8 | value = args.enhanced ~= nil and 0.8 | ||
}, | }, | ||
{ | { | ||
key = 'empowered', | key = 'empowered', | ||
name = 'Empowered', | name = translate('Empowered'), | ||
value = args.empowered == 'true' and 1.2 or tonumber(args.empowered) or false | value = args.empowered == 'true' and 1.2 or tonumber(args.empowered) or false | ||
}, | }, | ||
{ | { | ||
key = 'useful', | key = 'useful', | ||
name = 'Useful', | name = translate('Useful'), | ||
value = (args.hits_useful or args.avg_hits_useful) and (args.useful_penalty or args.useful or 0.8) or false | value = (args.hits_useful or args.avg_hits_useful) and (args.useful_penalty or args.useful or 0.8) or false | ||
}, | }, | ||
{ | { | ||
key = 'heavy', | key = 'heavy', | ||
name = 'Heavy', | name = translate('Heavy'), | ||
value = args.heavy ~= nil and 1.44 | value = args.heavy ~= nil and 1.44 | ||
} | } | ||
Line 132: | Line 141: | ||
--]] | --]] | ||
local passive_name = v | local passive_name = v | ||
local passive_title = v .. OPTIONS.lang_suffix | |||
local is_custom = string.find(k, '_define') ~= nil | local is_custom = string.find(k, '_define') ~= nil | ||
local passive_index = string.match(k, "%d") | local passive_index = string.match(k, "%d") | ||
local passive_values = split(is_custom and v or | local passive_values = split(is_custom and v or | ||
frame:preprocess('{{:' .. passive_name .. '}}{{#arrayprint:' .. passive_name .. '}}')); | frame:preprocess('{{:' .. passive_name .. '}}{{#arrayprint:' .. passive_name .. '}}')); | ||
local display_title | |||
if is_custom then | if is_custom then | ||
passive_name = passive_values[#passive_values] | passive_name = passive_values[#passive_values] | ||
passive_values[#passive_values] = nil | passive_values[#passive_values] = nil | ||
elseif OPTIONS.lang_append then | |||
--[[ | |||
Translate page's display title to passive name. | |||
Customized will override this name, thus no need to perform the translation | |||
--]] | |||
display_title = i18n.getTranslatedTitle(passive_title) | |||
end | end | ||
Line 146: | Line 163: | ||
value = passive_values[1], | value = passive_values[1], | ||
value_pvp = passive_values[2], | value_pvp = passive_values[2], | ||
alias = args['alias' .. passive_index] or (passive_index == OPTIONS.append_index and OPTIONS.append_name), | alias = args['alias' .. passive_index] or (passive_index == OPTIONS.append_index and OPTIONS.append_name) or display_title, | ||
suffix = args['suffix' .. passive_index] and (' ' .. args['suffix' .. passive_index]) or '', | suffix = args['suffix' .. passive_index] and (' ' .. args['suffix' .. passive_index]) or '', | ||
prefix = args['prefix' .. passive_index] and (args['prefix' .. passive_index] .. ' ') or '', | prefix = args['prefix' .. passive_index] and (args['prefix' .. passive_index] .. ' ') or '', | ||
exist = frame:preprocess('{{#ifexist:' .. passive_name .. '|true|false}}') == 'true' | exist = frame:preprocess('{{#ifexist:' .. passive_name .. '|true|false}}') == 'true' | ||
} | } | ||
elseif | elseif string.match(v, '^[()+%-*/%d%s,.i]+$') then | ||
--[[ | --[[ | ||
Change how args are received. | Change how args are received. | ||
Line 405: | Line 422: | ||
hit_count = hit_count == '' and 1 or hit_count | hit_count = hit_count == '' and 1 or hit_count | ||
new_value.hit_counts[damage_type][k] = hit_count * | new_value.hit_counts[damage_type][k] = hit_count * | ||
((string.find(damage_key, ' | ((string.find(damage_key, 'awk') and args.awk_count) and args.awk_count[1] or args.count[1]) | ||
end | end | ||
end) | end) | ||
Line 542: | Line 559: | ||
local RANGE = { | local RANGE = { | ||
min_count = args.range_min_count and args.range_min_count[1] | min_count = args.range_min_count and args.range_min_count[1], | ||
max_count = args.range_max_count and args.range_max_count[1] | max_count = args.range_max_count and args.range_max_count[1], | ||
PvE = { | PvE = { | ||
min = args.range_min and args.range_min[1] | min = args.range_min and args.range_min[1], | ||
max = args.range_max and args.range_max[1] | max = args.range_max and args.range_max[1] | ||
}, | }, | ||
PvP = { | PvP = { | ||
min = args.range_min and (args.range_min[2] or args.range_min[1]) | min = args.range_min and (args.range_min[2] or args.range_min[1]), | ||
max = args.range_max and (args.range_max[2] or args.range_max[1]) | max = args.range_max and (args.range_max[2] or args.range_max[1]) | ||
} | } | ||
} | } | ||
Line 561: | Line 578: | ||
WITH_RANGE[mode][damage_key] = { min = 0, max = 0 } | WITH_RANGE[mode][damage_key] = { min = 0, max = 0 } | ||
forEachDamageType(function(damage_type) | forEachDamageType(function(damage_type) | ||
local range_count = RANGE[damage_type .. '_count']; | local range_count = RANGE[damage_type .. '_count'] or 1; | ||
local range_multiplier = RANGE[mode][damage_type]; | -- If min count preset, use range_max for the multiplier. | ||
local range_multiplier = RANGE[mode][damage_type] or (damage_type == 'min' and RANGE.min_count and RANGE[mode].max) or 1; | |||
local final_range_multiplier = (1 + ((range_multiplier - 1) * range_count)); | local final_range_multiplier = (1 + ((range_multiplier - 1) * range_count)); | ||
local perm_buff = OPTIONS.perm_buff[mode]; | local perm_buff = OPTIONS.perm_buff[mode]; | ||
Line 635: | Line 653: | ||
{ | { | ||
type = 'extra', | type = 'extra', | ||
text = { 'Average' }, | text = { translate('Average') }, | ||
is_visible = OPTIONS.no_max, | is_visible = OPTIONS.no_max, | ||
no_damage = true | no_damage = true | ||
Line 642: | Line 660: | ||
type = 'passives', | type = 'passives', | ||
text = checkPassives({ | text = checkPassives({ | ||
output = { 'Base' }, | output = { translate('Base') }, | ||
action = function(passive, output) | action = function(passive, output) | ||
if passive.is_combined then | if passive.is_combined then | ||
Line 674: | Line 692: | ||
type = 'passive_appended', | type = 'passive_appended', | ||
text = { | text = { | ||
'Normal', | translate('Normal'), | ||
OPTIONS.is_append and | OPTIONS.is_append and | ||
link(PASSIVES[OPTIONS.append_index].name, | link(PASSIVES[OPTIONS.append_index].name, | ||
Line 688: | Line 706: | ||
{ | { | ||
type = 'awakening', | type = 'awakening', | ||
text = { 'Regular', (function() | text = { translate('Regular'), (function() | ||
if OPTIONS.dmp then | if OPTIONS.dmp then | ||
return link('Dynamo Point System', 'Dynamo Configuration', | return link('Dynamo Point System' .. OPTIONS.lang_suffix, 'Dynamo Configuration', args.awk_prefix, | ||
OPTIONS.dmp ~= 'false' and (fillTemplate('({1} DMP)', { OPTIONS.dmp })) .. (args.awk_suffix and (' ' .. args.awk_suffix) or '')) | |||
elseif args.awk_alias then | elseif args.awk_alias then | ||
return link | return link(args.awk_alias[1], args.awk_alias[2], args.awk_prefix, args.awk_suffix) | ||
end | end | ||
return link('Awakening Mode') | return link('Awakening Mode' .. OPTIONS.lang_suffix, translate('Awakening Mode'), args.awk_prefix, args.awk_suffix) | ||
end)() | end)() | ||
}, | }, | ||
Line 705: | Line 723: | ||
type = 'traits', | type = 'traits', | ||
text = checkTraits({ | text = checkTraits({ | ||
output = { 'Normal' }, | output = { translate('Normal') }, | ||
action = function(trait, output) | action = function(trait, output) | ||
table.insert(output, trait.name) | table.insert(output, trait.name) | ||
Line 720: | Line 738: | ||
type = 'cancel', | type = 'cancel', | ||
text = { | text = { | ||
'Cancel', 'Full' | translate('Cancel'), | ||
translate('Full'), | |||
}, | }, | ||
keywords = { 'cancel' }, | keywords = { 'cancel' }, | ||
Line 730: | Line 749: | ||
text = { | text = { | ||
(inArgs('count') and not OPTIONS.use_avg) and | (inArgs('count') and not OPTIONS.use_avg) and | ||
( | (fillTemplate(translate('Per {1}'), { args.count_name or translate('Group') })) or | ||
'Max' | translate('Average'), | ||
translate('Max') | |||
}, | }, | ||
keywords = (function() | keywords = (function() | ||
Line 813: | Line 833: | ||
function doInitialCell(new_row) | function doInitialCell(new_row) | ||
return new_row:tag('th'):wikitext('Mode') | return new_row:tag('th'):wikitext(translate('Mode')) | ||
end | end | ||
Line 872: | Line 892: | ||
function doContentByMode(mode) | function doContentByMode(mode) | ||
local mode_row = TABLE:new() | local mode_row = TABLE:new() | ||
mode_row:tag('td'):wikitext(frame:expandTemplate { title = mode }) | mode_row:tag('td'):wikitext(frame:expandTemplate { title = translate(mode) }) | ||
local damage_entries = returnDamageInOrder() | local damage_entries = returnDamageInOrder() | ||
local last_number | local last_number | ||
Line 922: | Line 942: | ||
if OPTIONS.bug then | if OPTIONS.bug then | ||
bug = frame:expandTemplate { | bug = frame:expandTemplate { | ||
title = 'SkillText', | title = translate('SkillText'), | ||
args = { 'FreeTraining' } | args = { 'FreeTraining' } | ||
} | } |