FANDOM


local p = {}
 
local Weapons = mw.loadData( 'Module:Weapon Database' )
 
function p.main(frame)
    local count = 0
    -- Don't use rowspan="2" for Name, Image, Rarity and Element collmuns.
    -- The sorting button will not show up and it will mess up the sorting of Min collumns.
    -- If somehow, you can fix that bug, then go ahead and use the rowspan="2".
    local result = 
        "{|class = \"mw-datatable sortable\" style=\"width:auto;text-size:90%;border-style:none;\"\n"..
        "! style=\"width:12%;border-style:none;background: none;\" | \n"..
        "! style=\"width:60px;padding:0px;border-style:none;background: none;\" | \n"..
        "! style=\"width:9%;border-style:none;background: none;\" | \n "..
        "! style=\"width:8%;border-style:none;background: none;\" | \n"..
        "! style=\"width:10%;border-style:none;background: none;\" | \n"..
        "! style=\"width:19%;border-style:none;background: none;\" | \n"..
        "! style=\"width:12%;\" colspan =\"2\" | HP \n"..
        "! style=\"width:12%;\" colspan =\"2\" | ATK \n"..
        "! style=\"width:12%;\" colspan =\"2\" | Total Power\n"..
        "|-\n"..
        "! Name\n"..
        "! Image\n".. 
        "! Rar.\n".. 
        "! Elem.\n"..
        "! Type\n"..
        "! Skill\n"..
        "! Min || Max || Min || Max || Min || Max\n"
    for key,value in pairs(Weapons) do
        local i = 0
        for _ in pairs(frame.args) do
            i = i + 1
            if (frame.args[i] == "All" or frame.args[i] == value["name"] or frame.args[i] == value["rarity"]) then
                count = count + 1
                result = result..
                    "|-style=\"border-left: 2px solid grey;\"\n "..
                    "| [["..value["name"].."]]".."\n"..
                    "| style=\"padding:0px;\" | "..("%s%s%s%s|60px|link=%s]]"):format('[[', 'File:', value.name, ' Portrait.jpg', value.name).."\n"..
                    "| "..("%s%s%s%s|35px]]"):format('[[', 'File:', value.rarity, '.png').."\n"..
                    "|"
 
                local count = 0 
                for element in (value["element"] .. ";"):gmatch("([^;]*);") do 
                    count = count + 1
                end
 
                if (count == 1) then
                    result = result..("%s%s%s%s|30px]]"):format('[[', 'File:', value.element, 'Symbol.png')
                else
                    for element in (value["element"] .. ";"):gmatch("([^;]*);") do
                        result = result..("%s%s%s%s|x20px]]"):format('[[', 'File:', element, 'Symbol.png')
                    end
                end
 
                result = result.."\n| "..("%s%s%s%s|x20px]]"):format('[[', 'File:', value.type, '.png').."\n"
 
                -- WEAPON SKILLS
                if value["skill1"] then
                    result = result.."| style=\"text-align:left;\" | '''•''' "..value["skill1"]
                    if value["skill1_flb"] then
                       result = result.." / <span style=\"color:blue;\">"..value["skill1_flb"].."</span>"
                    end
 
                    if value["skill2"] then
                        result = result.."<br />'''•''' "..value["skill2"]
                        if value["skill2_flb"] then
                            result = result.." / <span style=\"color:blue;\">"..value["skill2_flb"].."</span>"
                        end
                    elseif value["skill2_flb"] then
                        result = result.."<br />'''•''' <span style=\"color:blue;\">"..value["skill2_flb"].."</span>" 
                    end
                else
                    result = result.."| style=\"text-align:left;\" | None \n"
                end
 
                result = result.."\n"..
                    "| data-sort-type=\"number\" style=\"color:blue;\" | "..value["hp_min"].."\n"..
                    "| data-sort-type=\"number\" style=\"color:blue;\" | "..value["hp_max"]
                if value["hp_flb"] then
                    result = result.."<br />("..value["hp_flb"]..")"
                end
 
                result = result.."\n"..
                    "| data-sort-type=\"number\" style=\"color:red;\" | "..value["atk_min"].."\n"..
                    "| data-sort-type=\"number\" style=\"color:red;\" | "..value["atk_max"]
                if value["atk_flb"] then
                    result = result.."<br />("..value["atk_flb"]..")"
                end
 
                result = result.."\n"..
                    "| data-sort-type=\"number\" style=\"color:green;\" | "..value["hp_min"] + value["atk_min"].."\n"..
                    "| data-sort-type=\"number\" style=\"color:green;\" | "..(value["hp_max"] + value["atk_max"])
                if value["hp_flb"] then
                    result = result.."<br />("..value["hp_flb"] + value["atk_flb"] ..")"
                end
                result = result.."\n"
            end
        end
    end
    if (frame.args["header"] == "yes") then
        result = result.."|+ '''"..count.." Weapons'''\n"
    end
    result = result.."|}\n"
    return result
end
return p
Community content is available under CC-BY-SA unless otherwise noted.