跳到内容
折叠侧栏
搜索
创建账号
个人工具
创建账号
登录
导航
首页
最近更改
随机页面
编者用页面
方针
指引
讨论版
格式手册
挂起清单
维护清单
玩法条目
游戏玩法
界面
机制
搭档
潜力值
Link Play
世界模式
故事模式
段位挑战
解歌系统
成就系统
版本更新日志
列表条目
定数表
曲目列表
曲包列表
曲师列表
谱师列表
画师列表
背景列表
友情链接
Rotaeno中文维基
工具
链入页面
相关更改
特殊页面
页面信息
查看“Module:Arcaea Data”的源代码
模块
讨论
English
阅读
查看源代码
查看历史
更多
阅读
查看源代码
查看历史
←
Module:Arcaea Data
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
local p = {} function p.packName(id) -- 将曲包ID转换为曲包名称。 -- 传入Songlist中定义的曲包ID,返回Packlist中的曲包名称。如果Template:Transition.json中存在转换,则使用转换后的名称。 if type(id) ~= "string" then mw.log("id值类型不符,类型为"..type(id)) return "undefined" end -- 检查曲包ID→曲包名称转换表是否存在转换规则。 local covList = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Transition.json' })["packName"] if covList[id] then return covList[id] end -- 判断变量是否已有值,为多次调用预备。 -- 变量为全局变量 if packlist == nil then packlist = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Packlist.json' }) end for i, k in ipairs(packlist['packs']) do if k['id'] == id then return k['name_localized']['en'] end end if packlistNS == nil then packlistNS = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Packlist NS' }) end for i, k in ipairs(packlistNS['packs']) do if k['id'] == id then return k['name_localized']['en'] end end mw.log("未找到曲包名称,id为"..id) return id end function p.unlockText(songId) -- 还未编写好的函数。目的:传入Songid,检索unlock,返回一个解锁要求文本的字符串。 -- 变量为全局变量 if unlock == nil then unlock = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Packlist.json' }) 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 extractInfoFromSingleSongData(info, key) -- 如果info无值即无法在songlist中查找到索引值,则返回nil。 if info == nil then mw.log( '无法在Songlist中发现目标,索引值为:'.. (index or 'nil') ) return nil end local difficulties={} if info["difficulties"] then for _, difficulty in ipairs(info["difficulties"]) do difficulties[difficulty["ratingClass"]] = difficulty end 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, ["category"] = function() return info["category"] 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() if info["difficulties"] then return difficulties[0]['chartDesigner'] end end, ["pstJacketDesigner"] = function() if info["difficulties"] then return difficulties[0]['jacketDesigner'] end end, ["pstRating"] = function() if difficulties[0]['ratingPlus'] then return difficulties[0]['rating'] .. '+' else return difficulties[0]['rating'] end end, ["prsChartDesigner"] = function() if info["difficulties"] then return difficulties[1]['chartDesigner'] end end, ["prsJacketDesigner"] = function() if info["difficulties"] then return difficulties[1]['jacketDesigner'] end end, ["prsRating"] = function() if difficulties[1]['ratingPlus'] then return difficulties[1]['rating'] .. '+' else return difficulties[1]['rating'] end end, ["ftrChartDesigner"] = function() if info["difficulties"] then return difficulties[2]['chartDesigner'] end end, ["ftrJacketDesigner"] = function() if info["difficulties"] then return difficulties[2]['jacketDesigner'] end end, ["ftrRating"] = function() if info["difficulties"] then if difficulties[2]['ratingPlus'] then return difficulties[2]['rating'] .. '+' else return difficulties[2]['rating'] end end end, ["bydChartDesigner"] = function() if info["difficulties"] and difficulties[3] then return difficulties[3]['chartDesigner'] end end, ["bydJacketDesigner"] = function() if info["difficulties"] and difficulties[3] then return difficulties[3]['jacketDesigner'] end end, ["bydRating"] = function() if info["difficulties"] and difficulties[3] then if difficulties[3]['ratingPlus'] then return difficulties[3]['rating'] .. '+' else return difficulties[3]['rating'] end end end, ["etrChartDesigner"] = function() if info["difficulties"] and difficulties[4] then return difficulties[4]['chartDesigner'] end end, ["etrJacketDesigner"] = function() if info["difficulties"] and difficulties[4] then return difficulties[4]['jacketDesigner'] end end, ["etrRating"] = function() if info["difficulties"] and difficulties[4] then if difficulties[4]['ratingPlus'] then return difficulties[4]['rating'] .. '+' else return difficulties[4]['rating'] end end end, ["pstChange"] = function() if info["difficulties"] and difficulties[0] then return difficulties[0]['has_controller_alt_chart'] end end, ["prsChange"] = function() if info["difficulties"] and difficulties[1] then return difficulties[1]['has_controller_alt_chart'] end end, ["ftrChange"] = function() if info["difficulties"] and difficulties[2] then return difficulties[2]['has_controller_alt_chart'] end end, ["bydChange"] = function() if info["difficulties"] and difficulties[3] then return difficulties[3]['has_controller_alt_chart'] end end, ["etrChange"] = function() if info["difficulties"] and difficulties[4] then return difficulties[4]['has_controller_alt_chart'] end end, ["bydAudioChange"] = function() if info["difficulties"] and difficulties[3] then return difficulties[3]['audioOverride'] end end, ["bydBg"] = function() if info["difficulties"] and difficulties[3] then return difficulties[3]['bg'] end end, ["bydBPM"] = function() if info["difficulties"] and difficulties[3] then return difficulties[3]['bpm'] end end, ["bydArtist"] = function() if info["difficulties"] and difficulties[3] then return difficulties[3]['artist'] end end, ["bydSongName"] = function() if info["difficulties"] and difficulties[3] and difficulties[3].title_localized then return difficulties[3].title_localized.en end end, ["bydDate"] = function() if info["difficulties"] and difficulties[3] then return difficulties[3].date end end, ["bydVersion"] = function() if info["difficulties"] and difficulties[3] then return difficulties[3].version end end } if switch[key] == nil then mw.log( '未定义的索引类型,请检查是否拼写错误。' ) return nil end return switch[key]() end function jsonAssayForSingleSong(json, index, indexTyped) -- 传入JSON文件,索引值和索引值类型(索引是ID还是曲名)。分析JSON文件以获得曲目信息,返回的是一个查找单一曲目中信息的函数。仅获取单一曲目的信息。table中的索引名请查看下方switch表。 -- Songlist是以数字为索引值,因此遍历Songlist,直到发现需要找的曲目,将信息存入info变量中。 local s, info = "", {} -- 如果模式是ID则遍历songlist直至发现id值为索引值为止,并获取内容。曲名同理。 if indexTyped == "id" then for i, k in ipairs(json['songs']) do if k['id'] == index then info = k end end else for i, k in ipairs(json['songs']) do if string.lower(k['title_localized']['en']) == string.lower(index) then info = k end end end -- 此处返回一个函数用于查询内容。 return function(key) return extractInfoFromSingleSongData(info, key) end end function p.singleSongInformation(index, indexTyped, platform) -- 传入曲名或ID,获得一个查阅信息的函数。直接在下一个模块使用。 -- index:曲目的索引字符串,和typed一致 indexTyped:id或name,查找曲目的索引值类型 platform:mobile或ns if platform == "mobile" then if indexTyped == "id" then return jsonAssayForSingleSong(mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist.json' } ), index, 'id') else return jsonAssayForSingleSong(mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist.json' } ), index, 'name') end else if indexTyped == "id" then return jsonAssayForSingleSong(mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist NS.json' } ), index, 'id') else return jsonAssayForSingleSong(mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist NS.json' } ), index, 'name') end end end function jsonAssayForAllSong(json, indexTyped) -- 传入JSON文件,获得一个通过索引值查找指定曲目指定信息的函数。与jsonAssayForSingleSong不同,本函数可以同时查找多个函数。 -- 索引值由下一步函数使用来指定,但是索引类型必须刚开始就指定。(id或name) local s, info = "", {} if indexTyped == "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) return extractInfoFromSingleSongData(info[index], key) end end function p.allSongInformation(indexTyped, platform) -- 获得一个查阅信息的函数,可查阅任何曲目。直接在下一个模块使用。 -- indexTyped:id或name,查找曲目的索引值类型 platform:mobile或ns if platform == "mobile" then if indexTyped == "id" then return jsonAssayForAllSong(mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist.json' } ), 'id') else return jsonAssayForAllSong(mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist.json' } ), 'name') end else if indexTyped == "id" then return jsonAssayForAllSong(mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist NS.json' } ), 'id') else return jsonAssayForAllSong(mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist NS.json' } ), 'name') end end end local getArgs = require('Module:Arguments').getArgs function makeInvokeFunc(funcName) return function(frame) local args = getArgs(frame) return p[funcName](args) end end p.Song_Query = makeInvokeFunc('_Song_Query') function p._Song_Query(args) -- 面向wikitext直接查询 -- return p.singleSongInformation(songIndex, songIndexType, platform)(attributeName) return p.singleSongInformation(args[1], args[2], args[4])(args[3]) end p.Pack_Query = makeInvokeFunc('_Pack_Query') function p._Pack_Query(args) -- 面向wikitext直接查询 return p.packName(args[1]) end return p
本页使用的模板:
Module:Arcaea Data/doc
(
查看源代码
)
返回
Module:Arcaea Data
。