跳到内容

Module:Data:修订间差异

删除2,120字节 、​ 2021年7月19日 (星期一)
代码重新整理
无编辑摘要
(代码重新整理)
第1行: 第1行:
local getArgs = require('Module:Arguments').getArgs
local getArgs = require('Module:Arguments').getArgs
local loadJson =require("Module:LoadJson")
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


第14行: 第14行:


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


function p.unlock(songId)
function p.unlock(songId)
local json=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


第36行: 第37行:


function p._song(args)
function p._song(args)
local json=loadJson.Songlist()
   local json
local s,list="",{}
   if args['type'] or args[3] == 'ns'
for i,k in ipairs(json['songs']) do
      then
if args['type']=="id" then
      json = loadJson.Songlist()
s=k['id']
    else
else
      json = loadJson.SonglistNS()
s=k['title_localized']['en']
end
list[s]=k
end
local switch = {
["existence"] = function()
     if list[args[2]] then return true else return false end
   end,
   ["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
    end
}
 
   return getSingle(json, args[1], args['index'])(args[2])
return switch[args[1]]()
end
end


function getSingle(json,name)
function getSingle(json, index, genre)
local s,list="",{}
   local s, list = "", {}
    for i,k in ipairs(json['songs']) do
    if genre == "id"
     s=k['title_localized']['en']
     then
     list[s]=k
     list = json
   else
     for i, k in ipairs(json['songs']) do
       s = k['title_localized']['en']
       list[s] = k
     end
    end
    end
 
    return function(mold)
    return function(key)
      local info=list[name]
      local info = list[index]
    
 
      if list[name]==nil then return nil end
      if list[index] == nil then return nil end


      local switch = {
      local switch = {
第150行: 第72行:
          return info['title_localized']['en']
          return info['title_localized']['en']
        end,
        end,
      ["artist"] = function()
       ["artist"] = function()
          return info["artist"]
          return info["artist"]
        end,
        end,
第169行: 第91行:
        end,
        end,
        ["bg"] = function()
        ["bg"] = function()
       if info["bg"]~="" then
         if info["bg"] ~= "" then
         return info["bg"]
           return info["bg"]
          else
          else
         if info["side"]==0 then 
           if info["side"] == 0 then
         return 'base_light'
             return 'base_light'
         else
           else
         return 'base_conflict'
             return 'base_conflict'
         end
           end
          end
          end
        end,
        end,
第205行: 第127行:
        ["ftrRating"] = function()
        ["ftrRating"] = function()
          if info["difficulties"][3]['ratingPlus']
          if info["difficulties"][3]['ratingPlus']
         then
           then
            return info["difficulties"][3]['rating']..'+'
            return info["difficulties"][3]['rating'] .. '+'
          else
          else
            return info["difficulties"][3]['rating']
            return info["difficulties"][3]['rating']
第237行: 第159行:
        end,
        end,
        ["ftrChange"] = function()
        ["ftrChange"] = function()
if info["difficulties"][3] then
         if info["difficulties"][3] then
            return info["difficulties"][3]['has_controller_alt_chart']
            return info["difficulties"][3]['has_controller_alt_chart']
          end
          end
第243行: 第165行:
      }
      }


if switch[mold]==nil then return nil end
     if switch[key] == nil then return nil end
 
   return switch[mold]()
     return switch[key]()
    end
    end
end
end


function p.getMobile(name)
function p.getMobile(name)
    return getSingle(loadJson.Songlist(),name)
    return getSingle(loadJson.Songlist(), name, 'name')


end
end


function p.getNS(name)
function p.getNS(name)
    return getSingle(loadJson.SonglistNS(),name)
    return getSingle(loadJson.SonglistNS(), name, 'name')
end
end


return p
return p