Module:Data:修订间差异
小无编辑摘要 |
小无编辑摘要 |
||
第1行: | 第1行: | ||
local getArgs = require('Module:Arguments').getArgs | local getArgs = require('Module:Arguments').getArgs | ||
local loadJson =require("Module:LoadJson") | |||
local p = {} | local p = {} | ||
第127行: | 第128行: | ||
end | end | ||
function | function getSingle(json) | ||
local s,list="",{} | |||
for i,k in ipairs(json['songs']) do | for i,k in ipairs(json['songs']) do | ||
s=k['title_localized']['en'] | s=k['title_localized']['en'] | ||
list[s]=k | list[s]=k | ||
end | end | ||
return function(mold) | return function(mold) | ||
local info=list[name] | local info=list[name] | ||
if list[name]==nil then return | if list[name]==nil then return nil end | ||
local switch = { | local switch = { | ||
第217行: | 第217行: | ||
} | } | ||
if switch[mold]==nil then return nil end | |||
return switch[mold]() | |||
end | end | ||
end | |||
function p.getMobile(name) | |||
return getSingle(loadJson.Songlist()) | |||
end | end | ||
function p.getNS(name) | function p.getNS(name) | ||
return getSingle(loadJson.SonglistNS()) | |||
end | end | ||
return p | return p |
2021年5月20日 (四) 22:18的版本
可在Module:Data/doc创建此模块的帮助文档
local getArgs = require('Module:Arguments').getArgs
local loadJson =require("Module:LoadJson")
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,k in ipairs(json['songs']) do
if args['type']=="id" then
s=k['id']
else
s=k['title_localized']['en']
end
list[s]=k
end
local switch = {
["id"] = function()
return list[args[2]]["id"]
end,
["title"] = function()
return list[args[2]]['title_localized']['en']
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,
["bg"] = function()
return list[args[2]]["bg"]
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()
if list[args[2]]["difficulties"][3]['ratingPlus']
then
return list[args[2]]["difficulties"][3]['rating']..'+'
else
return list[args[2]]["difficulties"][3]['rating']
end
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
function getSingle(json)
local s,list="",{}
for i,k in ipairs(json['songs']) do
s=k['title_localized']['en']
list[s]=k
end
return function(mold)
local info=list[name]
if list[name]==nil then return nil end
local switch = {
["id"] = function()
return info["id"]
end,
["title"] = function()
return info['title_localized']['en']
end,
["artist"] = function()
return info["artist"]
end,
["bpm"] = function()
return info["bpm"]
end,
["set"] = function()
return info["set"]
end,
["side"] = function()
return info["side"]
end,
["date"] = function()
return info["date"]
end,
["version"] = function()
return info["version"]
end,
["bg"] = function()
return info["bg"]
end,
["pstChartDesigner"] = function()
return info["difficulties"][1]['chartDesigner']
end,
["pstJacketDesigner"] = function()
return info["difficulties"][1]['jacketDesigner']
end,
["pstRating"] = function()
return info["difficulties"][1]['rating']
end,
["prsChartDesigner"] = function()
return info["difficulties"][2]['chartDesigner']
end,
["prsJacketDesigner"] = function()
return info["difficulties"][2]['jacketDesigner']
end,
["prsRating"] = function()
return info["difficulties"][2]['rating']
end,
["ftrChartDesigner"] = function()
return info["difficulties"][3]['chartDesigner']
end,
["ftrJacketDesigner"] = function()
return info["difficulties"][3]['jacketDesigner']
end,
["ftrRating"] = function()
if info["difficulties"][3]['ratingPlus']
then
return info["difficulties"][3]['rating']..'+'
else
return info["difficulties"][3]['rating']
end
end,
["bydChartDesigner"] = function()
if info["difficulties"][4] then
return info["difficulties"][4]['chartDesigner']
end
end,
["bydJacketDesigner"] = function()
if info["difficulties"][4] then
return info["difficulties"][4]['jacketDesigner']
end
end,
["bydRating"] = function()
if info["difficulties"][4] then
return info["difficulties"][4]['rating']
end
end
}
if switch[mold]==nil then return nil end
return switch[mold]()
end
end
function p.getMobile(name)
return getSingle(loadJson.Songlist())
end
function p.getNS(name)
return getSingle(loadJson.SonglistNS())
end
return p