Module:PvMTreeExample: Difference between revisions

From August Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(15 intermediate revisions by 2 users not shown)
Line 4: Line 4:
local tiers = {
local tiers = {
     ['tier1'] = {
     ['tier1'] = {
         { name = 'Double<br />Cast', total = 1 },
         { name = '[[Talents/PvM_talent_tree#Tier_1|Double<br />Cast]]', file = 'Double cast.png', total = 1 },
         { name = 'Fluid<br />Strikes', total = 1 },
         { name = '[[Talents/PvM_talent_tree#Tier_1|Fluid<br />Strikes]]', file = 'Fluid strikes.png', total = 1 },
         { name = 'Quick<br />Shot', total = 1 },
         { name = '[[Talents/PvM_talent_tree#Tier_1|Quick<br />Shot]]', file = 'Quick shot.png', total = 1 },
         { name = 'Boner<br />Boost', total = 5 },
         { name = '[[Talents/PvM_talent_tree#Tier_1|Boner<br />Boost]]', file = 'Boner boost.png', total = 5 },
         { name = 'Deft<br />Strikes', total = 5 }
         { name = '[[Talents/PvM_talent_tree#Tier_1|Deft<br />Strikes]]', file = 'Deft strikes.png', total = 5 }
     },
     },
     ['tier2'] = {
     ['tier2'] = {
         { name = 'Combat<br />XP', total = 5 },
         { name = '[[Talents/PvM_talent_tree#Tier_2|Combat<br />XP]]', file = 'Combat xp.png', total = 5 },
         { name = 'Menacing<br />Mage', total = 5 },
         { name = '[[Talents/PvM_talent_tree#Tier_2|Menacing<br />Mage]]', file = 'Menacing mage.png', total = 5 },
         { name = 'Elementalist', total = 5 },
         { name = '[[Talents/PvM_talent_tree#Tier_2|Elementalist]]', file = 'Elementalist.png', total = 5 },
         { name = 'Feral<br />fighter', total = 5 },
         { name = '[[Talents/PvM_talent_tree#Tier_2|Feral<br />fighter]]', file = 'Feral fighter.png', total = 5 },
         { name = 'Giant<br />Slayer', total = 5 },
         { name = '[[Talents/PvM_talent_tree#Tier_2|Giant<br />Slayer]]', file = 'Giant slayer.png', total = 5 },
         { name = 'Ruthless<br />Ranger', total = 5 },
         { name = '[[Talents/PvM_talent_tree#Tier_2|Ruthless<br />Ranger]]', file = 'Ruthless ranger.png', total = 5 },
         { name = 'Headshot', total = 5 },
         { name = '[[Talents/PvM_talent_tree#Tier_2|Headshot]]', file = 'Headshot.png', total = 5 },
         { name = 'Bloodworm', total = 1 },
         { name = '[[Talents/PvM_talent_tree#Tier_2|Bloodworm]]', file = 'Bloodworm.png', total = 1 },
         { name = 'Resilience I', total = 5 },
         { name = '[[Talents/PvM_talent_tree#Tier_2|Resilience I]]', file = 'Resilience i.png', total = 5 },
         { name = 'Heart<br />Rate', total = 10 },
         { name = '[[Talents/PvM_talent_tree#Tier_2|Heart<br />Rate]]', file = 'Heart rate.png', total = 10 },
         { name = 'Consistency', total = 5 },
         { name = '[[Talents/PvM_talent_tree#Tier_2|Consistency]]', file = 'Consistency.png', total = 5 },
         { name = 'Fortification', total = 5 },
         { name = '[[Talents/PvM_talent_tree#Tier_2|Fortification]]', file = 'Fortification.png', total = 5 },
         { name = 'Antifire', total = 5 },
         { name = '[[Talents/PvM_talent_tree#Tier_2|Antifire]]', file = 'Antifire.png', total = 5 },
         { name = 'Antipoison', total = 5 },
         { name = '[[Talents/PvM_talent_tree#Tier_2|Antipoison]]', file = 'Antipoison.png', total = 5 },
         { name = 'Devout', total = 5 },
         { name = '[[Talents/PvM_talent_tree#Tier_2|Devout]]', file = 'Devout.png', total = 5 },
         { name = 'Renewal', total = 5 }
         { name = '[[Talents/PvM_talent_tree#Tier_2|Renewal]]', file = 'Renewal.png', total = 5 }
     },
     },
     -- Tiers 3-6 and Key Stones would go here
     ['tier3'] = {
        { name = '[[Talents/PvM_talent_tree#Tier_3|Porcupine]]', file = 'Porcupine.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_3|Unnatural<br />Selection]]', file = 'Unnatural selection.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_3|Treasure<br />Goblins]]', file = 'Treasure goblins.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_3|Draining<br />Strikes]]', file = 'Draining strikes.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_3|Exploding<br />Attacks]]', file = 'Exploding attacks.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_3|Holey<br />Vestments]]', file = 'Holey vestments.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_3|Bottomless<br />Quiver]]', file = 'Bottomless quiver.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_3|Runic<br />Efficiency]]', file = 'Runic efficiency.png', total = 5 }
    },
    ['tier4'] = {
        { name = '[[Talents/PvM_talent_tree#Tier_4|Sigil of<br />Finality]]', file = 'Sigil of finality.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_4|Pious<br />Protectio]]n', file = 'Pious protection.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_4|Aggression]]', file = 'Victory_rush.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_4|Precision]]', file = 'Precision.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_4|Unholy]]', file = 'Unholy.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_4|Firebender]]', file = 'Firebender.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_4|Tekton\'s<br />Rage I]]', file = 'Tekton\'s rage i.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_4|Ghommal\'s<br />Might I]]', file = 'Ghommal\'s might i.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_4|Victory<br />Rush]]', file = 'Victory rush.png', total = 5 }
    },
    ['tier5'] = {
        { name = '[[Talents/PvM_talent_tree#Tier_5|Adrenaline<br />Assault]]', file = 'Adrenaline assault.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_5|Guardian]]', file = 'Guardian.png', total = 1 },
        { name = '[[Talents/PvM_talent_tree#Tier_5|Executioner]]', file = 'Executioner.png', total = 1 },
        { name = '[[Talents/PvM_talent_tree#Tier_5|Berserker]]', file = 'Berserker.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_5|Absolute<br />Unit]]', file = 'Absolute unit.png', total = 1 },
        { name = '[[Talents/PvM_talent_tree#Tier_5|Resilience II]]', file = 'Resilience ii.png', total = 5 }
    },
    ['tier6'] = {
        { name = '[[Talents/PvM_talent_tree#Tier_6|Tekton\'s<br />Rage II]]', file = 'Tekton\'s rage ii.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_6|Ghommal\'s<br />Might II]]', file = 'Ghommal\'s might ii.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_6|Reach<br />Around]]', file = 'Reach around.png', total = 4 },
        { name = '[[Talents/PvM_talent_tree#Tier_6|Energy<br />Efficiency]]', file = 'Energy efficiency.png', total = 7 }
    },
    ['keystones'] = {
        { name = '[[Talents/PvM_talent_tree#Tier_7|Key Stone:<br />Vanguard]]', file = 'Key stone vanguard.png', total = 1 },
        { name = '[[Talents/PvM_talent_tree#Tier_7|Key Stone:<br />Trickster]]', file = 'Key stone trickster.png', total = 1 },
        { name = '[[Talents/PvM_talent_tree#Tier_7|Key Stone:<br />Battlemage]]', file = 'Key stone battlemage.png', total = 1 }
    }
}
}


