FANDOM


-- Taken from [[en:Module:Stat calculator]]
-- Credits to Summoners War Wiki in English.
 
local p = {}
 
function round(n)
    return n % 1 >= 0.5 and math.ceil(n) or math.floor(n)
 
end
 
function p.calculator(frame)
    ----------------------------------
    ----Initialise Stats/Variables----
    ----------------------------------
    local grades = mw.loadData( 'Module:Estadísticas/Grados' )
    local unawk_grade = grades[frame.args[1]]
    local awk_grade = unawk_grade + 1
    local can_awk = frame.args[2]
 
    local unawk_hp = tonumber(frame.args[3])
    if unawk_hp == nil then
        unawk_hp = 0
    end
 
    local unawk_atk = tonumber(frame.args[4])
    if unawk_atk == nil then
        unawk_atk = 0
    end
 
    local unawk_def = tonumber(frame.args[5])
    if unawk_def == nil then
        unawk_def = 0
    end
 
    local awk_hp = tonumber(frame.args[6])
    if awk_hp == nil then
        awk_hp = 0
    end
 
    local awk_atk = tonumber(frame.args[7])
    if awk_atk == nil then
        awk_atk = 0
    end
 
    local awk_def = tonumber(frame.args[8])
    if awk_def == nil then
        awk_def = 0
    end
    --------------------------
    ----End Initialization----
    --------------------------
    --Weighted Stats and firstTermValues for unawakened:--
    local unawk_wstat = unawk_hp / 15 + unawk_atk + unawk_def
    local unawk_hpFrac = unawk_hp / 15 * (105 + (15 * unawk_grade))
    local unawk_atkFrac = unawk_atk * (105 + (15 * unawk_grade))
    local unawk_defFrac = unawk_def * (105 + (15 * unawk_grade))
 
    local unawk_hpBase = round(unawk_hpFrac / unawk_wstat)
    local unawk_atkBase = round(unawk_atkFrac / unawk_wstat)
    local unawk_defBase = round(unawk_defFrac / unawk_wstat)
 
    --Weighted Stats and firstTermValues for awakened:--
    local awk_wstat = awk_hp / 15 + awk_atk + awk_def
    local awk_hpFrac = awk_hp / 15 * (105 + (15 * awk_grade))
    local awk_atkFrac = awk_atk * (105 + (15 * awk_grade))
    local awk_defFrac = awk_def * (105 + (15* awk_grade))
 
    local awk_hpBase = round(awk_hpFrac / awk_wstat)
    local awk_atkBase = round(awk_atkFrac / awk_wstat)
    local awk_defBase = round(awk_defFrac / awk_wstat)
 
    -------------------
    ----Multipliers----
    -------------------
    local maxStarMtp = {1, 1.5966, 2.4242774, 3.4914444, 4.7529032, 6.4582449}
    local levelMtp = {1.9958, 1.8981, 1.8003, 1.7017, 1.6984, 1.7000}
 
    local min1 = 1
    local max1 = min1 * 1.9958 
    local min2 = 1.5966   
    local max2 = min2 * 1.8981 
    local min3 = 2.4242774 
    local max3 = min3 * 1.8003 
    local min4 = 3.4914444  
    local max4 = min4 * 1.7017 
    local min5 = 4.7529032
    local max5 = min5 * 1.6984
    local min6 = 6.4582449 
    local max6 = min6 * 1.7000  
 
    ----------------------
    ---- Stat Results ----
    ----------------------
 
    --Unawakened HP--
    local unawk_HP1min = frame.args[9]
    if unawk_HP1min == '' then
        unawk_HP1min = 15 * round(unawk_hpBase * min1)
    end
 
    local unawk_HP1max = frame.args[10]
    if unawk_HP1max == '' then
        unawk_HP1max = 15 * round(unawk_hpBase * max1)
    end
 
    local unawk_HP2min = frame.args[11]
    if unawk_HP2min == '' then
        unawk_HP2min = 15 * round(unawk_hpBase * min2)
    end
 
    local unawk_HP2max = frame.args[12]
    if unawk_HP2max == '' then
        unawk_HP2max = 15 * round(unawk_hpBase * max2)
    end
 
    local unawk_HP3min = frame.args[13]
    if unawk_HP3min == '' then
        unawk_HP3min = 15 * round(unawk_hpBase * min3)
    end
 
    local unawk_HP3max = frame.args[14]
    if unawk_HP3max == '' then
        unawk_HP3max = 15 * round(unawk_hpBase * max3)
    end
 
    local unawk_HP4min = frame.args[15]
    if unawk_HP4min == '' then
        unawk_HP4min = 15 * round(unawk_hpBase * min4)
    end
 
    local unawk_HP4max = frame.args[16]
    if unawk_HP4max == '' then
        unawk_HP4max = 15 * round(unawk_hpBase * max4)
    end
 
    local unawk_HP5min = frame.args[17]
    if unawk_HP5min == '' then
        unawk_HP5min = 15 * round(unawk_hpBase * min5)
    end
 
    local unawk_HP5max = frame.args[18]
    if unawk_HP5max == '' then
        unawk_HP5max = 15 * round(unawk_hpBase * max5)
    end
 
    local unawk_HP6min = frame.args[19]
    if unawk_HP6min == '' then
        unawk_HP6min = 15 * round(unawk_hpBase * min6)
    end
 
    local unawk_HP6max = frame.args[20]
    if unawk_HP6max == '' then
        unawk_HP6max = 15 * round(unawk_hpBase * max6)
    end
 
    --Unawakened ATK--
    local unawk_ATK1min = frame.args[21]
    if unawk_ATK1min == '' then
        unawk_ATK1min = round(unawk_atkBase * min1)
    end
 
    local unawk_ATK1max = frame.args[22]
    if unawk_ATK1max == '' then
        unawk_ATK1max = round(unawk_atkBase * max1)
    end
 
    local unawk_ATK2min = frame.args[23]
    if unawk_ATK2min == '' then
        unawk_ATK2min = round(unawk_atkBase * min2)
    end
 
    local unawk_ATK2max = frame.args[24]
    if unawk_ATK2max == '' then
        unawk_ATK2max = round(unawk_atkBase * max2)
    end
 
    local unawk_ATK3min = frame.args[25]
    if unawk_ATK3min == '' then
        unawk_ATK3min = round(unawk_atkBase * min3)
    end
 
    local unawk_ATK3max = frame.args[26]
    if unawk_ATK3max == '' then
        unawk_ATK3max = round(unawk_atkBase * max3)
    end
 
    local unawk_ATK4min = frame.args[27]
    if unawk_ATK4min == '' then
        unawk_ATK4min = round(unawk_atkBase * min4)
    end
 
    local unawk_ATK4max = frame.args[28]
    if unawk_ATK4max == '' then
        unawk_ATK4max = round(unawk_atkBase * max4)
    end
 
    local unawk_ATK5min = frame.args[29]
    if unawk_ATK5min == '' then
        unawk_ATK5min = round(unawk_atkBase * min5)
    end
 
    local unawk_ATK5max = frame.args[30]
    if unawk_ATK5max == '' then
        unawk_ATK5max = round(unawk_atkBase * max5)
    end
 
    local unawk_ATK6min = frame.args[31]
    if unawk_ATK6min == '' then
        unawk_ATK6min = round(unawk_atkBase * min6)
    end
 
    local unawk_ATK6max = frame.args[32]
    if unawk_ATK6max == '' then
        unawk_ATK6max = round(unawk_atkBase * max6)
    end
 
 
    --Unawakened DEF--
    local unawk_DEF1min = frame.args[33]
    if unawk_DEF1min == '' then
        unawk_DEF1min = round(unawk_defBase * min1)
    end
 
    local unawk_DEF1max = frame.args[34]
    if unawk_DEF1max == '' then
        unawk_DEF1max = round(unawk_defBase * max1)
    end
 
    local unawk_DEF2min = frame.args[35]
    if unawk_DEF2min == '' then
        unawk_DEF2min = round(unawk_defBase * min2)
    end
 
    local unawk_DEF2max = frame.args[36]
    if unawk_DEF2max == '' then
        unawk_DEF2max = round(unawk_defBase * max2)
    end
 
    local unawk_DEF3min = frame.args[37]
    if unawk_DEF3min == '' then
        unawk_DEF3min = round(unawk_defBase * min3)
    end
 
    local unawk_DEF3max = frame.args[38]
    if unawk_DEF3max == '' then
        unawk_DEF3max = round(unawk_defBase * max3)
    end
 
    local unawk_DEF4min = frame.args[39]
    if unawk_DEF4min == '' then
        unawk_DEF4min = round(unawk_defBase * min4)
    end
 
    local unawk_DEF4max = frame.args[40]
    if unawk_DEF4max == '' then
        unawk_DEF4max = round(unawk_defBase * max4)
    end
 
    local unawk_DEF5min = frame.args[41]
    if unawk_DEF5min == '' then
        unawk_DEF5min = round(unawk_defBase * min5)
    end
 
    local unawk_DEF5max = frame.args[42]
    if unawk_DEF5max == '' then
        unawk_DEF5max = round(unawk_defBase * max5)
    end
 
    local unawk_DEF6min = frame.args[43]
    if unawk_DEF6min == '' then
        unawk_DEF6min = round(unawk_defBase * min6)
    end
 
    local unawk_DEF6max = frame.args[44]
    if unawk_DEF6max == '' then
        unawk_DEF6max = round(unawk_defBase * max6)
    end
 
    --Awakened HP--
    local awk_HP1min = frame.args[45]
    if awk_HP1min == '' then
        awk_HP1min = 15 * round(awk_hpBase * min1)
    end
 
    local awk_HP1max = frame.args[46]
    if awk_HP1max == '' then
        awk_HP1max = 15 * round(awk_hpBase * max1)
    end
 
    local awk_HP2min = frame.args[47]
    if awk_HP2min == '' then
        awk_HP2min = 15 * round(awk_hpBase * min2)
    end
 
    local awk_HP2max = frame.args[48]
    if awk_HP2max == '' then
        awk_HP2max = 15 * round(awk_hpBase * max2)
    end
 
    local awk_HP3min = frame.args[49]
    if awk_HP3min == '' then
        awk_HP3min = 15 * round(awk_hpBase * min3)
    end
 
    local awk_HP3max = frame.args[50]
    if awk_HP3max == '' then
        awk_HP3max = 15 * round(awk_hpBase * max3)
    end
 
    local awk_HP4min = frame.args[51]
    if awk_HP4min == '' then
        awk_HP4min = 15 * round(awk_hpBase * min4)
    end
 
    local awk_HP4max = frame.args[52]
    if awk_HP4max == '' then
        awk_HP4max = 15 * round(awk_hpBase * max4)
    end
 
    local awk_HP5min = frame.args[53]
    if awk_HP5min == '' then
        awk_HP5min = 15 * round(awk_hpBase * min5)
    end
 
    local awk_HP5max = frame.args[54]
    if awk_HP5max == '' then
        awk_HP5max = 15 * round(awk_hpBase * max5)
    end
 
    local awk_HP6min = frame.args[55]
    if awk_HP6min == '' then
        awk_HP6min = 15 * round(awk_hpBase * min6)
    end
 
    local awk_HP6max = frame.args[56]
    if awk_HP6max == '' then
        awk_HP6max = 15 * round(awk_hpBase * max6)
    end
 
    --Awakened ATK--
    local awk_ATK1min = frame.args[57]
    if awk_ATK1min == '' then
        awk_ATK1min = round(awk_atkBase * min1)
    end
 
    local awk_ATK1max = frame.args[58]
    if awk_ATK1max == '' then
        awk_ATK1max = round(awk_atkBase * max1)
    end
 
    local awk_ATK2min = frame.args[59]
    if awk_ATK2min == '' then
        awk_ATK2min = round(awk_atkBase * min2)
    end
 
    local awk_ATK2max = frame.args[60]
    if awk_ATK2max == '' then
        awk_ATK2max = round(awk_atkBase * max2)
    end
 
    local awk_ATK3min = frame.args[61]
    if awk_ATK3min == '' then
        awk_ATK3min = round(awk_atkBase * min3)
    end
 
    local awk_ATK3max = frame.args[62]
    if awk_ATK3max == '' then
        awk_ATK3max = round(awk_atkBase * max3)
    end
 
    local awk_ATK4min = frame.args[63]
    if awk_ATK4min == '' then
        awk_ATK4min = round(awk_atkBase * min4)
    end
 
    local awk_ATK4max = frame.args[64]
    if awk_ATK4max == '' then
        awk_ATK4max = round(awk_atkBase * max4)
    end
 
    local awk_ATK5min = frame.args[65]
    if awk_ATK5min == '' then
        awk_ATK5min = round(awk_atkBase * min5)
    end
 
    local awk_ATK5max = frame.args[66]
    if awk_ATK5max == '' then
        awk_ATK5max = round(awk_atkBase * max5)
    end
 
    local awk_ATK6min = frame.args[67]
    if awk_ATK6min == '' then
        awk_ATK6min = round(awk_atkBase * min6)
    end
 
    local awk_ATK6max = frame.args[68]
    if awk_ATK6max == '' then
        awk_ATK6max = round(awk_atkBase * max6)
    end
 
    --Awakened DEF--
    local awk_DEF1min = frame.args[69]
    if awk_DEF1min == '' then
        awk_DEF1min = round(awk_defBase * min1)
    end
 
    local awk_DEF1max = frame.args[70]
    if awk_DEF1max == '' then
        awk_DEF1max = round(awk_defBase * max1)
    end
 
    local awk_DEF2min = frame.args[71]
    if awk_DEF2min == '' then
        awk_DEF2min = round(awk_defBase * min2)
    end
 
    local awk_DEF2max = frame.args[72]
    if awk_DEF2max == '' then
        awk_DEF2max = round(awk_defBase * max2)
    end
 
    local awk_DEF3min = frame.args[73]
    if awk_DEF3min == '' then
        awk_DEF3min = round(awk_defBase * min3)
    end
 
    local awk_DEF3max = frame.args[74]
    if awk_DEF3max == '' then
        awk_DEF3max = round(awk_defBase * max3)
    end
 
    local awk_DEF4min = frame.args[75]
    if awk_DEF4min == '' then
        awk_DEF4min = round(awk_defBase * min4)
    end
 
    local awk_DEF4max = frame.args[76]
    if awk_DEF4max == '' then
        awk_DEF4max = round(awk_defBase * max4)
    end
 
    local awk_DEF5min = frame.args[77]
    if awk_DEF5min == '' then
        awk_DEF5min = round(awk_defBase * min5)
    end
 
    local awk_DEF5max = frame.args[78]
    if awk_DEF5max == '' then
        awk_DEF5max = round(awk_defBase * max5)
    end
 
    local awk_DEF6min = frame.args[79]
    if awk_DEF6min == '' then
        awk_DEF6min = round(awk_defBase * min6)
    end
 
    local awk_DEF6max = frame.args[80]
    if awk_DEF6max == '' then
        awk_DEF6max = round(awk_defBase * max6)
    end
 
    ---------------------------------
    ----Variables End/Table Begin----
    ---------------------------------
    local not_obtainable = frame.args[81]
 
    if not_obtainable ~= 'Y' and not_obtainable ~= 'y' then
        result = 
        '{| class="estadísticas"\n' ..
        '! colspan="2" | Grado\n'
 
        if unawk_grade == 1 then
            result = result .. '! colspan="2" | ★\n'
        end
        if unawk_grade <=2 then
            result = result .. '! colspan="2" | ★★\n'
        end
        if unawk_grade <=3 then
            result = result .. '! colspan="2" | ★★★\n'
        end
        if unawk_grade <=4 then
            result = result .. '! colspan="2" | ★★★★\n'
        end
 
        result = result .. 
        '! colspan="2" | ★★★★★\n' ..
        '! colspan="2" | ★★★★★★\n' ..
        '|-\n' .. 
        '! colspan="2" | Nivel\n'
 
        if unawk_grade == 1 then
            result = result .. 
            '! Nivel 1\n' ..
            '! Nivel 15\n'
        end
        if unawk_grade <=2 then
            result = result .. 
            '! Nivel 1\n'  ..
            '! Nivel 20\n'
        end
        if unawk_grade <=3 then
            result = result .. 
            '! Nivel 1\n' .. 
            '! Nivel 25\n'
        end
        if unawk_grade <=4 then
            result = result .. 
            '! Nivel 1\n' .. 
            '! Nivel 30\n'
        end
        result = result .. 
        '! Nivel 1\n' ..
        '! Nivel 35\n' ..
        '! Nivel 1\n' ..
        '! Nivel 40\n'
 
        if can_awk ~= '' then
            result = result .. 
            '|-\n' ..
            '! rowspan="4" | Normal\n' ..
            '|-\n' ..
            '! HP\n'
        else
            result = result .. 
            '|-\n' ..
            '! colspan="2" | HP\n'
        end
 
        if unawk_grade == 1 then
            result = result ..
            '| ' .. unawk_HP1min .. '\n' ..
            '| ' .. unawk_HP1max .. '\n'
        end
        if unawk_grade <=2 then
            result = result ..
            '| ' .. unawk_HP2min .. '\n' ..
            '| ' .. unawk_HP2max .. '\n'
        end
        if unawk_grade <=3 then
            result = result .. 
            '| ' .. unawk_HP3min .. '\n' ..
            '| ' .. unawk_HP3max .. '\n'
        end
        if unawk_grade <=4 then
            result = result ..
            '| ' .. unawk_HP4min .. '\n' ..
            '| ' .. unawk_HP4max .. '\n'
        end
 
        result = result ..
        '| ' .. unawk_HP5min .. '\n' ..
        '| ' .. unawk_HP5max .. '\n' ..
        '| ' .. unawk_HP6min .. '\n' ..
        '| ' .. unawk_HP6max .. '\n'
 
        if can_awk ~= '' then
            result = result .. 
            '|-\n' .. 
            '! ATQ\n'
        else
            result = result .. 
            '|-\n' .. 
            '! colspan="2" | ATQ\n'
        end
 
        if unawk_grade == 1 then
            result = result ..
            '| ' .. unawk_ATK1min .. '\n' ..
            '| ' .. unawk_ATK1max .. '\n'
        end
        if unawk_grade <=2 then
            result = result ..
            '| ' .. unawk_ATK2min .. '\n' ..
            '| ' .. unawk_ATK2max .. '\n'
        end
        if unawk_grade <=3 then
            result = result .. 
            '| ' .. unawk_ATK3min .. '\n' ..
            '| ' .. unawk_ATK3max .. '\n'
        end
        if unawk_grade <=4 then
            result = result ..
            '| ' .. unawk_ATK4min .. '\n' ..
            '| ' .. unawk_ATK4max .. '\n'
        end
 
        result = result ..
        '| ' .. unawk_ATK5min .. '\n' ..
        '| ' .. unawk_ATK5max .. '\n' ..
        '| ' .. unawk_ATK6min .. '\n' ..
        '| ' .. unawk_ATK6max .. '\n'
 
        if can_awk ~= '' then
            result = result .. 
            '|-\n' .. 
            '! DEF\n'
        else
            result = result .. 
            '|-\n' .. 
            '! colspan="2" | DEF\n'
        end
 
        if unawk_grade == 1 then
            result = result ..
            '| ' .. unawk_DEF1min .. '\n' ..
            '| ' .. unawk_DEF1max .. '\n'
        end
        if unawk_grade <=2 then
            result = result ..
            '| ' .. unawk_DEF2min .. '\n' ..
            '| ' .. unawk_DEF2max .. '\n'
        end
        if unawk_grade <=3 then
            result = result .. 
            '| ' .. unawk_DEF3min .. '\n' ..
            '| ' .. unawk_DEF3max .. '\n'
        end
        if unawk_grade <=4 then
            result = result ..
            '| ' .. unawk_DEF4min .. '\n' ..
            '| ' .. unawk_DEF4max .. '\n'
        end
 
            result = result ..
        '| ' .. unawk_DEF5min .. '\n' ..
        '| ' .. unawk_DEF5max .. '\n' ..
        '| ' .. unawk_DEF6min .. '\n' ..
        '| ' .. unawk_DEF6max .. '\n'
 
 
        if can_awk ~= '' then
            result = result .. 
            '|-\n' .. 
            '! rowspan="4" | Despierto\n' ..
            '|-\n' ..
            '! HP\n'
 
            if unawk_grade == 1 then
                result = result ..
                '| ' .. awk_HP1min .. '\n' ..
                '| ' .. awk_HP1max .. '\n'
            end
            if unawk_grade <=2 then
                result = result ..
                '| ' .. awk_HP2min .. '\n' ..
                '| ' .. awk_HP2max .. '\n'
            end
            if unawk_grade <=3 then
                result = result .. 
                '| ' .. awk_HP3min .. '\n' ..
                '| ' .. awk_HP3max .. '\n'
            end
            if unawk_grade <=4 then
                result = result ..
                '| ' .. awk_HP4min .. '\n' ..
                '| ' .. awk_HP4max .. '\n'
            end
 
            result = result ..
            '| ' .. awk_HP5min .. '\n' ..
            '| ' .. awk_HP5max .. '\n' ..
            '| ' .. awk_HP6min .. '\n' ..
            '| ' .. awk_HP6max .. '\n' ..
            '|-\n' ..
            '! ATQ\n'
 
            if unawk_grade == 1 then
                result = result ..
                '| ' .. awk_ATK1min .. '\n' ..
                '| ' .. awk_ATK1max .. '\n'
            end
            if unawk_grade <=2 then
                result = result ..
                '| ' .. awk_ATK2min .. '\n' ..
                '| ' .. awk_ATK2max .. '\n'
            end
            if unawk_grade <=3 then
                result = result .. 
                '| ' .. awk_ATK3min .. '\n' ..
                '| ' .. awk_ATK3max .. '\n'
            end
            if unawk_grade <=4 then
                result = result ..
                '| ' .. awk_ATK4min .. '\n' ..
                '| ' .. awk_ATK4max .. '\n'
            end
 
            result = result ..
            '| ' .. awk_ATK5min .. '\n' ..
            '| ' .. awk_ATK5max .. '\n' ..
            '| ' .. awk_ATK6min .. '\n' ..
            '| ' .. awk_ATK6max .. '\n' ..
            '|-\n' ..
            '! DEF\n'
 
            if unawk_grade == 1 then
                result = result ..
                '| ' .. awk_DEF1min .. '\n' ..
                '| ' .. awk_DEF1max .. '\n'
            end
            if unawk_grade <=2 then
                result = result ..
                '| ' .. awk_DEF2min .. '\n' ..
                '| ' .. awk_DEF2max .. '\n'
            end
            if unawk_grade <=3 then
                result = result .. 
                '| ' .. awk_DEF3min .. '\n' ..
                '| ' .. awk_DEF3max .. '\n'
            end
            if unawk_grade <=4 then
                result = result ..
                '| ' .. awk_DEF4min .. '\n' ..
                '| ' .. awk_DEF4max .. '\n'
            end
 
            result = result ..
            '| ' .. awk_DEF5min .. '\n' ..
            '| ' .. awk_DEF5max .. '\n' ..
            '| ' .. awk_DEF6min .. '\n' ..
            '| ' .. awk_DEF6max .. '\n' 
 
        end
 
        result = result .. 
        '|}'
 
 
        return result
 
    end
 
 
end
 
 
return p

¡Interferencia de bloqueo de anuncios detectada!


Wikia es un sitio libre de uso que hace dinero de la publicidad. Contamos con una experiencia modificada para los visitantes que utilizan el bloqueo de anuncios

Wikia no es accesible si se han hecho aún más modificaciones. Si se quita el bloqueador de anuncios personalizado, la página cargará como se esperaba.