No edit summary |
No edit summary |
||
Line 51: | Line 51: | ||
local memoria_effects = require("Module:MemoriaEffects") |
local memoria_effects = require("Module:MemoriaEffects") |
||
− | local formated_effect1 = memoria_effects. |
+ | local formated_effect1 = memoria_effects.render(frame, effect1) |
output = output .. "<td data-sort-value=" .. formated_effect1 .. "</td>" |
output = output .. "<td data-sort-value=" .. formated_effect1 .. "</td>" |
Revision as of 12:46, 5 June 2021
Documentation for this module may be created at Module:TFF/doc
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 make_row(frame, memo, iconsize)
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
-- TEST
output = "<tr><td>" .. event .. "</td><td>" .. owner .. "</td><td>" .. rarity .. "</td><td>" .. atk .. "</td><td>" .. name .. "</td><td>" .. hp .. atk .. def .. "</td><td>" .. effect2 .. effect1 .. "</td><td>" .. cooldown2 .. cooldown1 .. "</td></tr>"
-- TEST END
local style = ""
if event ~= "" then
style = "style=\"background: #E9F2FF;\""
elseif owner ~= "" then
style = "style=\"background: #E9FFF2;\""
elseif rarity == "1" then
style = "style=\"background: #E9FFF2;\""
end
output = output .. "<tr " .. style .. ">"
output = output .. "<td data-sort-value=\"" .. id .."\">[[File:memoria_" .. id .. "_s.png|" .. iconsize .. "|link=" .. name:gsub("%%3F", "?") .. "]]</td>"
output = output .. "<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>"
output = output .. string.format(number_row, rarity, name, "center", rarity .. "★")
output = output .. string.format(number_row, hp, name, "right", hp)
output = output .. string.format(number_row, atk, name, "right", atk)
output = output .. string.format(number_row, def, name, "right", def)
local memoria_effects = require("Module:MemoriaEffects")
local formated_effect1 = memoria_effects.render(frame, effect1)
output = output .. "<td data-sort-value=" .. formated_effect1 .. "</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
if effect2 ~= "" then
effect_sort = effect2
elseif cooldown1 ~= "" then
effect_sort = effect1
else
effect_sort = "!"
end
output = output .. "<td data-sort-value=\"" .. cooldown_sort .. name .. effect_sort .. "\" style=\"text-align: center;\">" .. cooldown .. "</td>"
output = output .. "</tr>"
return output
end
function p.render(frame, memoria_list_page, iconsize)
mw.log(("%5s").format("11"))
local memos = frame:expandTemplate{ title = memoria_list_page }
if iconsize == nil then
iconsize = "75px"
end
local output = "<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, line = pcall(make_row, frame, memo, iconsize)
if result then -- If pcall returns not error
output = output .. line
else
output = output .. "<tr><td>?</td><td>" .. memo .. "</td><td>" .. line .. "</td><td>?</td><td>?</td><td>?</td><td>?</td><td>?</td></tr>"
end
end
output = output .. "</table>"
return output
end
return p