function p._main(frame)
function p._main(frame)
     local args = frame.args
     local args = frame.args
     local output = ''
     local output = {}
   
    local tier_order = { 'tier1', 'tier2', 'tier3', 'tier4', 'tier5', 'tier6', 'keystones' }


     for key, value in pairs(args) do
     for _, tier_key in ipairs(tier_order) do
         if tiers[key] then
         local value = args[tier_key]
        if value then
             local values = {}
             local values = {}
             for v in value:gmatch("([^,]+)") do
             for v in value:gmatch("([^,]+)") do
Line 42: Line 84:
             end
             end


             local tier_data = tiers[key]
             local tier_data = tiers[tier_key]
           
            table.insert(output, '=== ' .. (tier_key:gsub('(%a+)(%d+)', '%1 %2'):gsub('^%l', string.upper)) .. ' ===')
            table.insert(output, '{| class="wikitable" style="width: 35%;"')
              
              
             output = output .. '=== ' .. (key:gsub('(%a+)(%d+)', '%1 %2'):gsub('^%l', string.upper)) .. ' ===\n'
             local i = 1
            output = output .. '{| class="wikitable" style="width: 35%;"\n'
            while i <= #tier_data do
 
                local header_row_parts = {}
            -- Create header rows
                local data_row_parts = {}
            output = output .. '|-\n'
                local cells_in_row = 0
            for i, item in ipairs(tier_data) do
               
                local filename = item.name:gsub('<br />', ' '):gsub('%s+', ' ')
                while i <= #tier_data and cells_in_row < 5 do
                output = output .. '! style="width: 20%;" | [[File:' .. filename .. '.png|32px]]<br />' .. item.name .. ' '
                    local item = tier_data[i]
            end
                    local current = values[i] or 0
            output = output .. '\n'
                    local total = item.total
 
                    local cell_class = ''
            -- Create data rows
                    local display_text = current .. '/' .. total
            output = output .. '|-\n'
                   
            output = output .. 'style="text-align:center; height: 40px;"\n'
                    if current == total then
            for i, item in ipairs(tier_data) do
                        cell_class = ' class="table-bg-green"'
                local current = values[i] or 0
                    elseif current > 0 then
                local total = item.total
                        cell_class = ' class="table-bg-yellow"'
                local bgcolor = ''
                    elseif current == -1 then
 
                        cell_class = ' class="table-bg-red"'
                if current == total then
                        display_text = '<span style="border-bottom: 1px dashed black;" title="This talent is locked due to other talent choices.">Locked</span>'
                     bgcolor = ' style="width: 20%; background-color:#56e156;"'
                    else
                elseif current > 0 then
                        cell_class = ''
                     bgcolor = ' style="width: 20%; background-color:#ffed4c;"'
                    end
                else
                   
                     bgcolor = ' style="width: 20%;"'
                    table.insert(header_row_parts, 'style="width: 20%;" | [[File:' .. item.file .. '|32px]]<br />' .. item.name .. '')
                    table.insert(data_row_parts, 'style="width: 20%;"' .. cell_class .. ' | ' .. display_text .. '')
                      
                     i = i + 1
                     cells_in_row = cells_in_row + 1
                 end
                 end
                 output = output .. '|' .. bgcolor .. ' | ' .. current .. '/' .. total .. '\n'
                  
                table.insert(output, '|-\n! ' .. table.concat(header_row_parts, ' !! '))
                table.insert(output, '|-' .. ' style="text-align:center; height: 40px;"\n| ' .. table.concat(data_row_parts, ' || '))
             end
             end
             output = output .. '|}\n\n'
             table.insert(output, '|}')
            table.insert(output, '') -- Add a blank line for separation
         end
         end
     end
     end
      
      
     return output
     return table.concat(output, '\n')
