Module:Traits: Difference between revisions

1,064 bytes removed ,  2 May 2023
no edit summary
No edit summary
Tag: Reverted
No edit summary
Tag: Manual revert
Line 49: Line 49:
     }
     }


     local details = {
     local details = { { STR.LIGHT, STR.CRITICAL, STR.REVERSED },
        { STR.LIGHT, STR.CRITICAL, STR.REVERSED },
         { STR.HEAVY, STR.HASTE,    STR.REGEN2,  STR.RUTHLESS, STR.POWERFUL, STR.REVERSED }, { STR.KB1 },
         { STR.HEAVY, STR.HASTE,    STR.REGEN2,  STR.RUTHLESS, STR.POWERFUL, STR.REVERSED },
         { STR.REGEN1 }, { STR.USEFUL } }
        { STR.KB1 },
         { STR.REGEN1 },
        { STR.USEFUL }
    }


     -- Default values
     -- Default values
Line 98: Line 94:
         return char:gsub('/', '')
         return char:gsub('/', '')
     end
     end
    local buffs = args.buffs and split(args.buffs)


     local trait_table = mw.html.create('div'):attr('class', 'content-table'):tag('table'):attr({
     local trait_table = mw.html.create('div'):attr('class', 'content-table'):tag('table'):attr({
Line 156: Line 150:
                 local th_detail = tr2:tag('th'):wikitext(prop[detail_key]);
                 local th_detail = tr2:tag('th'):wikitext(prop[detail_key]);
                 th:attr('colspan', tonumber(th:getAttr('colspan') or 1) + 1)
                 th:attr('colspan', tonumber(th:getAttr('colspan') or 1) + 1)
                if prop[detail_key] == 'Duration' then
                    if (trait_name == STR.KB1 or trait_name == STR.KB2) and args.buffs then
                        for _, buff in ipairs(buffs) do
                            if trait_name == STR.KB1 then
                                th_detail:attr('colspan', (th_detail:getAttr('colspan') or 0) + 1)
                                tr2:tag('th'):wikitext(buff)
                            else
                                tr2:tag('th'):wikitext(buff)
                            end
                           
                            th:attr('colspan', (th:getAttr('colspan') or 1) + 1)
                        end
                    end
                end
             end
             end
         end
         end
       


         -- Unnamed argument.
         -- Unnamed argument.
Line 196: Line 174:
                         unnamed[1],
                         unnamed[1],
                         unnamed[2],
                         unnamed[2],
                         MP = args['def_ignore' .. trait_count] ~= nil and 'Energy' or MP_ARG,
                         MP = MP_ARG,
                         ECP = ECP_ARG,
                         ECP = ECP_ARG,
                         CD = args['cd' .. trait_count] or default_value['cd'],
                         CD = args['cd' .. trait_count] or default_value['cd'],
                         DURATION = args['duration' .. trait_count],
                         DURATION = args['duration' .. trait_count],
                         CHANCE = args['chance' .. trait_count] or default_value['chance'],
                         CHANCE = args['chance' .. trait_count] or default_value['chance'],
                         DAMAGE = args['dmg' .. trait_count] or default_value['dmg'],
                         DAMAGE = args['dmg' .. trait_count] or default_value['dmg']
                        DEF_IGNORE = args['def_ignore' .. trait_count],
                        DEF_IGNORE_PVP = args['pvp_def_ignore' .. trait_count]
                     }
                     }
                 });
                 });
Line 236: Line 212:
                         local function calcEndValue(base)
                         local function calcEndValue(base)
                             local end_value;
                             local end_value;
                             if tonumber(short_detail) == nil then
                             if short_detail == 'hits' then
                                 end_value = base or -1
                                 end_value = base or 0
                             else
                             else
                                 end_value = (tonumber(multiplier) / 100) * tonumber(base or -1)
                                 end_value = (tonumber(multiplier) / 100) * tonumber(base or 0)
                             end
                             end
                             if tonumber(end_value) ~= nil and tonumber(end_value) < 0 then
                             if tonumber(end_value) ~= nil and tonumber(end_value) <= 0 then
                                 end_value = '-'
                                 end_value = '-'
                             end
                             end
Line 265: Line 241:
                             end
                             end


                             local detail_cell = (is_pvp and tr4 or tr3):tag('td'):wikitext(detail_text):attr('rowspan',
                             local detail_cell = (is_pvp and tr4 or tr3):tag('td'):wikitext(detail_text):attr('rowspan', has_pvp_values and (not args[short_detail_improved .. '_pvp']) and 2 or 1);
                            has_pvp_values and (not args[short_detail_improved .. '_pvp']) and 2 or 1);
                         end
                         end
                     end
                     end