Module:ChartConstant:修订间差异

(补last的洞 (这洞怎么还在这 我还以为早有人修完了.jpg))
无编辑摘要
第1行: 第1行:
local p = {}
local p = {}
local chartConstantList = require("Module:LoadJson").ChartConstant()
local chartConstantList = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'ChartConstant.json' })
local songlist = require("Module:LoadJson").Songlist()
local songlist = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist.json' })
local trans = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Template:Transition.json' })


 
local function cvFunc()
 
   -- id到曲名的转换表
local function cv()
local list = {}
local list = {}
for i,k in pairs(songlist['songs'])
for i,k in pairs(songlist['songs'])
第28行: 第28行:




local specialSongNameConverter = {
-- local specialSongNameConverter = {
["#1f1e33"] = "#1f1e33",
-- ["#1f1e33"] = "#1f1e33",
    ["AI[UE]OON"] = "AI[UE]OON",
--    ["AI[UE]OON"] = "AI[UE]OON",
    ["Last | Eternity"] = "Last",
--    ["Last | Eternity"] = "Last",
    ["Last | Moment"] = "Last"
--    ["Last | Moment"] = "Last"
}
-- }
local n = {
-- local n = {
    ["Last | Eternity"] = "Last \| Eternity",
--    ["Last | Eternity"] = "Last \| Eternity",
    ["Last | Moment"] = "Last \| Moment"
--    ["Last | Moment"] = "Last \| Moment"
}
-- }
local getArgs = require('Module:Arguments').getArgs
 
function p.main(frame)
   local args = getArgs(frame)
   return p._main(args)
end


function p.main()
function p._main(args)
local list = {}
local firstList = {}
local name
local name, link
local cvList = cv()
local cvList = cvFunc()
-- firstList架构:
-- 以曲目(单难度)为单位,数字型数组
-- {
-- { "" }
-- }
    for i, k in pairs(chartConstantList) do
    for i, k in pairs(chartConstantList) do
     -- 如果曲目定数存在,则使用Songlist查找曲名
    if k[2] or k[3] or k[4] then
    if k[2] or k[3] or k[4] then
    name = cvList[i][1]
    name = cvList[i][1]
     else
       name = i
end
end
     local link = name
      if specialSongNameConverter[name] then
-- 在转换表中查找页面名称
        link = specialSongNameConverter[name]
      if trans["songNameToDisplayName"][name] then
        link = trans["songNameToDisplayName"][name]
else
link = name
      end
      end
if n[name] then
-- if n[name] then
name = n[name]
-- name = n[name]
end
-- end
    if k[2] and tonumber(k[2]['constant'])>=8 and not(k[2]['old']) then
    if k[2] and tonumber(k[2]['constant'])>=8 and not(k[2]['old'])
    table.insert(list, { i, name, k[2]['constant'], "PRS", link, cvList[i][2] })
then
    end
    table.insert(firstList, { i, name, k[2]['constant'], "PRS", link, cvList[i][2] })
   if k[3] and tonumber(k[3]['constant'])>=8 and not(k[3]['old']) then
    elseif k[3] and tonumber(k[3]['constant'])>=8 and not(k[3]['old'])
    table.insert(list, { i, name, k[3]['constant'], "FTR", link, cvList[i][2] })
then
    end
    table.insert(firstList, { i, name, k[3]['constant'], "FTR", link, cvList[i][2] })
   if k[4] and tonumber(k[4]['constant'])>=8 and not(k[4]['old']) then
    elseif k[4] and tonumber(k[4]['constant'])>=8 and not(k[4]['old'])
    if cvList[i][3] then
then
    if cvList[i][3]
then
name = cvList[i][3]
name = cvList[i][3]
end
end
if cvList[i][4] then
if cvList[i][4]
table.insert(list, { i, name, k[4]['constant'], "BYD", link, cvList[i][4] })
then
table.insert(firstList, { i, name, k[4]['constant'], "BYD", link, cvList[i][4] })
else
else
    table.insert(list, { i, name, k[4]['constant'], "BYD", link, cvList[i][2] })
    table.insert(firstList, { i, name, k[4]['constant'], "BYD", link, cvList[i][2] })
end
end
    end
    end
    end
    end
  


-- make lists
-- make lists
   local result = {}
local secondList = {}
    local mid_result = {}
    secondList[11], secondList[12] = {}, {}
   result[11], result[12] = {}, {}
   mid_result[11], mid_result[12] = {}, {}


    for s, k in pairs(list) do
    for s, k in pairs(firstList) do
      if not(mid_result[k[3]]) then mid_result[k[3]]={} end
      if not(secondList[k[3]]) then secondList[k[3]]={} end
      if k[3]>=11 then
      if k[3]>=11 
then
        if k[3]>=12 then
        if k[3]>=12 then
          table.insert(mid_result[12], k)
          table.insert(secondList[12], k)
        else
        else
          table.insert(mid_result[11], k)
          table.insert(secondList[11], k)
        end
        end
      else table.insert(mid_result[k[3]], k) end
      else 
table.insert(secondList[k[3]], k) 
end
    end
    end




    -- sort songs
    -- sort songs
    local diffConverter = { PRS=2, FTR=3, BYD=4 }
    -- local diffConverter = { PRS=2, FTR=3, BYD=4 }
    for s, k in pairs(mid_result) do
    for s, k in pairs(secondList) do
      table.sort(k, function (a, b)
      table.sort(k, function (a, b)
        if not(a[3]==b[3]) then
        if not(a[3]==b[3]) then
第107行: 第128行:
    end
    end


local result = {}
   result[11], result[12] = {}, {}


-- use template
-- use template
-- 组排单元 第一个参数是曲名,第二个是id,第三个是难度,link字面意思
-- 组排单元 第一个参数是曲名,第二个是id,第三个是难度,link字面意思
    for s, k in pairs(mid_result) do
    for s, k in pairs(secondList) do
    if s<11 then
    if s<11 then
   if not(result[s]) then result[s]={} end
   if not(result[s]) then result[s]={} end