end
end


return p
return p

Latest revision as of 13:52, 19 August 2025

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

local p = {}

-- Data for the tiers
local tiers = {
    ['tier1'] = {
        { name = '[[Talents/PvM_talent_tree#Tier_1|Double<br />Cast]]', file = 'Double cast.png', total = 1 },
        { name = '[[Talents/PvM_talent_tree#Tier_1|Fluid<br />Strikes]]', file = 'Fluid strikes.png', total = 1 },
        { name = '[[Talents/PvM_talent_tree#Tier_1|Quick<br />Shot]]', file = 'Quick shot.png', total = 1 },
        { name = '[[Talents/PvM_talent_tree#Tier_1|Boner<br />Boost]]', file = 'Boner boost.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_1|Deft<br />Strikes]]', file = 'Deft strikes.png', total = 5 }
    },
    ['tier2'] = {
        { name = '[[Talents/PvM_talent_tree#Tier_2|Combat<br />XP]]', file = 'Combat xp.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_2|Menacing<br />Mage]]', file = 'Menacing mage.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_2|Elementalist]]', file = 'Elementalist.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_2|Feral<br />fighter]]', file = 'Feral fighter.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_2|Giant<br />Slayer]]', file = 'Giant slayer.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_2|Ruthless<br />Ranger]]', file = 'Ruthless ranger.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_2|Headshot]]', file = 'Headshot.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_2|Bloodworm]]', file = 'Bloodworm.png', total = 1 },
        { name = '[[Talents/PvM_talent_tree#Tier_2|Resilience I]]', file = 'Resilience i.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_2|Heart<br />Rate]]', file = 'Heart rate.png', total = 10 },
        { name = '[[Talents/PvM_talent_tree#Tier_2|Consistency]]', file = 'Consistency.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_2|Fortification]]', file = 'Fortification.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_2|Antifire]]', file = 'Antifire.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_2|Antipoison]]', file = 'Antipoison.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_2|Devout]]', file = 'Devout.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_2|Renewal]]', file = 'Renewal.png', total = 5 }
    },
    ['tier3'] = {
        { name = '[[Talents/PvM_talent_tree#Tier_3|Porcupine]]', file = 'Porcupine.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_3|Unnatural<br />Selection]]', file = 'Unnatural selection.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_3|Treasure<br />Goblins]]', file = 'Treasure goblins.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_3|Draining<br />Strikes]]', file = 'Draining strikes.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_3|Exploding<br />Attacks]]', file = 'Exploding attacks.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_3|Holey<br />Vestments]]', file = 'Holey vestments.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_3|Bottomless<br />Quiver]]', file = 'Bottomless quiver.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_3|Runic<br />Efficiency]]', file = 'Runic efficiency.png', total = 5 }
    },
    ['tier4'] = {
        { name = '[[Talents/PvM_talent_tree#Tier_4|Sigil of<br />Finality]]', file = 'Sigil of finality.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_4|Pious<br />Protectio]]n', file = 'Pious protection.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_4|Aggression]]', file = 'Victory_rush.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_4|Precision]]', file = 'Precision.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_4|Unholy]]', file = 'Unholy.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_4|Firebender]]', file = 'Firebender.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_4|Tekton\'s<br />Rage I]]', file = 'Tekton\'s rage i.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_4|Ghommal\'s<br />Might I]]', file = 'Ghommal\'s might i.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_4|Victory<br />Rush]]', file = 'Victory rush.png', total = 5 }
    },
    ['tier5'] = {
        { name = '[[Talents/PvM_talent_tree#Tier_5|Adrenaline<br />Assault]]', file = 'Adrenaline assault.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_5|Guardian]]', file = 'Guardian.png', total = 1 },
        { name = '[[Talents/PvM_talent_tree#Tier_5|Executioner]]', file = 'Executioner.png', total = 1 },
        { name = '[[Talents/PvM_talent_tree#Tier_5|Berserker]]', file = 'Berserker.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_5|Absolute<br />Unit]]', file = 'Absolute unit.png', total = 1 },
        { name = '[[Talents/PvM_talent_tree#Tier_5|Resilience II]]', file = 'Resilience ii.png', total = 5 }
    },
    ['tier6'] = {
        { name = '[[Talents/PvM_talent_tree#Tier_6|Tekton\'s<br />Rage II]]', file = 'Tekton\'s rage ii.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_6|Ghommal\'s<br />Might II]]', file = 'Ghommal\'s might ii.png', total = 5 },
        { name = '[[Talents/PvM_talent_tree#Tier_6|Reach<br />Around]]', file = 'Reach around.png', total = 4 },
        { name = '[[Talents/PvM_talent_tree#Tier_6|Energy<br />Efficiency]]', file = 'Energy efficiency.png', total = 7 }
    },
    ['keystones'] = {
        { name = '[[Talents/PvM_talent_tree#Tier_7|Key Stone:<br />Vanguard]]', file = 'Key stone vanguard.png', total = 1 },
        { name = '[[Talents/PvM_talent_tree#Tier_7|Key Stone:<br />Trickster]]', file = 'Key stone trickster.png', total = 1 },
        { name = '[[Talents/PvM_talent_tree#Tier_7|Key Stone:<br />Battlemage]]', file = 'Key stone battlemage.png', total = 1 }
    }
}

