No edit summary |
No edit summary |
||
Line 107: | Line 107: | ||
bonus = bonus .. " " |
bonus = bonus .. " " |
||
end |
end |
||
− | bonus = "+" .. v .. " " .. k |
+ | bonus = bonus .. "+" .. v .. " " .. k |
end |
end |
||
end |
end |
Revision as of 15:21, 21 May 2020
Documentation for this module may be created at Module:ArmorSet/doc
local p = {}
local cargo = mw.ext.cargo
function p.Main( frame )
local inpSet = frame.args['set']
local inpType = "base"
if frame.args['type'] and frame.args['type'] ~= "" then
inpType = frame.args['type']
end
local inpExceptional = (inpType == "exceptional") or false
local inpFlawless = (inpType == "flawless") or false
local inpEpic = false
if frame.args['epic'] == "true" then
inpEpic = true
end
-- prepare query
local where = '_pageName '
-- epic
if not inpEpic then
where = where .. "NOT"
end
where = where .. ' LIKE "%(Epic)" AND '
-- exceptional
local where = where .. '_pageName '
if not inpExceptional then
where = where .. "NOT"
end
where = where .. ' LIKE "Exceptional %" AND '
-- flawless
local where = where .. '_pageName '
if not inpFlawless then
where = where .. "NOT"
end
where = where .. ' LIKE "Flawless %" AND '
-- set name (and exclude saddle, padding and lining)
where = where .. '_pageName LIKE "%' .. inpSet .. '%" AND _pageName NOT LIKE "%Saddle%" AND _pageName NOT LIKE "%Padding%" AND _pageName NOT LIKE "%Lining%"'
tables = 'Item'
fields = 'id, name, _pageName, bonus, heatres, coldres, dlcPackage'
local args = {
where = '_pageName=uniqueName AND type="Armor" AND id IS NOT NULL AND ' .. where,
groupBy = 'id,_pageName',
limit = 10
}
-- itemlist
local itemList = "" -- inpSet .. " / " .. inpExceptional .. " / " .. where
local foundHeatres, foundColdres = false
local dlcPackage
local attr = {["Accuracy"] = 0, ["Agility"] = 0, ["Grit"] = 0, ["Encumbrance"] = 0, ["Strength"] = 0, ["Vitality"] = 0}
local results = cargo.query( tables, fields, args )
for r = 1, #results do
local result = results[r]
-- item list
itemList = itemList .. "* " .. frame:callParserFunction('#invoke:ItemLink', 'Main', result["name"]) .. " " .. result["bonus"] .. "\n"
-- heat/cold res
if tonumber(result["heatres"]) or 0 > 0 then
foundHeatres = true
end
if tonumber(result["coldres"]) or 0 > 0 then
foundColdres = true
end
-- bonus
if result["bonus"] ~= "" then
local value, key = string.match(result["bonus"],'(%d+)%s*(%a+)')
if attr[key] then
value = value + attr[key]
attr[key] = value
end
end
-- dlc
if not dlcPackage then
dlcPackage = result["dlcPackage"]
end
end
-- prepare result
-- headline
local headline = '<div style="font-size: 14px; font-weight:bold; color:#a38369">' .. inpSet .. '</div>\n' -- .. "<br/>"
-- sub-headline
local subHeadline = ""
-- heat/cold res
if foundColdres and foundHeatres then
subHeadline = subHeadline .. "[[File:T_tooltip_warmIcon.png|frameless|32px|link=]]" .. "/" .. "[[File:T_tooltip_coldIcon.png|frameless|32px|link=]]" .. " Heat and Cold resistance"
elseif foundHeatres then
subHeadline = subHeadline .. "[[File:T_tooltip_warmIcon.png|frameless|32px|link=]]" .. " Heat resistance"
elseif foundColdres then
subHeadline = subHeadline .. "[[File:T_tooltip_coldIcon.png|frameless|32px|link=]]" .. " Cold resistance"
end
-- bonus
local bonus = ""
for k, v in pairs(attr) do
if v > 0 then
if bonus ~= "" then
bonus = bonus .. " "
end
bonus = bonus .. "+" .. v .. " " .. k
end
end
if bonus ~= "" then
subHeadline = subHeadline .. ", " .. bonus
end
-- dlc
if dlcPackage and dlcPackage ~= "" then
subHeadline = subHeadline .. ", [[Downloadable Content|DLC]] [[" .. dlcPackage .. "]]"
end
subHeadline = subHeadline .. "\n" -- "<br/>"
return headline .. subHeadline .. itemList .. "\n" .. attr["Agility"] -- .. inpType .. "/" .. tostring(inpExceptional) .. "/" .. tostring(inpFlawless)
end
return p