Module:沙盒/盐棋/Sandbox:修订间差异
小 (自定义控制层) 标签:替换 |
小 (unlocks) |
||
第1行: | 第1行: | ||
local p = {} | local p = {} | ||
local null = require('Module:Nullish') | |||
local map = mw.loadData('Module:沙盒/盐棋/Sandbox1')--Line7 | |||
local unlocks = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'unlocks' }).unlocks | |||
function p. | p.condition = setmetatable({ | ||
song_id = function(v) return "[[" .. map[v] .. "]]" end, | |||
song_difficulty=function(v) return "["..({[0] = "PST","PRS","FTR","BYD"})[v] .."]"end, | |||
grade = function(v) return v == 0 and "" or ("以 「%s」 或以上成绩"):format(({"C","B","A","AA","EX"})[v]) end, | |||
rating = function(v) return ("%.2f"):format(v / 100) end, | |||
id = function() return "[[拉格兰]]" end, | |||
[0] = "$credit 残片", | |||
"$grade通关 $song_id $song_difficulty", | |||
"游玩 $song_id $song_difficulty", | |||
"$grade通关 $song_id $song_difficulty$times回", | |||
"$1 '''或''' $2", | |||
"个人游玩潜力值 $rating 或以上", | |||
[103] = "获得搭档「$id」" | |||
}, { | |||
__call = function(self, args) | |||
return string.gsub(self[args.type] or "", "%$[a-z12_]+", function(k) | |||
k = k:sub(2) | |||
if self[k] then return self[k](args[k]) end | |||
if tonumber(k) then return self(args.conditions[tonumber(k)]) end | |||
return args[k] | |||
end) | |||
end | |||
}) | |||
p.single = function(id) | |||
function UnlocksIt(ware) | |||
local i, key = 1, nil | |||
return function() | |||
if not ware[i] then return end | |||
local arr = {} | |||
key = ware[i].songId | |||
repeat | |||
table.insert(arr, ware[i].ratingClass + 1, ware[i].conditions) | |||
i = i + 1 | |||
until (ware[i] / null).songId ~= key | |||
return key, arr | |||
end | |||
end | |||
-- unlocks k/v | |||
for ukey, uval in UnlocksIt(unlocks) do | |||
if id == ukey then return uval end | |||
end | |||
end | end | ||
return p | return p |
2022年9月15日 (四) 23:12的版本
可在Module:沙盒/盐棋/Sandbox/doc创建此模块的帮助文档
local p = {}
local null = require('Module:Nullish')
local map = mw.loadData('Module:沙盒/盐棋/Sandbox1')--Line7
local unlocks = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'unlocks' }).unlocks
p.condition = setmetatable({
song_id = function(v) return "[[" .. map[v] .. "]]" end,
song_difficulty=function(v) return "["..({[0] = "PST","PRS","FTR","BYD"})[v] .."]"end,
grade = function(v) return v == 0 and "" or ("以 「%s」 或以上成绩"):format(({"C","B","A","AA","EX"})[v]) end,
rating = function(v) return ("%.2f"):format(v / 100) end,
id = function() return "[[拉格兰]]" end,
[0] = "$credit 残片",
"$grade通关 $song_id $song_difficulty",
"游玩 $song_id $song_difficulty",
"$grade通关 $song_id $song_difficulty$times回",
"$1 '''或''' $2",
"个人游玩潜力值 $rating 或以上",
[103] = "获得搭档「$id」"
}, {
__call = function(self, args)
return string.gsub(self[args.type] or "", "%$[a-z12_]+", function(k)
k = k:sub(2)
if self[k] then return self[k](args[k]) end
if tonumber(k) then return self(args.conditions[tonumber(k)]) end
return args[k]
end)
end
})
p.single = function(id)
function UnlocksIt(ware)
local i, key = 1, nil
return function()
if not ware[i] then return end
local arr = {}
key = ware[i].songId
repeat
table.insert(arr, ware[i].ratingClass + 1, ware[i].conditions)
i = i + 1
until (ware[i] / null).songId ~= key
return key, arr
end
end
-- unlocks k/v
for ukey, uval in UnlocksIt(unlocks) do
if id == ukey then return uval end
end
end
return p