function p._main(frame)
    local args = frame.args
    local output = {}
    
    local tier_order = { 'tier1', 'tier2', 'tier3', 'tier4', 'tier5', 'tier6', 'keystones' }

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

            local tier_data = tiers[tier_key]
            
            table.insert(output, '=== ' .. (tier_key:gsub('(%a+)(%d+)', '%1 %2'):gsub('^%l', string.upper)) .. ' ===')
            table.insert(output, '{| class="wikitable" style="width: 35%;"')
            
            local i = 1
            while i <= #tier_data do
                local header_row_parts = {}
                local data_row_parts = {}
                local cells_in_row = 0
                
                while i <= #tier_data and cells_in_row < 5 do
                    local item = tier_data[i]
                    local current = values[i] or 0
                    local total = item.total
                    local cell_class = ''
                    local display_text = current .. '/' .. total
                    
                    if current == total then
                        cell_class = ' class="table-bg-green"'
                    elseif current > 0 then
                        cell_class = ' class="table-bg-yellow"'
                    elseif current == -1 then
                        cell_class = ' class="table-bg-red"'
                        display_text = '<span style="border-bottom: 1px dashed black;" title="This talent is locked due to other talent choices.">Locked</span>'
                    else
                        cell_class = ''
                    end
                    
                    table.insert(header_row_parts, 'style="width: 20%;" | [[File:' .. item.file .. '|32px]]<br />' .. item.name .. '')
                    table.insert(data_row_parts, 'style="width: 20%;"' .. cell_class .. ' | ' .. display_text .. '')
                    
                    i = i + 1
                    cells_in_row = cells_in_row + 1
                end
                
                table.insert(output, '|-\n! ' .. table.concat(header_row_parts, ' !! '))
                table.insert(output, '|-' .. ' style="text-align:center; height: 40px;"\n| ' .. table.concat(data_row_parts, ' || '))
            end
            table.insert(output, '|}')
            table.insert(output, '') -- Add a blank line for separation
        end
    end
    
    return table.concat(output, '\n')
end

return p