Module:Data:修订间差异

来自Arcaea中文维基
(撤销Star0讨论)的版本26402)
标签撤销
无编辑摘要
第21行: 第21行:
end
end


function unlock(songId)
function p.unlock(songId)
local json=require("Module:LoadJson").unlocks()['unlocks']
local json=require("Module:LoadJson").unlocks()['unlocks']
local result={}
local result={}

2021年5月10日 (一) 12:27的版本

可在Module:Data/doc创建此模块的帮助文档

local getArgs = require('Module:Arguments').getArgs

local p = {}

local function makeInvokeFunc(funcName)
	return function (frame)
		local args = getArgs(frame)
		return p[funcName](args)
	end
end

p.pack = makeInvokeFunc('_pack')

function p._pack(args)
	local json=require("Module:LoadJson").Packlist()['packs']
	for i,k in ipairs(json) do
		if k['id']==args[1] then
			return k['name_localized']['en']
		end
	end
end

function p.unlock(songId)
	local json=require("Module:LoadJson").unlocks()['unlocks']
	local result={}
	for i,k in ipairs(json) do
		if k['songId']==songId then
			result[tonumber(k['ratingClass']+1)]=k['conditions']
		end
	end
	return result
end

p.song = makeInvokeFunc('_song')

function p._song(args)
	local json=require("Module:LoadJson").Songlist()
	local s,list="",{}
	for i=1,250 do
		if json['songs'][i]==nil then break end
		s=json['songs'][i]['title_localized']['en']
		list[s]=json['songs'][i]
	end
	
	local switch = {
    ["id"] = function()
        return list[args[2]]["id"]
    end,
   ["artist"] = function()
        return list[args[2]]["artist"]
    end,
    ["bpm"] = function()
        return list[args[2]]["bpm"]
    end,
    ["set"] = function()
        return list[args[2]]["set"]
    end,
    ["side"] = function()
        return list[args[2]]["side"]
    end,
    ["date"] = function()
        return list[args[2]]["date"]
    end,
    ["version"] = function()
        return list[args[2]]["version"]
    end,
    ["pstChartDesigner"] = function()
        return list[args[2]]["difficulties"][1]['chartDesigner']
    end,
    ["pstJacketDesigner"] = function()
        return list[args[2]]["difficulties"][1]['jacketDesigner']
    end,
    ["pstRating"] = function()
        return list[args[2]]["difficulties"][1]['rating']
    end,
    ["prsChartDesigner"] = function()
        return list[args[2]]["difficulties"][2]['chartDesigner']
    end,
    ["prsJacketDesigner"] = function()
        return list[args[2]]["difficulties"][2]['jacketDesigner']
    end,
    ["prsRating"] = function()
        return list[args[2]]["difficulties"][2]['rating']
    end,
    ["ftrChartDesigner"] = function()
        return list[args[2]]["difficulties"][3]['chartDesigner']
    end,
    ["ftrJacketDesigner"] = function()
        return list[args[2]]["difficulties"][3]['jacketDesigner']
    end,
    ["ftrRating"] = function()
        return list[args[2]]["difficulties"][3]['rating']
    end,
    ["bydChartDesigner"] = function()
    	if list[args[2]]["difficulties"][4] then
    		return list[args[2]]["difficulties"][4]['chartDesigner']
    	end
    end,
    ["bydJacketDesigner"] = function()
    	if list[args[2]]["difficulties"][4] then
        	return list[args[2]]["difficulties"][4]['jacketDesigner']
        end
    end,
    ["bydRating"] = function()
    	if list[args[2]]["difficulties"][4] then
        	return list[args[2]]["difficulties"][4]['rating']
        end
    end
}
	
	return switch[args[1]]()
	
end

return p