Module:Songconstant
可在Module:Songconstant/doc创建此模块的帮助文档
local getArgs = require('Module:Arguments').getArgs
local getData = require("Module:Arcaea Data")
local constantTable = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'ChartConstant.json' })
local p={}
function p.main(frame)
local args = getArgs(frame)
return p._main(args)
end
function p._main(args)
-- arg: id, name, diff
-- id 优先于 name
-- diff 是难度, 为 0~4
-- 不存在返回 0, 存在返回定数
local id=''
if args["id"] and args["id"] ~= "" then
id=args["id"]
elseif args["name"] then
id=getData.singleSongInformation(args["name"],"name","mobile")("id")
end
local diff=args['diff']
if constantTable[id][diff] then
return constantTable[id][diff]["constant"]
end
return "0"
end
return p