Module:Traits: Difference between revisions

no edit summary
No edit summary
No edit summary
Tag: Reverted
Line 29: Line 29:
     end
     end


     local desc = {
     local desc = {}
        [1] = {},
        [2] = {}
    }


     -- Extra effects
     -- Extra effects
     local counts = {}
     local counts = {}
     local desc_arg = nil;
     local desc_arg = nil;
     local header_data = {
     local header_data = {}
        [1] = {},
        [2] = {}
    }
     for i = 1, 2, 1 do
     for i = 1, 2, 1 do
         if (i == 1) then
         if (i == 1) then
Line 53: Line 47:


         if desc_arg ~= nil then
         if desc_arg ~= nil then
             local headers = split(desc_arg, ';')[1];
            traits[i] = trim(traits[i]);
             local data = split(desc_arg, ';')[2];
             local data_split = split(desc_arg, ';');
            headers = split(headers);
            local headers;
            local data;
 
            if (#data_split >= 2) then
                headers = split(data_split[1]);
                data = data_split[2];
             else
                data = data_split[1];
 
                -- Generate headers based on trait.
                if (traits[i] == 'Light' or traits[i] == 'Critical') then
                    headers = {[1] = 'MP Usage'}
                elseif (traits[i] == 'Heavy' or traits[i] == 'Haste' or traits[i] == 'Regenerating (2)' or traits[i] == 'Ruthless' or traits[i] == 'Powerful') then
                    headers = {[1] = 'Cooldown'}
                elseif (traits[i] == 'Reversed') then
                    headers = {[1] = 'Cooldown', [2] = 'MP Usage'}
                elseif (traits[i] == 'Regenerating (1)') then
                    headers = {[1] = 'MP Recovery'}
                elseif (traits[i] == 'Killing Blow (1)') then
                    headers = {[1] = 'Duration'}
                end
 
            end


             for k, v in spairs(headers) do
             for k, v in spairs(headers) do
                header_data[i] = {}
                 table.insert(header_data[i], v)
                 table.insert(header_data[i], v)
             end
             end
Line 66: Line 83:
             local index = 1
             local index = 1
             while index <= #headers do
             while index <= #headers do
                 desc[i][headers[index]] = data[index]
                 desc[i] = {}
                desc[i][index] = {}
                desc[i][index][headers[index]] = data[index]
                 index = index + 1
                 index = index + 1
             end
             end
Line 99: Line 118:
     thead:tag('th'):attr('colspan', counts[1]):wikitext(traits[1] .. ' ' .. skill)
     thead:tag('th'):attr('colspan', counts[1]):wikitext(traits[1] .. ' ' .. skill)
     thead:tag('th'):attr('colspan', counts[2]):wikitext(traits[2] .. ' ' .. skill)
     thead:tag('th'):attr('colspan', counts[2]):wikitext(traits[2] .. ' ' .. skill)
    local no_desc;


     local tr_2 = newtr();
     local tr_2 = newtr();
     for i = 1, 2, 1 do
     for i = 1, 2, 1 do
        no_desc = args['desc' .. i] == nil and args[6] == nil and args[7] == nil;
         tr_2:tag('th'):wikitext('Attribute Effect')
         tr_2:tag('th'):wikitext('Attribute Effect')
         if (args['effects' .. i] ~= nil) then
         if not (no_desc) then
             for k, v in spairs(header_data[i]) do
             for k, v in ipairs(header_data[i]) do
                 v = frame:preprocess(v);
                 v = frame:preprocess(v);
                 tr_2:tag('th'):wikitext(v)
                 tr_2:tag('th'):wikitext(v)
Line 114: Line 136:
     local tr = trait_table:tag('tr')
     local tr = trait_table:tag('tr')
     for i = 1, 2, 1 do
     for i = 1, 2, 1 do
        no_desc = args['desc' .. i] == nil and args[6] == nil and args[7] == nil;
         tr:tag('td'):wikitext(frame:expandTemplate{
         tr:tag('td'):wikitext(frame:expandTemplate{
             title = 'SkillText',
             title = 'SkillText',
             args = {traits[i], effects[i][1], effects[i][2]}
             args = {traits[i], effects[i][1], effects[i][2]}
         })
         })
         for k, v in pairs(desc[i]) do
         if not (no_desc) then
            tr:tag('td'):wikitext(frame:preprocess(v))
            for k, v in ipairs(desc[i]) do
                for k2, v2 in pairs(desc[i][k]) do
                    tr:tag('td'):wikitext(frame:preprocess(v2))
                end
            end
         end
         end
     end
     end