◆42Lab是非盈利性、非官方的云图计划维基百科。
◆诚邀指挥官们加入编辑部共同建设wiki。点这里加入42Lab
如果您发现某些内容错误/空缺,请勇于修正/添加!参与进来其实很容易!
◆有任何意见、建议、纠错,欢迎在任意评论区评论
◆编辑讨论QQ群741423564 微博@GFwiki少前百科 欢迎您

模块:TestSandbox

来自42LAB

local p = {}

local Data = require("Module:TestSandbox/data")
local AVATAR_LEVEL = Data["AVATAR_LEVEL"]

function p.AvatarLevelTable()
    local buffer = {}
    local TempTotalExp = 0
    local TempGrowth = 0

    buffer[#buffer + 1] = '<table class="wikitable" style="font-size:100%;text-align: center;">'
    buffer[#buffer + 1] = '<th>角色等级</th>'
    buffer[#buffer + 1] = '<th>到下一级所需经验</th>'
    buffer[#buffer + 1] = '<th>累积所需经验</th>'
    buffer[#buffer + 1] = '<th>属性提升系数</th>'
    
    for k,v in ipairs(AVATAR_LEVEL) do
        buffer[#buffer + 1] = '<tr>'
        buffer[#buffer + 1] = '<td>' .. v["CurrentLevel"] .. '</td>'
        buffer[#buffer + 1] = '<td>' .. v["ExpToNextLevel"] .. '</td>'

        TempTotalExp = TempTotalExp + v["ExpToNextLevel"]
        buffer[#buffer + 1] = '<td>' .. TempTotalExp .. '</td>'

        TempGrowth = v["AttributeGrowth"] / 1000000 
        buffer[#buffer + 1] = '<td>' .. TempGrowth .. '</td>'
    end
    
    buffer[#buffer + 1] = '</table>'

    local res = ''
    res = table.concat(buffer)

    return tostring(res)
end

function p.test()
  local s = mw.getCurrentFrame():preprocess('{{#ask:[[分类:算法]]|limit=1000}}')
  local z = ''
  local t = {}
  for i in s:gmatch(':([^|]*)') do
    if not i:find('/') then
      local c = mw.title.new(i):getContent()
      c = c:gsub('算法套装','算法套装|套装名称='..i,1)  

      local id = c:match('id%s*=%s*(%d*)') or -1
      t[#t+1] = {id=tonumber(id), c=c}
    end
  end
  table.sort(t,function(a,b) return a.id < b.id end)
  for i,v in ipairs(t) do
    z = z..v.id..v.c
  end
  return z
end

function p.test2()
  return mw.getCurrentFrame():preprocess(p.test())
end







return p