跳至內容

「Module:Unlock」:修訂間差異

增加 107 位元組 、​ 2024年1月18日 (星期四)
摩耶
(fix)
(摩耶)
第1行: 第1行:
local p = {}
local p = {}
local slstIdx = mw.loadData "Module:songlist index".slstIdx
local slstIdx = mw.loadData 'Module:songlist index'.slstIdx
local unlocks = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate { title = "unlocks.json" }).unlocks;
local unlocks = mw.text.jsonDecode(mw.title.new 'Template:unlocks.json':getContent()).unlocks;
(function(u) u[14], u[15], u[16], u[17] = u[16], u[14], u[17], u[15]; table.insert(u, { songId = "" }) end)(unlocks)
(function(u)u[14], u[15], u[16], u[17] = u[16], u[14], u[17], u[15]; table.insert(u, {songId = ''})end)(unlocks)


local eDifficulty = {[0] = 'PST', 'PRS', 'FTR', 'BYD'}
local eGrade = {'C', 'B', 'A', 'AA', 'EX'}
local mPartner = {[45] = '拉格兰', [71] = '摩耶'}
p.condition = setmetatable({
p.condition = setmetatable({
song_id = function(v) return "[[" .. slstIdx[v].title .. "]]" end,
song_id = function(v) return '[[' .. slstIdx[v].title .. ']]' end,
song_difficulty = function(v) return "[" .. ({ [0] = "PST", "PRS", "FTR", "BYD" })[v] .. "]" end,
song_difficulty = function(v) return '[' .. eDifficulty[v] .. ']' end,
grade = function(v) return v == 0 and "" or (" 以 「%s」 或以上成绩"):format(({ "C", "B", "A", "AA", "EX" })[v]) end,
grade = function(v) return v == 0 and '' or (' 以 「%s」 或以上成绩'):format(eGrade[v]) end,
rating = function(v) return v > 15 and ("%.2f"):format(v / 100) or v end,
rating = function(v) return v > 15 and ('%.2f'):format(v / 100) or v end,
id = function() return "[[ 拉格兰]]" end,
id = function(v) return '[[' .. mPartner[v] .. ']]' end,
ratingPlus = function(v) return v and "+" or "" end,
ratingPlus = function(v) return v and '+' or '' end,
[0] = "$credit 残片",
[0] = '$credit 残片',
"$grade通关 $song_id $song_difficulty",
'$grade通关 $song_id $song_difficulty',
" 游玩 $song_id $song_difficulty",
' 游玩 $song_id $song_difficulty',
"$grade通关 $song_id $song_difficulty$times回",
'$grade通关 $song_id $song_difficulty$times回',
"$1 <br>'''或''' $2",
"$1 <br>'''或''' $2",
" 个人游玩潜力值 $rating 或以上",
' 个人游玩潜力值 $rating 或以上',
" 通关$count首$rating$ratingPlus难度曲目",
' 通关$count首$rating$ratingPlus难度曲目',
[103] = " 获得搭档「$id」"
[103] = ' 获得搭档「$id」'
}, {
}, {
__call = function(self, args)
__call = function(self, args)
return (string.gsub(self[args.type] or "", "%$[a-zA-Z12_]+", function(k)
return (string.gsub(self[args.type] or '', '%$[a-zA-Z12_]+', function(k)
k = k:sub(2)
k = k:sub(2)
if self[k] then return self[k](args[k]) end
if self[k] then return self[k](args[k]) end
第33行: 第36行:
local i, key = 1, nil
local i, key = 1, nil
return function()
return function()
if ware[i].songId == "" then return end
if ware[i].songId == '' then return end
local arr = {}
local arr = {}
key = ware[i].songId
key = ware[i].songId
第40行: 第43行:
i = i + 1
i = i + 1
until ware[i].songId ~= key
until ware[i].songId ~= key
if ware[i].songId == "lasteternity" then i = i + 4 end --
if ware[i].songId == 'lasteternity' then i = i + 4 end --
return key, arr
return key, arr
end
end
第50行: 第53行:
local r = {}
local r = {}
for _, v in ipairs(songv or {}) do table.insert(r, p.condition(v)) end
for _, v in ipairs(songv or {}) do table.insert(r, p.condition(v)) end
return table.concat(r, "<br>")
return table.concat(r, '<br>')
end
end
--- unlocks song k/v :
--- unlocks song k/v :
for songk, songv in unlocksIt(unlocks) do
for songk, songv in unlocksIt(unlocks) do
if id == songk then return frame:expandTemplate { title = " 解禁方法", args = {
if id == songk then
["PST解禁方法"] = stringify(songv[1]),
return frame:expandTemplate {title = ' 解禁方法', args = {
["PRS解禁方法"] = stringify(songv[2]),
['PST解禁方法'] = stringify(songv[1]),
["FTR解禁方法"] = stringify(songv[3]),
['PRS解禁方法'] = stringify(songv[2]),
} }
['FTR解禁方法'] = stringify(songv[3]),
}}
end
end
end
end
第64行: 第68行:


function p.world(frame)
function p.world(frame)
local world = mw.title.new(" 世界模式地图详表 (移动版" .. frame.args[1] .. ")"):getContent()
local world = mw.title.new(' 世界模式地图详表 (移动版' .. frame.args[1] .. ')'):getContent()
local res = {}
local res = {}
for name, wtb in world:gmatch "== *([^B].-) *==[^={]+(%b{})" do
for name, wtb in world:gmatch '== *([^B].-) *==[^={]+(%b{})' do
local tot
local tot
for stair, reward in wtb:gmatch "| *(%d+)[0-9()%-| ]+(%b[])" do
for stair, reward in wtb:gmatch '| *(%d+)[0-9()%-| ]+(%b[])' do
if slstIdx[reward:sub(3, -3)] then
if slstIdx[reward:sub(3, -3)] then
tot = tot or wtb:match "| *(%d+)[^\n]+\n|%-\n| *总计"
tot = tot or wtb:match '| *(%d+)[^\n]+\n|%-\n| *总计'
table.insert(res, ("|-\n|%s||%s||%d/%d"):format(reward, name, tonumber(stair) - 1, tonumber(tot) - 1))
table.insert(res, ('|-\n|%s||%s||%d/%d'):format(reward, name, tonumber(stair) - 1, tonumber(tot) - 1))
end
end
end
end
end
end
return table.concat(res, "\n")
return table.concat(res, '\n')
end
end


第81行: 第85行:
function p.detail(frame)
function p.detail(frame)
if next(detail) then return detail[frame.args[1]] end
if next(detail) then return detail[frame.args[1]] end
local inter = { fragment = {}, previous = {}, potential = {}, partner = {} }
local inter = {fragment = {}, previous = {}, potential = {}, partner = {}}
function type2Key(t)
function type2Key(t)
if t == 0 then return "fragment"
if t == 0 then
elseif t < 5 then return "previous"
return 'fragment'
elseif t == 5 then return "potential"
elseif t < 5 then
elseif t == 103 then return "partner"
return 'previous'
elseif t == 5 then
return 'potential'
elseif t == 103 then
return 'partner'
end
end
end
end
for songk, songv in unlocksIt(unlocks) do
for songk, songv in unlocksIt(unlocks) do
local row = { fragment = {}, previous = {}, potential = {}, partner = {} }
local row = {fragment = {}, previous = {}, potential = {}, partner = {}}
for rate = 1, 3 do
for rate = 1, 3 do
for _, cond in ipairs(songv[rate] or {}) do
for _, cond in ipairs(songv[rate] or {}) do
第103行: 第112行:
if kind[3] then
if kind[3] then
table.insert(inter[key], {
table.insert(inter[key], {
table.concat(kind[1] or { " " }, "<br>"),
table.concat(kind[1] or {' '}, '<br>'),
table.concat(kind[2] or { " " }, "<br>"),
table.concat(kind[2] or {' '}, '<br>'),
table.concat(kind[3], "<br>"), id = songk
table.concat(kind[3], '<br>'),
id = songk
})
})
end
end
end
end
end
end
local slst = mw.loadData "Module:songlist index".slst
local slst = mw.loadData 'Module:songlist index'.slst
local plst = mw.loadData "Module:packlist index"
local plst = mw.loadData 'Module:packlist index'
for key, songs in pairs(inter) do
for key, songs in pairs(inter) do
table.sort(songs, function(a, b)
table.sort(songs, function(a, b)
第118行: 第128行:
end)
end)
--- wikitable
--- wikitable
local wtb, pid = {}, ""
local wtb, pid = {}, ''
for _, song in ipairs(songs) do
for _, song in ipairs(songs) do
if pid ~= slst[slstIdx[song.id].idx].set then
if pid ~= slst[slstIdx[song.id].idx].set then
pid = slst[slstIdx[song.id].idx].set
pid = slst[slstIdx[song.id].idx].set
table.insert(wtb, '|-\n| colspan="4" |[[' .. plst[pid].name .. "]]")
table.insert(wtb, '|-\n| colspan="4" |[[' .. plst[pid].name .. ']]')
end
end
table.insert(wtb, table.concat({ "|-\n|[[" .. slstIdx[song.id].title .. "]]", unpack(song) }, "||"))
table.insert(wtb, table.concat({'|-\n|[[' .. slstIdx[song.id].title .. ']]', unpack(song)}, '||'))
end
end
detail[key] = table.concat(wtb, "\n")
detail[key] = table.concat(wtb, '\n')
end
end
return detail[frame.args[1]]
return detail[frame.args[1]]
end
end
return p
return p
2,544

次編輯