Module:PvMTreeExample: Difference between revisions

From August Wiki
Jump to navigation Jump to search
Created page with "local p = {} -- Data for the tiers local tiers = { ['tier1'] = { { name = 'Double<br />Cast', total = 1 }, { name = 'Fluid<br />Strikes', total = 1 }, { name = 'Quick<br />Shot', total = 1 }, { name = 'Boner<br />Boost', total = 5 }, { name = 'Deft<br />Strikes', total = 5 } }, ['tier2'] = { { name = 'Combat<br />XP', total = 5 }, { name = 'Menacing<br />Mage', total = 5 }, { name = 'Elementalis..."
 
No edit summary
Line 28: Line 28:
         { name = 'Renewal', total = 5 }
         { name = 'Renewal', total = 5 }
     },
     },
     -- You would continue to add data for tiers 3-6 and Key Stones here
     -- Tiers 3-6 and Key Stones would go here
}
}


function p.main(frame)
function p._main(frame)
     local args = frame.args
     local args = frame.args
     local output = ''
     local output = ''
Line 50: Line 50:
             output = output .. '|-\n'
             output = output .. '|-\n'
             for i, item in ipairs(tier_data) do
             for i, item in ipairs(tier_data) do
                 output = output .. '! style="width: 20%;" | [[File:' .. item.name:gsub('<br />', '') .. '.png|32px]]<br />' .. item.name .. ' '
                local filename = item.name:gsub('<br />', ' '):gsub('%s+', ' ')
                 output = output .. '! style="width: 20%;" | [[File:' .. filename .. '.png|32px]]<br />' .. item.name .. ' '
             end
             end
             output = output .. '\n'
             output = output .. '\n'

Revision as of 12:41, 18 August 2025

Documentation for this module may be created at Module:PvMTreeExample/doc

local p = {}

-- Data for the tiers
local tiers = {
    ['tier1'] = {
        { name = 'Double<br />Cast', total = 1 },
        { name = 'Fluid<br />Strikes', total = 1 },
        { name = 'Quick<br />Shot', total = 1 },
        { name = 'Boner<br />Boost', total = 5 },
        { name = 'Deft<br />Strikes', total = 5 }
    },
    ['tier2'] = {
        { name = 'Combat<br />XP', total = 5 },
        { name = 'Menacing<br />Mage', total = 5 },
        { name = 'Elementalist', total = 5 },
        { name = 'Feral<br />fighter', total = 5 },
        { name = 'Giant<br />Slayer', total = 5 },
        { name = 'Ruthless<br />Ranger', total = 5 },
        { name = 'Headshot', total = 5 },
        { name = 'Bloodworm', total = 1 },
        { name = 'Resilience I', total = 5 },
        { name = 'Heart<br />Rate', total = 10 },
        { name = 'Consistency', total = 5 },
        { name = 'Fortification', total = 5 },
        { name = 'Antifire', total = 5 },
        { name = 'Antipoison', total = 5 },
        { name = 'Devout', total = 5 },
        { name = 'Renewal', total = 5 }
    },
    -- Tiers 3-6 and Key Stones would go here
}

function p._main(frame)
    local args = frame.args
    local output = ''

    for key, value in pairs(args) do
        if tiers[key] then
            local values = {}
            for v in value:gmatch("([^,]+)") do
                table.insert(values, tonumber(v))
            end

            local tier_data = tiers[key]
            
            output = output .. '=== ' .. (key:gsub('(%a+)(%d+)', '%1 %2'):gsub('^%l', string.upper)) .. ' ===\n'
            output = output .. '{| class="wikitable" style="width: 35%;"\n'

            -- Create header rows
            output = output .. '|-\n'
            for i, item in ipairs(tier_data) do
                local filename = item.name:gsub('<br />', ' '):gsub('%s+', ' ')
                output = output .. '! style="width: 20%;" | [[File:' .. filename .. '.png|32px]]<br />' .. item.name .. ' '
            end
            output = output .. '\n'

            -- Create data rows
            output = output .. '|-\n'
            output = output .. 'style="text-align:center; height: 40px;"\n'
            for i, item in ipairs(tier_data) do
                local current = values[i] or 0
                local total = item.total
                local bgcolor = ''

                if current == total then
                    bgcolor = ' style="width: 20%; background-color:#56e156;"'
                elseif current > 0 then
                    bgcolor = ' style="width: 20%; background-color:#ffed4c;"'
                else
                    bgcolor = ' style="width: 20%;"'
                end
                output = output .. '|' .. bgcolor .. ' | ' .. current .. '/' .. total .. '\n'
            end
            output = output .. '|}\n\n'
        end
    end
    
    return output
end

return p