Module:Data:修订间差异

来自Arcaea中文维基
(撤销Star0讨论)的版本26402)
标签撤销
(撤销两个编辑)
标签手工回退
 
(未显示2个用户的33个中间版本)
第1行: 第1行:
local getArgs = require('Module:Arguments').getArgs
local getArgs = require('Module:Arguments').getArgs
local loadJson = require("Module:LoadJson")


local p = {}
local p = {}


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


第13行: 第14行:


function p._pack(args)
function p._pack(args)
local json=require("Module:LoadJson").Packlist()['packs']
local covList={
for i,k in ipairs(json) do
['chunithm_append_1']='CHUNITHM Collaboration - Collaboration Chapter 2',
if k['id']==args[1] then
['dividedheart']='Divided Heart',
return k['name_localized']['en']
['groovecoaster']='Groove Coaster Collaboration',
end
['lanota']='Lanota Collaboration',
end
['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
   local json = loadJson.Packlist()['packs']
   for i, k in ipairs(json) do
     if k['id'] == args[1] then
       return k['name_localized']['en']
     end
   end
end
end


function unlock(songId)
function p.unlock(songId)
local json=require("Module:LoadJson").unlocks()['unlocks']
   local json = loadJson.unlocks()['unlocks']
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
result[tonumber(k['ratingClass']+1)]=k['conditions']
       then
end
       result[tonumber(k['ratingClass'] + 1)] = k['conditions']
end
     end
return result
   end
   return result
end
end


第35行: 第52行:


function p._song(args)
function p._song(args)
local json=require("Module:LoadJson").Songlist()
   local json
local s,list="",{}
   if args['type'] or args[3] == 'ns'
for i=1,250 do
     then
if json['songs'][i]==nil then break end
      json = loadJson.Songlist()
s=json['songs'][i]['title_localized']['en']
    else
list[s]=json['songs'][i]
      json = loadJson.SonglistNS()
end
    end
 
local switch = {
    return getSingle(json, args[1], args['index'])(args[2])
   ["id"] = function()
end
      return list[args[2]]["id"]
 
   end,
function getSingle(json, index, genre)
  ["artist"] = function()
    local s, list = "", {}
     return list[args[2]]["artist"]
    if genre == "id"
   end,
      then
    ["bpm"] = function()
     for i, k in ipairs(json['songs']) do
      return list[args[2]]["bpm"]
     if k['id'] == index then
   end,
     list[index] = k
   ["set"] = function()
      end
     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
    end,
    else
   ["bydRating"] = function()
     for i, k in ipairs(json['songs']) do
   if list[args[2]]["difficulties"][4] then
       s = k['title_localized']['en']
     return list[args[2]]["difficulties"][4]['rating']
       list[s] = k
      end
      end
    end
    end
}
 
   return function(key)
return switch[args[1]]()
     local info = list[index]
 
     if list[index] == 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()
         if info["bg"] ~= "" then
           return info["bg"]
         else
           if info["side"] == 0 then
             return 'base_light'
           else
             return 'base_conflict'
           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 return nil end
 
     return switch[key]()
   end
end
 
function p.getMobile(name, id)
if id then
return getSingle(loadJson.Songlist(), id, 'id')
else
return getSingle(loadJson.Songlist(), name, 'name')
end
end
 
function p.getNS(name, id)
if id then
return getSingle(loadJson.SonglistNS(), id, 'id')
else
return getSingle(loadJson.SonglistNS(), name, 'name')
end
end
end


return p
return p

2024年8月12日 (一) 02:20的最新版本

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

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

p.pack = makeInvokeFunc('_pack')

function p._pack(args)
	local covList={
		['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
    local json = 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 = 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
    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)
    local s, list = "", {}
    if genre == "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
            s = k['title_localized']['en']
            list[s] = k
        end
    end

    return function(key)
        local info = list[index]

        if list[index] == 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()
                if info["bg"] ~= "" then
                    return info["bg"]
                else
                    if info["side"] == 0 then
                        return 'base_light'
                    else
                        return 'base_conflict'
                    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 return nil end

        return switch[key]()
    end
end

function p.getMobile(name, id)
	if id then
		return getSingle(loadJson.Songlist(), id, 'id')
	else
		return getSingle(loadJson.Songlist(), name, 'name')
	end
end

function p.getNS(name, id)
	if id then
		return getSingle(loadJson.SonglistNS(), id, 'id')
	else
		return getSingle(loadJson.SonglistNS(), name, 'name')
	end
end

return p