|
|
(未显示同一用户的1个中间版本) |
第1行: |
第1行: |
| local p = {} | | local p = { single = { idx = -100, name = "Memory Archive" } } |
| local W = mw
| | local plst = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate { title = "packlist" }).packs |
| local cfg = {
| | local special = { base = true, omatsuri = true, observer = true } |
| prior = {single = 16383},
| | for i, v in ipairs(plst) do |
| name = {single = 'Memory Archive'},
| | local co = v.custom_banner and not special[v.id] |
| contest_set = {['base'] = true, ['observer'] = true, ['omatsuri'] = true},
| | local name = v.name_localized.en |
| mbIcon = '[[文件:Icon Smartphone.png|16px|link=曲目列表 (移动版)]]',
| | if co then name = name .. " Collaboration" end |
| nsIcon = '[[文件:Icon Nintendo switch.png|16px|link=曲目列表 (Nintendo Switch版)]]',
| | if (p[v.pack_parent or ""] or p.single).name:find " Collaboration" then |
| NS_byd_set = {['tempestissimo'] = true},
| | name = p[v.pack_parent].name .. " - " .. name |
| display = {
| |
| ['ifi'] = '#1f1e33',
| |
| ['aiueoon'] = 'AI[UE]OON',
| |
| ['quon'] = 'Quon (Feryquitous)',
| |
| ['quonwacca'] = 'Quon (DJ Noriken)'
| |
| }
| |
| }
| |
| | |
| function LoadJson(filename)
| |
| return W.text.jsonDecode(W.getCurrentFrame():expandTemplate{ title = filename })
| |
| end
| |
| | |
| local packPrior, packName = (function() | |
| local P, N = cfg.prior, cfg.name
| |
| local conbine = function(rt, lf) return string.format('%s#%s - %s|%s - %s', rt, rt, lf, rt, lf) end
| |
| local exs = function(t)
| |
| local p=t[3]
| |
| t[3]=t[4]
| |
| t[4]=p
| |
| return t
| |
| end
| |
| for i, v in ipairs(exs(LoadJson("packlist").packs)) do
| |
| P[v.id] = i
| |
| N[v.id] = v.name_localized.en
| |
| if v.pack_parent then
| |
| P[v.id] = P[v.pack_parent]
| |
| N[v.id] = conbine(N[v.pack_parent], N[v.id])
| |
| elseif v.custom_banner and not cfg.contest_set[v.id] then
| |
| N[v.id] = N[v.id] .. ' Collaboration'
| |
| end
| |
| end | |
| for i, v in ipairs(LoadJson("packlist NS").packs) do
| |
| if not N[v.id] and v.pack_parent then -- single-append
| |
| P[v.id] = P[v.pack_parent]
| |
| N[v.id] = conbine(N[v.pack_parent], v.name_localized.en)
| |
| end
| |
| end | |
| for i, v in pairs(N) do N[i] = string.format('[[%s]]', v) end
| |
| return P, N
| |
| end)()
| |
| | |
| local songLines, songList = (function()
| |
| -- ruin field: plat, title, NS_pack_alt_suffix
| |
| local MP, LS, LST = {}, {}, {}
| |
| local mbMark, nsMark = W.getCurrentFrame():expandTemplate{
| |
| title = '仅',
| |
| args = {'移动版', '', '图片角标'}
| |
| }, W.getCurrentFrame():expandTemplate{
| |
| title = '仅',
| |
| args = {'NS版', '', '图片角标'}
| |
| }
| |
| for i, v in ipairs(LoadJson("songlist").songs) do
| |
| v.__plat = {cfg.mbIcon}
| |
| MP[v.id] = v
| |
| end
| |
| for i, v in pairs(cfg.display) do MP[i].__title = v end | |
| for i, v in ipairs(LoadJson("songlist NS").songs) do
| |
| if MP[v.id] then
| |
| table.insert(MP[v.id].__plat, cfg.nsIcon)
| |
| if MP[v.id].set ~= v.set then
| |
| MP[v.id].__NS_pack_alt_suffix = table.concat{mbMark, '<br />', packName[v.set], nsMark}
| |
| end
| |
| else
| |
| v.__plat = {cfg.nsIcon}
| |
| MP[v.id] = v
| |
| end
| |
| end
| |
| for i, v in pairs(MP) do
| |
| local norm,page = pcall(function()return W.title.new(v.__title or v.title_localized.en):getContent() end)
| |
| if norm then
| |
| table.insert(LST, i)
| |
| local title = '[[' .. (v.__title and v.__title .. '|' or '') .. v.title_localized.en .. ']]'
| |
| local second = v.title_localized.ja or v.title_localized['zh-Hans']
| |
| if second then title = title .. '<br /><span lang="ja">-{' .. second .. '}-</span>' end
| |
| local dur = page:match("时长%s*=%s*0?(%d:%d%d)")
| |
| local pack = packName[v.set] .. (v.__NS_pack_alt_suffix or '')
| |
| local bpm, rate = v.bpm, ''
| |
| if not tonumber(bpm) then
| |
| bpm = 'data-sort-value=' .. v.bpm_base .. '|' .. bpm
| |
| end
| |
| | |
| for j, d in ipairs(v.difficulties) do
| |
| rate = rate .. '||' .. d.rating
| |
| if d.ratingPlus then rate = rate .. '+' end
| |
| end
| |
| if v.difficulties[4] then
| |
| if not cfg.NS_byd_set[v.id] then rate = rate .. mbMark end
| |
| else
| |
| rate = rate .. '||/'
| |
| end
| |
| LS[i] = string.format(
| |
| '|%s\n|[[文件:Songs %s.jpg|75px]]\n|%s\n|<span lang="ja">-{%s}-</span>\n|%s\n|%s\n|0%s\n%s\n|-\n',
| |
| table.concat(v.__plat), v.id, title, v.artist, pack, bpm, dur, rate:sub(2))
| |
| end | |
| end
| |
| table.sort(LST, function(a, b)
| |
| if packPrior[MP[a].set] ~= packPrior[MP[b].set] then
| |
| return packPrior[MP[a].set] < packPrior[MP[b].set]
| |
| else
| |
| return MP[a].date < MP[b].date
| |
| end
| |
| end)
| |
| return LS, LST
| |
| end)()
| |
| | |
| function p.main(frames)
| |
| local chart = ''
| |
| for i, v in ipairs(songList) do chart = chart .. songLines[v] end
| |
| chart=chart..'|'..cfg.mbIcon..cfg.nsIcon..'\n|[[文件:Songs tutorial.jpg|75px]]\n|[[Tutorial]]\n|<span lang="ja">ak+q</span>\n|/\n|128\n|02:07\n|1\n|4\n|/\n|/\n|-\n'
| |
| for i,v in ipairs(frames.args) do
| |
| local text=W.title.new(v):getContent()
| |
| local dur=text:match('%d:%d%d')
| |
| local artist=text:match('(%[%[曲师列表[^<]+)</div>'):gsub('%[%[',''):gsub('%]%]',''):gsub('曲师列表#[^|]+%|','')
| |
| local bpm=text:match('BPM</div>\n<div class="data">([^<]+)</div>')
| |
| chart=chart..string.format('|%s\n|[[文件:Songs %s.jpg|75px]]\n|[[%s]]\n|<span lang="ja">-{%s}-</span>\n|/\n|%s\n|0%s\n|/\n|/\n|?\n|/\n|-\n',cfg.mbIcon,v:gsub('%A+',''):lower(),v,artist,bpm,dur)
| |
| end | | end |
| return chart | | p[v.id] = { idx = i, name = name } |
| end | | end |
|
| |
| return p | | return p |