Module:Arcaea Data:修订间差异

来自Arcaea中文维基
(// Edit via Wikiplus)
 
(// Edit via Wikiplus)
第11行: 第11行:
end
end


-- p.pack = makeInvokeFunc('_pack')
function p.packName(id)
 
   -- 将曲包ID转换为曲包名称。
local packlist
   -- 传入Songlist中定义的曲包ID,返回Packlist中的曲包ID。如果Template:Transition.json中存在转换,则使用转换后的名称。


function p.packId(packId)
    --  检查 曲包ID 曲包名称 转换表是否存在转换规则
    --  曲包ID 转换为 曲包名称。
    local covList = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Packlist' })["packName"]
    local covList = {
    if covList[id] then return covList[id] end
     ['chunithm_append_1'] = 'CHUNITHM Collaboration - Collaboration Chapter 2',
     ['dividedheart'] = 'Divided Heart',
     ['groovecoaster'] = 'Groove Coaster Collaboration',
     ['lanota'] = 'Lanota Collaboration',
     ['lanota_append_1'] = 'Lanota Collaboration - Collaboration Chapter 2',
     ['tonesphere'] = 'Tone Sphere Collaboration',
     ['chunithm'] = 'CHUNITHM Collaboration',
     ['dynamix'] = 'Dynamix Collaboration',
     ['maimai'] = 'maimai Collaboration',
     ['ongeki'] = 'O.N.G.E.K.I. Collaboration',
     ['musedash'] = 'Muse Dash Collaboration',
     ['single'] = 'Memory Archive'
   }
    if covList[args[1]] then return covList[args[1]] end


   -- 判断变量是否已有值,为多次调用预备。
   -- 变量为全局变量
    if packlist == nil then
    if packlist == nil then
      packlist = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Packlist' })
      packlist = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Packlist' })
第42行: 第30行:
end
end


function p.unlock(songId)
function p.unlockText(songId)
    local json = loadJson.unlocks()['unlocks']
    -- 还未编写好的函数。目的:传入Songid,检索unlock,返回一个解锁要求文本的字符串。
 
   -- 变量为全局变量
   if unlock == nil
   then
     unlock = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Packlist' })
   end
  
    local result = {}
    local result = {}
    for i, k in ipairs(json) do
    for i, k in ipairs(json) do
      if k['songId'] == songId then
      if k['songId'] == songId then
        result[tonumber(k['ratingClass'] + 1)] = k['conditions']
        result[tonumber(k['ratingClass'] + 1)] = k['conditions']
       -- coding...
      end
      end
    end
    end
第53行: 第49行:
end
end


p.song = makeInvokeFunc('_song')
function jsonAssayForSingleSong(json, index, typed)
 
    -- 传入JSON文件,索引值和索引值类型(索引是ID还是曲名)。分析JSON文件以获得曲目信息 ,返回的是一个查找单一曲目中信息的函数 。仅获取单一曲目的信息。table中的索引名请查看下方switch表。
function p._song(args)
   local json
   if args['type'] or args[3] == 'ns' then
     json = loadJson.Songlist()
   else
     json = loadJson.SonglistNS()
   end
 
   return getSingle(json, args[1], args['index'])(args[2])
end
 
function getSingle(json, index, genre)
    -- 传入JSON文件,索引值和索引值类型(索引是ID还是曲名)。分析JSON文件以获得曲目信息。仅获取单一曲目的信息。table中的索引名请查看下方switch表。


    -- Songlist是以数字为索引值,因此遍历Songlist,直到发现需要找的曲目,将信息存入info变量中。
    -- Songlist是以数字为索引值,因此遍历Songlist,直到发现需要找的曲目,将信息存入info变量中。
    local s, info = "", {}
    local s, info = "", {}
    -- 如果模式是ID则遍历songlist直至发现id值为索引值为止,并获取内容。曲名同理。
    -- 如果模式是ID则遍历songlist直至发现id值为索引值为止,并获取内容。曲名同理。
    if genre == "id" then
    if typed == "id" then
      for i, k in ipairs(json['songs']) do
      for i, k in ipairs(json['songs']) do
        if k['id'] == index then list[index] = k end
        if k['id'] == index then list[index] = k end
第212行: 第195行:
end
end


function p.getMobile(name, id)
function p.singleSongInformation(index, indexTyped, platform)
    -- 传入曲名或ID,获得一个查阅信息的函数 (移动版信息) 。直接在下一个模块使用。
    -- 传入曲名或ID,获得一个查阅信息的函数。直接在下一个模块使用。
    if id then
    -- index:曲目的索引字符串,和typed一致  indexTyped:id或name,查找曲目的索引值类型  platform:mobile或ns
     return getSingle(mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist.json' } ), id, 'id')
   if platfrom == "mobile"
   then
     if indexTyped == "idthen
       return jsonAssayForSingleSong(mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist.json' } ), id, 'id')
     else
       return jsonAssayForSingleSong(mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist.json' } ), name, 'name')
     end
    else
    else
      return getSingle(mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist.json' } ), name, 'name')
      if indexTyped == "id"  then
       return jsonAssayForSingleSong(mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist NS.json' } ), id, 'id')
     else
       return jsonAssayForSingleSong(mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist NS.json' } ), name, 'name')
     end
    end
    end
end
end


function p.getNS(name, id)
function jsonAssayForAllSong(json, indexTyped)
    -- 传 入曲名或ID ,获得一个查 信息的函数 (NS版信息) 直接在 下一 个模块 使用。
    -- 传 入JSON文件 ,获得一个 通过索引值 找指定曲目指定 信息的函数。 与jsonAssayForSingleSong不同,本函数可以同时查找多个函数。
    if id then
   -- 索引值由 下一 步函数 使用 来指定,但是索引类型必须刚开始就指定 (id或name)
      return getSingle(mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist NS.json' } ), id, 'id')
 
   local s, info = "", {}
    if typed == "id" then
      for i, k in ipairs(json['songs']) do
       info[k['id']] = k
     end
    else
    else
      return getSingle(mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist NS.json' } ), name, 'name')
      for i, k in ipairs(json['songs']) do
       info[k['title_localized']['en']] = k
     end
    end
    end
   -- 此处返回一个函数用于查询内容。
   return function(index, key)
     -- 如果info无值即无法在songlist中查找到索引值,则返回nil。
    
     if info[index] == nil
     then
       mw.log( '无法在Songlist中发现目标,索引值为:'..index )
       return nil
     end
     -- 此处定义一个switch table以达到switch函数的效用。如果需要查找的参数在switch中不存在,返回nil。
     local switch = {
       ["id"] = function() return info[index]["id"] end,
       ["title"] = function() return info[index]['title_localized']['en'] end,
       ["artist"] = function() return info[index]["artist"] end,
       ["bpm"] = function() return info[index]["bpm"] end,
       ["set"] = function() return info[index]["set"] end,
       ["side"] = function() return info[index]["side"] end,
       ["date"] = function() return info[index]["date"] end,
       ["version"] = function() return info[index]["version"] end,
       ["bg"] = function()
         if info[index]["bg"] ~= "" then
           return info[index]["bg"]
         else
           if info[index]["side"] == 0 then
             return 'base_light'
           else
             if info[index]['side'] ==1 then
               return 'base_conflict'
             else
               return 'undefined'
             end
           end
         end
       end,
       ["pstChartDesigner"] = function()
         return info[index]["difficulties"][1]['chartDesigner']
       end,
       ["pstJacketDesigner"] = function()
         return info[index]["difficulties"][1]['jacketDesigner']
       end,
       ["pstRating"] = function()
         return info[index]["difficulties"][1]['rating']
       end,
       ["prsChartDesigner"] = function()
         return info[index]["difficulties"][2]['chartDesigner']
       end,
       ["prsJacketDesigner"] = function()
         return info[index]["difficulties"][2]['jacketDesigner']
       end,
       ["prsRating"] = function()
         return info[index]["difficulties"][2]['rating']
       end,
       ["ftrChartDesigner"] = function()
         return info[index]["difficulties"][3]['chartDesigner']
       end,
       ["ftrJacketDesigner"] = function()
         return info[index]["difficulties"][3]['jacketDesigner']
       end,
       ["ftrRating"] = function()
         if info[index]["difficulties"][3]['ratingPlus'] then
           return info[index]["difficulties"][3]['rating'] .. '+'
         else
           return info[index]["difficulties"][3]['rating']
         end
       end,
       ["bydChartDesigner"] = function()
         if info[index]["difficulties"][4] then
           return info[index]["difficulties"][4]['chartDesigner']
         end
       end,
       ["bydJacketDesigner"] = function()
         if info[index]["difficulties"][4] then
           return info[index]["difficulties"][4]['jacketDesigner']
         end
       end,
       ["bydRating"] = function()
         if info[index]["difficulties"][4] then
           return info[index]["difficulties"][4]['rating']
         end
       end,
       ["pstChange"] = function()
         if info[index]["difficulties"][1] then
           return info[index]["difficulties"][1]['has_controller_alt_chart']
         end
       end,
       ["prsChange"] = function()
         if info[index]["difficulties"][2] then
           return info[index]["difficulties"][2]['has_controller_alt_chart']
         end
       end,
       ["ftrChange"] = function()
         if info[index]["difficulties"][3] then
           return info[index]["difficulties"][3]['has_controller_alt_chart']
         end
       end,
       ["bydAudioChange"] = function()
         if info[index]["difficulties"][4] then
           return info[index]["difficulties"][4]['audioOverride']
         end
       end,
       ["bydBg"] = function()
         if info[index]["difficulties"][4] then
           return info[index]["difficulties"][4]['bg']
         end
       end,
       ["bydBPM"] = function()
         if info[index]["difficulties"][4] then
           return info[index]["difficulties"][4]['bpm']
         end
       end,
       ["bydArtist"] = function()
         if info[index]["difficulties"][4] then
           return info[index]["difficulties"][4]['artist']
         end
       end
     }
     if switch[key] == nil
     then
       mw.log( '未定义的索引类型,请检查是否拼写错误。' )
       return nil
     end
     return switch[key]()
   end
end
function p.allSongInformation(index, platform)
   -- 传入曲名或ID,获得一个查阅信息的函数。直接在下一个模块使用。
   -- index:曲目的索引字符串,和typed一致  typed:id或name,查找曲目的索引值类型  platform:mobile或ns
   if platfrom == "mobile"
   then
     if typed == "id"  then
       return jsonAssayForSingleSong(mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist.json' } ), 'id')
     else
       return jsonAssayForSingleSong(mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist.json' } ), 'name')
     end
   else
     if typed == "id"  then
       return jsonAssayForSingleSong(mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist NS.json' } ), 'id')
     else
       return jsonAssayForSingleSong(mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist NS.json' } ), 'name')
     end
   end
end
p.Song_Query = makeInvokeFunc('_Song_Query')
function p._Song_Query(songIndexType, songIndex, attributeName, platform)
   return p.singleSongInformation(songIndex, songIndexType, platform)(attributeName)
end
end


return p
return p

2022年7月29日 (五) 17:26的版本

本模块可查询Arcaea数据文件中存在的信息,为元模块,为其他模块提供支持。也提供接口对模块外直接查询。

通过模板:Songlist.json模板:Songlist NS.json模板:Packlist.json模板:Unlocks.json进行分析以提供数据。

面向模块函数

singleSongInformation

获取一个曲目所有信息,返回值是一个函数。可以通过该函数进行查询。

使用方法

local data = require("Module:Arcaea Data")
local query = data.singleSongInformation("该曲目的索引值", "索引值的类型,id或name", "查找内容的平台,mobile或ns")
mw.log(query("需要查询的属性的名称"))

示例

local data = require("Module:Arcaea Data")
local query = data.singleSongInformation("ifi", "id", "mobile")
-- 此时query是一个函数,传入需要查询的属性名称返回该属性的值。
mw.log(query("pstChartDesigner"))
-- 输出"夜浪"

allSongInformation

获取任何曲目的任何信息,返回值是一个函数。可以通过该函数进行查询。
和前者比效率略低一点点,查询更不方便(如果只需要查询一个曲目的话)。

使用方法

local data = require("Module:Arcaea Data")
local query = data.singleSongInformation("索引值的类型,id或name", "查找内容的平台,mobile或ns")
mw.log(query("该曲目的索引值", "需要查询的属性的名称"))

示例

local data = require("Module:Arcaea Data")
local query = data.allSongInformation("id", "mobile")
-- 此时query是一个函数,传入需要查询的属性名称返回该属性的值。
mw.log(query("ifi", "pstChartDesigner"))
-- 输出"夜浪"

packName

获传入曲包ID,获得Packlist中的曲包名称,返回值是一个字符串。
Template:Transition.json中存在转换,则使用转换后的名称,否则直接传出Packlist中的曲包名称。

使用方法

local data = require("Module:Arcaea Data")
local query = data.packName
mw.log(query("曲包ID"))

示例

local data = require("Module:Arcaea Data")
local query = data.packName
mw.log(query("vs"))
-- 输出"Black Fate"

unlockText

正在编写中。

直接查询函数

已将函数封为模板:Arcaea Data,可使用封包的模板来查询数据。

Song_Query

用法

{{Arcaea Data|type=Song_Query|索引名称|索引名称类型|属性名称|平台}}

示例

{{Arcaea Data|type=Song_Query|ifi|id|title|mobile}}

Pack_Query

用法

{{Arcaea Data|type=Pack_Query|曲包ID}}

示例

{{Arcaea Data|type=Pack_Query|vs}}

属性名列表

  • id
  • title
  • artist
  • bpm
  • set
  • side
  • date
  • version
  • bg
  • pstChartDesigner
  • pstJacketDesigner
  • pstRating
  • prsChartDesigner
  • prsJacketDesigner
  • prsRating
  • ftrChartDesigner
  • ftrJacketDesigner
  • ftrRating
  • bydChartDesigner
  • bydJacketDesigner
  • bydRating
  • etrChartDesigner
  • etrJacketDesigner
  • etrRating
  • pstChange
  • prsChange
  • ftrChange
  • bydChange
  • etrChange
  • bydAudioChange
  • bydBg
  • bydBPM
  • bydArtist

local getArgs = require('Module:Arguments').getArgs
local loadJson = require("Module:LoadJson")

local p = {}

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

function p.packName(id)
    -- 将曲包ID转换为曲包名称。
    -- 传入Songlist中定义的曲包ID,返回Packlist中的曲包ID。如果Template:Transition.json中存在转换,则使用转换后的名称。

    -- 检查曲包ID→曲包名称转换表是否存在转换规则。
    local covList = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Packlist' })["packName"]
    if covList[id] then return covList[id] end

    -- 判断变量是否已有值,为多次调用预备。
    -- 变量为全局变量
    if packlist == nil then
        packlist = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Packlist' })
    end

    for i, k in ipairs(packlist) do
        if k['id'] == packId then return k['name_localized']['en'] end
    end
end

function p.unlockText(songId)
    -- 还未编写好的函数。目的:传入Songid,检索unlock,返回一个解锁要求文本的字符串。

    -- 变量为全局变量
    if unlock == nil
    then
        unlock = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Packlist' })
    end
    
    local result = {}
    for i, k in ipairs(json) do
        if k['songId'] == songId then
            result[tonumber(k['ratingClass'] + 1)] = k['conditions']
            -- coding...
        end
    end
    return result
end

function jsonAssayForSingleSong(json, index, typed)
    -- 传入JSON文件,索引值和索引值类型(索引是ID还是曲名)。分析JSON文件以获得曲目信息,返回的是一个查找单一曲目中信息的函数。仅获取单一曲目的信息。table中的索引名请查看下方switch表。

    -- Songlist是以数字为索引值,因此遍历Songlist,直到发现需要找的曲目,将信息存入info变量中。
    local s, info = "", {}
    -- 如果模式是ID则遍历songlist直至发现id值为索引值为止,并获取内容。曲名同理。
    if typed == "id" then
        for i, k in ipairs(json['songs']) do
            if k['id'] == index then list[index] = k end
        end
    else
        for i, k in ipairs(json['songs']) do
            if k['title_localized']['en'] == index then info = k end
        end
    end

    -- 此处返回一个函数用于查询内容。

    return function(key)

        -- 如果info无值即无法在songlist中查找到索引值,则返回nil。
        
        if info == nil 
        then 
            mw.log( '无法在Songlist中发现目标,索引值为:'..index )
            return nil 
        end

        -- 此处定义一个switch table以达到switch函数的效用。如果需要查找的参数在switch中不存在,返回nil。
        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()
                if info["bg"] ~= "" then
                    return info["bg"]
                else
                    if info["side"] == 0 then
                        return 'base_light'
                    else
                        if info['side'] ==1 then
                            return 'base_conflict'
                        else
                            return 'undefined'
                        end
                    end
                end
            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,
            ["pstChange"] = function()
                if info["difficulties"][1] then
                    return info["difficulties"][1]['has_controller_alt_chart']
                end
            end,
            ["prsChange"] = function()
                if info["difficulties"][2] then
                    return info["difficulties"][2]['has_controller_alt_chart']
                end
            end,
            ["ftrChange"] = function()
                if info["difficulties"][3] then
                    return info["difficulties"][3]['has_controller_alt_chart']
                end
            end,
            ["bydAudioChange"] = function()
                if info["difficulties"][4] then
                    return info["difficulties"][4]['audioOverride']
                end
            end,
            ["bydBg"] = function()
                if info["difficulties"][4] then
                    return info["difficulties"][4]['bg']
                end
            end,
            ["bydBPM"] = function()
                if info["difficulties"][4] then
                    return info["difficulties"][4]['bpm']
                end
            end,
            ["bydArtist"] = function()
                if info["difficulties"][4] then
                    return info["difficulties"][4]['artist']
                end
            end
        }

        if switch[key] == nil 
        then 
            mw.log( '未定义的索引类型,请检查是否拼写错误。' )
            return nil 
        end

        return switch[key]()
    end
end

function p.singleSongInformation(index, indexTyped, platform)
    -- 传入曲名或ID,获得一个查阅信息的函数。直接在下一个模块使用。
    -- index:曲目的索引字符串,和typed一致  indexTyped:id或name,查找曲目的索引值类型  platform:mobile或ns
    if platfrom == "mobile"
    then
        if indexTyped == "id"  then
            return jsonAssayForSingleSong(mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist.json' } ), id, 'id')
        else
            return jsonAssayForSingleSong(mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist.json' } ), name, 'name')
        end
    else
        if indexTyped == "id"  then
            return jsonAssayForSingleSong(mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist NS.json' } ), id, 'id')
        else
            return jsonAssayForSingleSong(mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist NS.json' } ), name, 'name')
        end
    end
end

function jsonAssayForAllSong(json, indexTyped)
    -- 传入JSON文件,获得一个通过索引值查找指定曲目指定信息的函数。与jsonAssayForSingleSong不同,本函数可以同时查找多个函数。
    -- 索引值由下一步函数使用来指定,但是索引类型必须刚开始就指定。(id或name)

    local s, info = "", {}
    if typed == "id" then
        for i, k in ipairs(json['songs']) do
            info[k['id']] = k
        end
    else
        for i, k in ipairs(json['songs']) do
            info[k['title_localized']['en']] = k
        end
    end

    -- 此处返回一个函数用于查询内容。

    return function(index, key)

        -- 如果info无值即无法在songlist中查找到索引值,则返回nil。
        
        if info[index] == nil 
        then 
            mw.log( '无法在Songlist中发现目标,索引值为:'..index )
            return nil 
        end

        -- 此处定义一个switch table以达到switch函数的效用。如果需要查找的参数在switch中不存在,返回nil。
        local switch = {
            ["id"] = function() return info[index]["id"] end,
            ["title"] = function() return info[index]['title_localized']['en'] end,
            ["artist"] = function() return info[index]["artist"] end,
            ["bpm"] = function() return info[index]["bpm"] end,
            ["set"] = function() return info[index]["set"] end,
            ["side"] = function() return info[index]["side"] end,
            ["date"] = function() return info[index]["date"] end,
            ["version"] = function() return info[index]["version"] end,
            ["bg"] = function()
                if info[index]["bg"] ~= "" then
                    return info[index]["bg"]
                else
                    if info[index]["side"] == 0 then
                        return 'base_light'
                    else
                        if info[index]['side'] ==1 then
                            return 'base_conflict'
                        else
                            return 'undefined'
                        end
                    end
                end
            end,
            ["pstChartDesigner"] = function()
                return info[index]["difficulties"][1]['chartDesigner']
            end,
            ["pstJacketDesigner"] = function()
                return info[index]["difficulties"][1]['jacketDesigner']
            end,
            ["pstRating"] = function()
                return info[index]["difficulties"][1]['rating']
            end,
            ["prsChartDesigner"] = function()
                return info[index]["difficulties"][2]['chartDesigner']
            end,
            ["prsJacketDesigner"] = function()
                return info[index]["difficulties"][2]['jacketDesigner']
            end,
            ["prsRating"] = function()
                return info[index]["difficulties"][2]['rating']
            end,
            ["ftrChartDesigner"] = function()
                return info[index]["difficulties"][3]['chartDesigner']
            end,
            ["ftrJacketDesigner"] = function()
                return info[index]["difficulties"][3]['jacketDesigner']
            end,
            ["ftrRating"] = function()
                if info[index]["difficulties"][3]['ratingPlus'] then
                    return info[index]["difficulties"][3]['rating'] .. '+'
                else
                    return info[index]["difficulties"][3]['rating']
                end
            end,
            ["bydChartDesigner"] = function()
                if info[index]["difficulties"][4] then
                    return info[index]["difficulties"][4]['chartDesigner']
                end
            end,
            ["bydJacketDesigner"] = function()
                if info[index]["difficulties"][4] then
                    return info[index]["difficulties"][4]['jacketDesigner']
                end
            end,
            ["bydRating"] = function()
                if info[index]["difficulties"][4] then
                    return info[index]["difficulties"][4]['rating']
                end
            end,
            ["pstChange"] = function()
                if info[index]["difficulties"][1] then
                    return info[index]["difficulties"][1]['has_controller_alt_chart']
                end
            end,
            ["prsChange"] = function()
                if info[index]["difficulties"][2] then
                    return info[index]["difficulties"][2]['has_controller_alt_chart']
                end
            end,
            ["ftrChange"] = function()
                if info[index]["difficulties"][3] then
                    return info[index]["difficulties"][3]['has_controller_alt_chart']
                end
            end,
            ["bydAudioChange"] = function()
                if info[index]["difficulties"][4] then
                    return info[index]["difficulties"][4]['audioOverride']
                end
            end,
            ["bydBg"] = function()
                if info[index]["difficulties"][4] then
                    return info[index]["difficulties"][4]['bg']
                end
            end,
            ["bydBPM"] = function()
                if info[index]["difficulties"][4] then
                    return info[index]["difficulties"][4]['bpm']
                end
            end,
            ["bydArtist"] = function()
                if info[index]["difficulties"][4] then
                    return info[index]["difficulties"][4]['artist']
                end
            end
        }

        if switch[key] == nil 
        then 
            mw.log( '未定义的索引类型,请检查是否拼写错误。' )
            return nil 
        end

        return switch[key]()
    end

end

function p.allSongInformation(index, platform)
    -- 传入曲名或ID,获得一个查阅信息的函数。直接在下一个模块使用。
    -- index:曲目的索引字符串,和typed一致  typed:id或name,查找曲目的索引值类型  platform:mobile或ns
    if platfrom == "mobile"
    then
        if typed == "id"  then
            return jsonAssayForSingleSong(mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist.json' } ), 'id')
        else
            return jsonAssayForSingleSong(mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist.json' } ), 'name')
        end
    else
        if typed == "id"  then
            return jsonAssayForSingleSong(mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist NS.json' } ), 'id')
        else
            return jsonAssayForSingleSong(mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist NS.json' } ), 'name')
        end
    end
end

p.Song_Query = makeInvokeFunc('_Song_Query')

function p._Song_Query(songIndexType, songIndex, attributeName, platform)
    return p.singleSongInformation(songIndex, songIndexType, platform)(attributeName)
end

return p