Module:Base stats

-- local p   = {} local lib      = require('Module:Feature') local json     = require('Module:JSON') local cmd      = require('Module:Maintenance data') local userError = require('Dev:User error') local IL       = require('Module:ImageLink')

function p.get(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end local patchid    = args[3] or cmd.main{"PatchId"} local luadata    = loadData(patchid) local stat       = args[1] local lvl        = args[2] local s          = "" local stats  = {} for champname, champdata in pairs(luadata) do           base=tonumber(pst2(champname,stat.."_base",frame)) or tonumber(pst2(champname,stat,frame)) xlvl=tonumber(pst2(champname,stat.."_lvl",frame)) or 0 if stat=="as" then as_lvl1=tonumber(pst2(champname,"as_lvl1",frame)) or tonumber(pst2(champname,"as_base",frame)) table.insert(stats,{champname, as_lvl1+base*xlvl/100*(lvl-1)*(0.7025+0.0175*(lvl-1))}) else table.insert(stats,{champname, base+xlvl*(lvl-1)*(0.7025+0.0175*(lvl-1))}) end end table.sort(stats, function(a, b) return a[2]=1 do           if j==#stats then s=s.." ☂ "..stats[#stats][1] else if stats[j][2]==stats[j+1][2] then s=s..", "..stats[j][1] else k=k+1 if k==11 then break end s=s.." ☂ "..stats[j][1] end end j=j-1 end return s end

function loadData(patchid) if exists('Module:StatTable/data/' .. patchid) then return mw.loadData('Module:StatTable/data/' .. patchid) end return nil end

function exists(page) local sPage = page if sPage then local _, val = pcall(package.loaders[2], sPage) if type(val) == "function" or type(val) == "string" then return true end end return false end

function pst2(champion, stat, frame) return frame:expandTemplate{ title = 'Data '.. champion, args = {'pst2', stat} } end

function comp(a, b)       if a[2] == b[2] then return a[1]<b[1] end end return p --