Module:Songconstant

来自Arcaea中文维基
WYXkk讨论 | 贡献2024年3月30日 (六) 02:28的版本 (判空)

可在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 specialTransition={
	["Quon (DJ Noriken)"]="quonwacca",
	["Quon (Feryquitous)"]="quon",
	["Genesis (Iris)"]="genesis",
	["Genesis (Morrigan)"]="genesischunithm",
	["#1f1e33"]="ifi",
	["AI[UE]OON"]="aiueoon",
	["[X]"]="infinity",
}
-- 你维好像没有关于这个的 直接的 东西
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
	-- 不存在返回空, 存在返回定数
	local id=''
	if args["id"] and args["id"] ~= "" then
		id=args["id"]
	elseif args["name"] then
		local name=args["name"]
		if specialTransition[name] then
			id=specialTransition[name]
		else
			id=getData.singleSongInformation(name,"name","mobile")("id")
		end
	end
	if id=='' then
		return ''
	end
	local diff=tonumber(args['diff'])
	if constantTable[id][diff] then
		return string.format("%.1f",constantTable[id][diff]["constant"])
	end
	return ""
end

return p