FANDOM


local p = {}
 
function getColor(points, bonus, isAvatar)
    local retVal = {}
 
    local fullLevels = math.floor(points / 15)
    local partialLevels = math.floor((points - (fullLevels * 15)) / 5)
    local fullBonus = ''
    local partBonus = ''
    local totalBonus = ''
 
    if points < 3 then
        fullLevels = fullLevels - 1
    end
 
    fullLevels = fullLevels + bonus + isAvatar
 
    if fullLevels > 0 then
        fullBonus = '+' .. fullLevels
    elseif fullLevels < 0 then
        fullBonus = fullLevels
    end
 
    totalBonus = fullBonus
 
    if (partialLevels > 0) then
        partBonus = ' +' .. partialLevels
        partBonus = partBonus .. '/3'
        totalBonus = totalBonus .. partBonus
    end
 
    retVal.Bonus = totalBonus
 
    if fullLevels < 0 then
        retVal.color = "red"
    elseif fullLevels == 0 then
        if partialLevels == 0 then
            retVal.color = "yellow"
            retVal.Bonus = '0'
        else
            retVal.color = "limegreen"
        end
    else
        retVal.color = "limegreen"
    end
 
    return retVal
end
 
function addRow(htmltable, rowTitle, points, bonus, isAvatar)
    local val = getColor(tonumber(points), tonumber(bonus), tonumber(isAvatar))
 
    htmltable
        :tag('tr')
            :css('color', val.color)
            :css('background', 'black')
            :tag('th')
                :css('text-align', 'right')
                :css('font-size', '12px')
                :css('border-width', '3px')
                :css('border-color', 'limegreen')
                :wikitext(rowTitle)
                :done()
            :tag('td')
                :css('text-align', 'center')
                :css('border-width', '3px')
                :css('border-color', 'limegreen')
                :wikitext(points)
                :done()
            :tag('td')
                :css('border-width', '3px')
                :css('border-color', 'limegreen')
                :wikitext(val.Bonus)
end
 
function p.createtable(frame)
    -- Create an empty string that will be returned at the end of the function
    -- New things will be added to the string as we do them
    local retString = ""
 
    -- Create an html node that will represent the table
    local htmltable = mw.html.create('table')
 
    -- Change that node's css properties so that it has the proper style
    htmltable
        :css('width','49.5%')
        :css('font-size', '14px')
        :css('float', 'right')
        :css('margin', '0 0 0em 0em')
        :css('border-style', 'solid')
        :css('border-width', '3px')
        :css('border-color', 'limegreen')
        :css('background', 'limegreen')
        :css('padding', '1px 1px')
        :css('color', 'green')
        :css('text-align', 'left')
        :attr('cellpadding', '1')
        :attr('cellspacing', '1')
 
    -- Add table header texts
    htmltable:tag('tr')
            :css('background', 'black')
            :tag('th')
                :attr('colspan', 3)
                :css('text-align', 'center')
                :css('font-size','15px')
                :wikitext('Skills')
 
    htmltable:tag('tr')
            :css('background', 'black')
            :tag('th')
                :css('text-align', 'center')
                :css('font-size','15px')
                :wikitext('Name')
                :done()
            :tag('th')
                :css('text-align', 'center')
                :css('font-size','15px')
                :wikitext('Points')
                :done()
            :tag('th')
                :css('text-align', 'center')
                :css('font-size','15px')
                :wikitext('Bonus')
 
    -- Add stat rows
    addRow(htmltable, 'Conventional', frame.args.Con, frame.args.ConBonus, frame.args.Avatar)
    addRow(htmltable, 'Unconventional', frame.args.Uncon, frame.args.UnconBonus, frame.args.Avatar)
    addRow(htmltable, 'Exotic', frame.args.Exo, frame.args.ExoBonus, frame.args.Avatar)
    addRow(htmltable, 'Handiwork', frame.args.Handi, frame.args.HandiBonus, frame.args.Avatar)
    addRow(htmltable, 'Auxiliary', frame.args.Aux, frame.args.AuxBonus, frame.args.Avatar)
    addRow(htmltable, 'Medical', frame.args.Med, frame.args.MedBonus, frame.args.Avatar)
    addRow(htmltable, 'Gen. Knowledge', frame.args.Gen, frame.args.GenBonus, frame.args.Avatar)
 
    -- Add the table to the retString
    retString = retString .. tostring(htmltable)
 
    -- Return the retString, after everything has been processed
    return frame:preprocess(retString)
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.