Module:Events
Jump to navigation
Jump to search
Documentation for this module may be created at Module:Events/doc
-- This module implements [[Template:Events]].
local data = mw.loadData('Module:Events/data')
local p = {}
function p.globallist(frame)
local year = frame.args['year'] or frame.args[1]
keys = {}
for k in pairs(data) do
if data[k].type == "global"
and string.sub(k,1,4) == year then
table.insert(keys, k)
end
end
table.sort(keys, function(a, b) return a > b end)
result = ""
--hero table
result = result .. '{| class="wikitable" width="100%"\n'
result = result .. '!style="border-bottom: 1px solid;"|Date\n'
result = result .. '!style="border-bottom: 1px solid;"|Event\n'
result = result .. '!style="border-bottom: 1px solid;"|Theme\n'
result = result .. '!style="border-bottom: 1px solid;"|Hero Rarity\n'
result = result .. '!style="border-bottom: 1px solid;"|Hero 1\n'
result = result .. '!style="border-bottom: 1px solid;"|Hero 2\n'
result = result .. '!style="border-bottom: 1px solid;"|Hero 3\n'
for k, t in ipairs(keys) do
result = result .. '|-\n'
result = result .. '|rowspan="3" style="border-bottom: 1px solid;"|\'\'\'' .. data[t].date .. '\'\'\'\n'
if data[t].name == '?' then
result = result .. '|rowspan="3" style="border-bottom: 1px solid;"|\'\'\'' .. data[t].name .. '\'\'\'\n'
else
result = result .. '|rowspan="3" style="border-bottom: 1px solid;"|\'\'\'[[' .. data[t].name .. ']]\'\'\'\n'
end
result = result .. '|rowspan="3" style="border-bottom: 1px solid;"|' .. mw.getCurrentFrame():expandTemplate{title='Icon', args = { data[t].theme, link='yes', linebreak = 'yes', align = 'center'}} .. '\n'
result = result .. '|<span style="color:#FFD700">' .. mw.getCurrentFrame():expandTemplate{title='Icon', args = { 'legendary', link='yes', color = '#FFD700', linebreak = 'yes', align = 'center' }} .. '</span>\n'
if string.sub(data[t].legendaryhero1,1,1) == '*' then
result = result .. '|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { string.sub(data[t].legendaryhero1,2) }} .. ' (new)'
else
result = result .. '|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { data[t].legendaryhero1 }}
end
result = result .. '\n'
if string.sub(data[t].legendaryhero2,1,1) == '*' then
result = result .. '|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { string.sub(data[t].legendaryhero2,2) }} .. ' (new)'
else
result = result .. '|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { data[t].legendaryhero2 }}
end
result = result .. '\n'
if string.sub(data[t].legendaryhero3,1,1) == '*' then
result = result .. '|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { string.sub(data[t].legendaryhero3,2) }} .. ' (new)'
else
result = result .. '|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { data[t].legendaryhero3 }}
end
result = result .. '\n'
result = result .. '|-\n'
result = result .. '|<span style="color:#C938DF">' .. mw.getCurrentFrame():expandTemplate{title='Icon', args = { 'epic', link='yes', color = '#C938DF', linebreak = 'yes', align = 'center' }} .. '</span>\n'
if string.sub(data[t].epichero1,1,1) == '*' then
result = result .. '|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { string.sub(data[t].epichero1,2) }} .. ' (new)'
else
result = result .. '|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { data[t].epichero1 }}
end
result = result .. '\n'
if string.sub(data[t].epichero2,1,1) == '*' then
result = result .. '|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { string.sub(data[t].epichero2,2) }} .. ' (new)'
else
result = result .. '|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { data[t].epichero2 }}
end
result = result .. '\n'
if string.sub(data[t].epichero3,1,1) == '*' then
result = result .. '|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { string.sub(data[t].epichero3,2) }} .. ' (new)'
else
result = result .. '|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { data[t].epichero3 }}
end
result = result .. '\n'
result = result .. '|-\n'
result = result .. '|style="border-bottom: 1px solid;"|<span style="color:#49BEE9">' .. mw.getCurrentFrame():expandTemplate{title='Icon', args = { 'rare', link='yes', color = '#49BEE9', linebreak = 'yes', align = 'center' }} .. '</span>\n'
if string.sub(data[t].rarehero1,1,1) == '*' then
result = result .. '|style="border-bottom: 1px solid;"|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { string.sub(data[t].rarehero1,2) }} .. ' (new)'
else
result = result .. '|style="border-bottom: 1px solid;"|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { data[t].rarehero1 }}
end
result = result .. '\n'
if string.sub(data[t].rarehero2,1,1) == '*' then
result = result .. '|style="border-bottom: 1px solid;"|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { string.sub(data[t].rarehero2,2) }} .. ' (new)'
else
result = result .. '|style="border-bottom: 1px solid;"|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { data[t].rarehero2 }}
end
result = result .. '\n'
if string.sub(data[t].rarehero3,1,1) == '*' then
result = result .. '|style="border-bottom: 1px solid;"|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { string.sub(data[t].rarehero3,2) }} .. ' (new)'
else
result = result .. '|style="border-bottom: 1px solid;"|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { data[t].rarehero3 }}
end
result = result .. '\n'
end
result = result .. "|}"
return result
end
function p.mclist(frame)
local year = frame.args['year'] or frame.args[1]
keys = {}
for k in pairs(data) do
if data[k].type == "call"
and string.sub(k,1,4) == year then
table.insert(keys, k)
end
end
table.sort(keys, function(a, b) return a > b end)
result = ""
--hero table
result = result .. '{| class="wikitable" width="100%"\n'
result = result .. '!style="border-bottom: 1px solid;"|Date\n'
result = result .. '!style="border-bottom: 1px solid;"|Event\n'
result = result .. '!style="border-bottom: 1px solid;"|' .. mw.getCurrentFrame():expandTemplate{title='Icon', args = { 'legendary', link='yes'}} .. ' Hero\n'
result = result .. '!style="border-bottom: 1px solid;"|' .. mw.getCurrentFrame():expandTemplate{title='Icon', args = { 'epic', link='yes'}} .. ' Hero\n'
result = result .. '!style="border-bottom: 1px solid;"|' .. mw.getCurrentFrame():expandTemplate{title='Icon', args = { 'rare', link='yes'}} .. ' Hero\n'
for k, t in ipairs(keys) do
result = result .. '|-\n'
result = result .. '|style="border-bottom: 1px solid;"|\'\'\'' .. data[t].date .. '\'\'\'\n'
result = result .. '|style="border-bottom: 1px solid;"|\'\'\'[[' .. data[t].name .. ']]\'\'\'\n'
result = result .. '|style="border-bottom: 1px solid;"|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { data[t].legendaryhero1 }} .. '\n'
result = result .. '|style="border-bottom: 1px solid;"|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { data[t].epichero1 }} .. '\n'
result = result .. '|style="border-bottom: 1px solid;"|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { data[t].rarehero1 }} .. '\n'
end
result = result .. "|}"
return result
end
function p.eventlist(frame)
local display = frame.args['display'] or frame.args[1]
local count = 0;
keys = {}
for k in pairs(data) do
table.insert(keys, k)
end
table.sort(keys, function(a, b) return a > b end)
result = ""
--hero table
result = result .. '{| class="wikitable" width="100%"\n'
result = result .. '!style="border-bottom: 1px solid;"|Date\n'
result = result .. '!style="border-bottom: 1px solid;"|Event\n'
result = result .. '!style="border-bottom: 1px solid;"|' .. mw.getCurrentFrame():expandTemplate{title='Icon', args = { 'legendary', link='yes'}} .. ' Hero\n'
result = result .. '!style="border-bottom: 1px solid;"|' .. mw.getCurrentFrame():expandTemplate{title='Icon', args = { 'epic', link='yes'}} .. ' Hero\n'
result = result .. '!style="border-bottom: 1px solid;"|' .. mw.getCurrentFrame():expandTemplate{title='Icon', args = { 'rare', link='yes'}} .. ' Hero\n'
for k, t in ipairs(keys) do
if count < tonumber(display) then
if data[t].type == "chosen" then
result = result .. '|-\n'
result = result .. '|style="border-bottom: 1px solid;"|\'\'\'' .. data[t].date .. '\'\'\'\n'
result = result .. '|style="border-bottom: 1px solid;"|\'\'\'[[Chosen Hero Events|Chosen Hero Event]]\'\'\'\n'
result = result .. '|colspan="3" style="border-bottom: 1px solid;"|'
result = result .. mw.getCurrentFrame():expandTemplate{title='Icon', args = { data[t].theme, link='yes' }} .. '<br/>'
result = result .. mw.getCurrentFrame():expandTemplate{title='Icon', args = { data[t].class, link='yes' }} .. '\n'
else
if data[t].type == "animus" then
result = result .. '|-\n'
result = result .. '|style="border-bottom: 1px solid;"|\'\'\'' .. data[t].date .. '\'\'\'\n'
result = result .. '|colspan="4" style="border-bottom: 1px solid;"|\'\'\'[[' .. data[t].name .. ']]\'\'\'\n'
else if data[t].type == "global" then
result = result .. '|-\n'
result = result .. '|rowspan="3" style="border-bottom: 1px solid;"|\'\'\'' .. data[t].date .. '\'\'\'\n'
if data[t].name == '?' then
result = result .. '|rowspan="3" style="border-bottom: 1px solid;"|\'\'\'' .. data[t].name .. '\'\'\'\n'
else
result = result .. '|rowspan="3" style="border-bottom: 1px solid;"|\'\'\'[[' .. data[t].name .. ']]\'\'\'\n'
end
if string.sub(data[t].legendaryhero1,1,1) == '*' then
result = result .. '|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { string.sub(data[t].legendaryhero1,2) }} .. ' (new)'
else
result = result .. '|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { data[t].legendaryhero1 }}
end
result = result .. '\n'
if string.sub(data[t].epichero1,1,1) == '*' then
result = result .. '|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { string.sub(data[t].epichero1,2) }} .. ' (new)'
else
result = result .. '|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { data[t].epichero1 }}
end
result = result .. '\n'
if string.sub(data[t].rarehero1,1,1) == '*' then
result = result .. '|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { string.sub(data[t].rarehero1,2) }} .. ' (new)'
else
result = result .. '|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { data[t].rarehero1 }}
end
result = result .. '\n'
result = result .. '|-\n'
if string.sub(data[t].legendaryhero2,1,1) == '*' then
result = result .. '|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { string.sub(data[t].legendaryhero2,2) }} .. ' (new)'
else
result = result .. '|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { data[t].legendaryhero2 }}
end
result = result .. '\n'
if string.sub(data[t].epichero2,1,1) == '*' then
result = result .. '|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { string.sub(data[t].epichero2,2) }} .. ' (new)'
else
result = result .. '|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { data[t].epichero2 }}
end
result = result .. '\n'
if string.sub(data[t].rarehero2,1,1) == '*' then
result = result .. '|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { string.sub(data[t].rarehero2,2) }} .. ' (new)'
else
result = result .. '|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { data[t].rarehero2 }}
end
result = result .. '\n'
result = result .. '|-\n'
if string.sub(data[t].legendaryhero3,1,1) == '*' then
result = result .. '|style="border-bottom: 1px solid;"|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { string.sub(data[t].legendaryhero3,2) }} .. ' (new)'
else
result = result .. '|style="border-bottom: 1px solid;"|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { data[t].legendaryhero3 }}
end
result = result .. '\n'
if string.sub(data[t].epichero3,1,1) == '*' then
result = result .. '|style="border-bottom: 1px solid;"|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { string.sub(data[t].epichero3,2) }} .. ' (new)'
else
result = result .. '|style="border-bottom: 1px solid;"|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { data[t].epichero3 }}
end
result = result .. '\n'
if string.sub(data[t].rarehero3,1,1) == '*' then
result = result .. '|style="border-bottom: 1px solid;"|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { string.sub(data[t].rarehero3,2) }} .. ' (new)'
else
result = result .. '|style="border-bottom: 1px solid;"|' .. mw.getCurrentFrame():expandTemplate{title='tooltip', args = { data[t].rarehero3 }}
end
result = result .. '\n'
end
end
end
count = count + 1
end
end
result = result .. "|}"
return result
end
function p.lastevent(hero, output)
keys = {}
for k in pairs(data) do
if data[k].legendaryhero1 == hero or data[k].legendaryhero1 == '*'..hero
or data[k].legendaryhero2 == hero or data[k].legendaryhero2 == '*'..hero
or data[k].legendaryhero3 == hero or data[k].legendaryhero3 == '*'..hero
or data[k].epichero1 == hero or data[k].epichero1 == '*'..hero
or data[k].epichero2 == hero or data[k].epichero2 == '*'..hero
or data[k].epichero3 == hero or data[k].epichero3 == '*'..hero
or data[k].rarehero1 == hero or data[k].rarehero1 == '*'..hero
or data[k].rarehero2 == hero or data[k].rarehero2 == '*'..hero
or data[k].rarehero3 == hero or data[k].rarehero3 == '*'..hero
then
table.insert(keys, k)
end
end
table.sort(keys)
local result = 'N/A'
for k, t in ipairs(keys) do
if data[t].name ~= '?' then
if output == "name" then
result = '[[' .. data[t].name .. ']]'
else
if output == "date" then
result = data[t].date
else
result = t
end
end
end
end
return result
end
function p.eventinfo(frame)
local event = frame.args['event'] or frame.args[1]
keys = {}
for k in pairs(data) do
if data[k].name == event or data[k].newname == event
then
table.insert(keys, k)
end
end
table.sort(keys)
local result = ''
local first = true
for k, t in ipairs(keys) do
if first then
if data[t].medal or data[t].gameimage or data[t].socialimage then
local gallerycontent = ''
if data[t].medal and data[t].medal ~= "" then
gallerycontent = gallerycontent .. data[t].medal .. ' medal.png|' .. data[t].medal .. ' Medal'
end
if data[t].gameimage and data[t].gameimage ~= "" then
gallerycontent = gallerycontent .. '\n' .. data[t].gameimage .. '|In Game Notice'
end
if data[t].socialimage and data[t].socialimage ~= "" then
gallerycontent = gallerycontent .. '\n' .. data[t].socialimage .. '|Announcement'
end
if gallerycontent ~= '' then
result = mw.getCurrentFrame():callParserFunction( '#tag', { 'gallery', gallerycontent } )
end
end
result = result .. "'''" .. data[t].name .. "''' is "
if data[t].theme == 'Mixed' then
result = result .. 'a'
else
if data[t].theme == 'Order' then
result = result .. 'an [[' .. data[t].theme .. ']] themed'
else
result = result .. 'a [[' .. data[t].theme .. ']] themed'
end
end
result = result .. ' [[Global Events|Global Event]] released on ' .. data[t].date .. '.'
first = false
end
end
result = result .. '\n\n==Timeline==\n'
local first = true
for k, t in ipairs(keys) do
if first then
result = result .. '* Released: ' .. data[t].date
if data[t].newname ~= nil then
result = result .. " as '''" .. data[t].name .. "'''"
end
first = false
else
result = result .. '\n* Rerun: ' .. data[t].date
if data[t].newname ~= nil then
result = result .. " as '''" .. data[t].name .. "'''"
end
end
end
table.sort(keys, function(a, b) return a > b end)
result = result .. '\n\n==Flavor Text==\n'
local tabbercontent = ''
local count = 1
first = true
for k, t in ipairs(keys) do
local freq = 'Rerun'
if count == #keys then
freq = 'Release'
end
if first then
tabbercontent = '' .. data[t].date .. ' ' .. freq .. ' ====' .. data[t].date .. ' ' .. freq .. ' ===\n'
first = false
else
tabbercontent = tabbercontent .. '|-|' .. data[t].date .. ' ' .. freq .. ' ====' .. data[t].date .. ' ' .. freq .. ' ===\n'
end
tabbercontent = tabbercontent .. data[t].flavor
count = count + 1
end
result = result .. mw.getCurrentFrame():callParserFunction( '#tag', { 'tabber', tabbercontent } )
result = result .. '\n\n==Featured Heroes==\n'
tabbercontent = ''
count = 1
first = true
for k, t in ipairs(keys) do
local freq = 'Rerun'
if count == #keys then
freq = 'Release'
end
if first then
tabbercontent = '' .. data[t].date .. ' ' .. freq .. ' ====' .. data[t].date .. ' ' .. freq .. ' ===\n'
first = false
else
tabbercontent = tabbercontent .. '|-|' .. data[t].date .. ' ' .. freq .. ' ====' .. data[t].date .. ' ' .. freq .. ' ===\n'
end
tabbercontent = tabbercontent .. mw.getCurrentFrame():expandTemplate{ title='Featured Heroes', args = { LegendaryHero1 = data[t].legendaryhero1, EpicHero1 = data[t].epichero1, RareHero1 = data[t].rarehero1, LegendaryHero2 = data[t].legendaryhero2, EpicHero2 = data[t].epichero2, RareHero2 = data[t].rarehero2, LegendaryHero3 = data[t].legendaryhero3, EpicHero3 = data[t].epichero3, RareHero3 = data[t].rarehero3 }}
count = count + 1
end
result = result .. mw.getCurrentFrame():callParserFunction( '#tag', { 'tabber', tabbercontent } )
result = result .. '\n\n==Chapter Requirements==\n'
tabbercontent = ''
count = 1
first = true
for k, t in ipairs(keys) do
local freq = 'Rerun'
if count == #keys then
freq = 'Release'
end
if first then
tabbercontent = '' .. data[t].date .. ' ' .. freq .. ' ====' .. data[t].date .. ' ' .. freq .. ' ===\n'
first = false
else
tabbercontent = tabbercontent .. '|-|' .. data[t].date .. ' ' .. freq .. ' ====' .. data[t].date .. ' ' .. freq .. ' ===\n'
end
tabbercontent = tabbercontent .. '* Victory over Players with specified Warlord: '
if data[t].warlord == '?' or data[t].warlord == '' then
tabbercontent = tabbercontent .. '?\n'
else
tabbercontent = tabbercontent .. '[[' .. data[t].warlord .. ']]\n'
end
tabbercontent = tabbercontent .. '* Hero Promotion of specified Hero: '
if string.match(data[t].legendaryhero3, "?") then
tabbercontent = tabbercontent .. '?'
else
tabbercontent = tabbercontent .. mw.getCurrentFrame():expandTemplate{title='Tooltip', args = { string.gsub(data[t].legendaryhero3,"*","") }}
end
count = count + 1
end
result = result .. mw.getCurrentFrame():callParserFunction( '#tag', { 'tabber', tabbercontent } )
return result
end
return p