Documentation for this module may be created at Module:DetailedMemoriaStatListTable/doc
format_memoria_effects = require("Module:MemoriaEffects").render -- Import the render method of Module:MemoriaEffects
memoria_id_sort = require("Module:MemoriaIdSort ").main
local p = {}
function p.main(frame)
local memoria_list_page = frame.args['MemoriaListSource']
local iconsize = frame.args['iconsize']
return p.render(frame, memoria_list_page, iconsize)
end
function p.gallery(frame)
local memoria_list_page = frame.args['MemoriaListSource']
local character = frame.args['characterName']
local animePersonal = frame.args['animePersonal']
local iconsize = frame.args['iconsize']
return p.render(frame, memoria_list_page, iconsize, character, animePersonal)
end
function make_row(frame, memo, iconsize)
if memo == "" or memo == nil then
return ""
end
effect2, effect1, cooldown2, cooldown1 = frame:expandTemplate{ title = 'Template:'.. memo, args = {'Get', "effect2", "effect1", "Cooldown2", "Cooldown"}}:match("^(.*)¤(.*)¤(.*)¤(.*)$")
event, owner, rarity, id, name, hp, atk, def = frame:expandTemplate{ title = 'Template:'.. memo, args = {'Get', 'Event', "Owner", "Rarity", "ID", "name", "max_HP", "max_ATK", "max_DEF"}}:match("^(.*)¤(.*)¤(.*)¤(.*)¤(.*)¤(.*)¤(.*)¤(.*)$")
-- TODO: Expand memoria get to allow more than 9 query params
if event ~= "" then
colour_class = "memo-event-row"
elseif owner ~= "" or rarity == "1" then
colour_class = "memo-personal-row"
else
colour_class = ""
end
if cooldown2:gsub("%s+", "") == "" then
active_class = "memo-passive-row"
else
active_class = "memo-active-row"
end
if event:gsub("%s+", "") == "" then
limited_class = "memo-unlimited-row"
else
limited_class = "memo-limited-row"
end
local out = "<tr class=\"" .. colour_class .. " " .. active_class .. " " .. limited_class .. "\">"
out = out .. "<td data-sort-value=\"" .. id .."\">[[File:memoria_" .. id .. "_s.png|" .. iconsize .. "|link=" .. name:gsub("%%3F", "?") .. "]]</td>"
out = out .. "<td style=\"text-align: left;\">[[" .. name .. "]]</td>"
if rarity == "" then
rarity = "0"
end
if hp == "" then
hp = "0"
end
if atk == "" then
atk = "0"
end
if def == "" then
def = "0"
end
local number_row = "<td data-sort-value=\"%05d_%s\" style=\"text-align: %s;\">%s</td>"
out = out .. string.format(number_row, rarity, name, "center", rarity .. "★")
out = out .. string.format(number_row, hp, name, "right", hp)
out = out .. string.format(number_row, atk, name, "right", atk)
out = out .. string.format(number_row, def, name, "right", def)
if effect2 ~= "" then
effect_sort = effect2
effect = effect2
elseif cooldown1 ~= "" then
effect_sort = effect1
effect = effect1
else
effect_sort = "!"
effect = false
end
if effect then
display_effect_value = false
values = format_memoria_effects(frame, effect)
for value in (values .. ";"):gmatch("%s*(.-);%s*") do
stripped_effect, full_name_effect = value:match("^(.*)¬(.*)$")
if not display_effect_value then
display_effect_value = string.format("[[%s|%s]]", stripped_effect, full_name_effect)
else
display_effect_value = display_effect_value .. " & " .. string.format("[[%s|%s]]", stripped_effect, full_name_effect)
end
end
else
display_effect_value = "No Data"
end
out = out .. "<td data-sort-value=\"" .. effect_sort .. "\" style=\"text-align: center;\">" .. display_effect_value .. "</td>"
if cooldown2 ~= "" then
cooldown_sort = string.format("%02d", cooldown2)
cooldown = cooldown2
elseif cooldown1 ~= "" then
cooldown_sort = string.format("%02d", cooldown1)
cooldown = cooldown1
else
cooldown_sort = "00"
cooldown = "-"
end
out = out .. "<td data-sort-value=\"" .. cooldown_sort .. "_" .. name .. effect_sort .. "\" style=\"text-align: center;\">" .. cooldown .. "</td>"
out = out .. "</tr>"
return out
end
function get_personal(frame, character)
if character == nil then
return nil
end
return frame:expandTemplate{ title = 'Template:'.. character, args = {'Get', "memoria"}}
end
function p.render(frame, memoria_list_page, iconsize, character, animePersonal)
local released, check = pcall(get_personal, frame, character)
local personal = nil
if character ~= nil and released then
personal = check
if not personal or personal == "" then
personal = nil
end
end
local memos = memoria_id_sort(frame, frame:expandTemplate{ title = memoria_list_page })
if personal ~= nil then
if animePersonal ~= nil and animePersonal ~= "" then
personal = personal .. ";" .. animePersonal
end
for personal_memo in (personal .. ";"):gmatch("%s*([^;]*)%s*;") do
memos = memos:gsub(personal_memo:gsub('%?', '%%?'), "")
end
memos = personal .. ";" .. memos:gsub("[;]+", ";")
end
if iconsize == nil then
iconsize = "75px"
end
local out = "<table class=\"article-table sortable\" style=\"width: 100%;\">" ..
"<tr>" ..
"<th> </th>" ..
"<th>Name</th>" ..
"<th>Rank</th>" ..
"<th>HP</th>" ..
"<th>ATK</th>" ..
"<th>DEF</th>" ..
"<th>Effect</th>" ..
"<th>CD</th>" ..
"</tr>"
for memo in (memos .. ";"):gmatch("%s*([^;]*)%s*;") do
result, lineOrError = pcall(make_row, frame, memo, iconsize)
if result then -- If pcall returns not error
out = out .. lineOrError
else
out = out .. "<tr><td>?</td><td>" .. memo .. "</td><td>" .. lineOrError .. "</td><td>?</td><td>?</td><td>?</td><td>?</td><td>?</td></tr>"
end
end
out = out .. "</table>"
return out
end
return p