跳到内容
折叠侧栏
搜索
创建账号
个人工具
创建账号
登录
导航
首页
最近更改
随机页面
编者用页面
方针
指引
讨论版
格式手册
挂起清单
维护清单
玩法条目
游戏玩法
界面
机制
搭档
潜力值
Link Play
世界模式
故事模式
段位挑战
解歌系统
成就系统
版本更新日志
列表条目
定数表
曲目列表
曲包列表
曲师列表
谱师列表
画师列表
背景列表
友情链接
Rotaeno中文维基
工具
链入页面
相关更改
特殊页面
页面信息
查看“Module:SongCollectionMulti”的源代码
模块
讨论
English
阅读
查看源代码
查看历史
更多
阅读
查看源代码
查看历史
←
Module:SongCollectionMulti
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
local mad = require 'Module:AnotherData' local cLink = require 'Module:ConvertLink' local cal = mw.loadJsonData 'Template:ComplexArtistsList.json' local trans = mw.loadJsonData 'Template:Transition.json' local lang = mw.language.getContentLanguage() local frame = mw.getCurrentFrame() local p = {} local dates, versionNames = {}, {} -- 分离双平台页的曲包: local discrete_pack = {['Arcaea']='', ['Memory Archive']=''} local function verQuery(sec) local date = tonumber(lang:formatDate('ymd', '@' .. sec)) - 1 if date > dates[#dates] then return '@' end local l, r = 1, #dates while l < r do local m = math.floor((l + r) / 2) if dates[m] < date then l = m + 1 else r = m end end return versionNames[l] end local function otherTitles(song) local res = {} local titleJa = song.title_localized.ja if titleJa then table.insert(res, ('<span lang="ja">-{%s}-</span>'):format(titleJa)) end table.insert(res, song.title_localized['zh-Hans']) for _, diff in ipairs(song.difficulties) do if diff.title_localized then table.insert(res, diff.title_localized.en .. ' ' .. mad.color { rc = diff.ratingClass + 1, -- 为什么没有设置成对应关系!?(恼) txt = ('[%s]'):format(({[3] = 'Beyond'})[diff.ratingClass]), inline = true }) end end return res end local function link(l, d) if d then return '[[' .. l .. '|' .. d .. ']]' else return '[[' .. l .. ']]' end end local function formatJapaneseText(text) return mw.ustring.gsub( text, '[一-龠ぁ-ゔァ-ヴー々〆〤ヶ]+', function(v) return ('<span lang="ja">-{%s}-</span>'):format(v) end ) end local onlyMobile = frame:expandTemplate{title = '仅', args = {'移动版', '', '图片角标'}} local onlyNS = frame:expandTemplate{title = '仅', args = {'NS版', '', '图片角标'}} local ctrlTouch = '[[文件:Icon Touch2.png|16px|top|触摸|link=]]' local ctrlJC = '[[文件:Icon Joy-Con2.png|16px|top|Joy-Con|link=]]' local sectionCode = {unknown = 0, free = 1, archive = 2, mainstory = 3, sidestory = 4, collab = 5, single = 6} local function main(args, durArgs) local view = {} -- local plat = 'mobile' -- 不对song下述提及的字段存在性做检验 local multi_song={} local ns_song={} local multi_id={} local mobile_id={} local ns_id={} for _, song in ipairs(mad.listOf('songs', 'mobile')) do mobile_id[song.id] = 1 multi_id[song.id] = 1 multi_song[song.id] = song end for _, song in ipairs(mad.listOf('songs', 'ns')) do ns_id[song.id] = 1 ns_song[song.id] = song if not multi_id[song.id] then multi_id[song.id] = 1 multi_song[song.id] = song end end local ns2mo = trans.multiId local mo2ns = {} for ns,mo in pairs(ns2mo) do mo2ns[mo]=ns end for v in pairs(ns2mo) do multi_song[v] = nil end for _, song in pairs(multi_song) do local id = song.id local packItem = mad.packQueryWrap(song.set, 'mobile') local data = setmetatable({}, {__index = table}) local function input(...) return args[table.concat({id, ...}, '.')] end if id ~= 'lasteternity' then table.insert(view, { data = data, sort = {sectionCode[packItem['section']], packItem['numero'], song.date} }) end -- 平台 local display_plat = '' local NSid = id if mobile_id[id] then display_plat = display_plat .. '[[文件:Icon Smartphone.png|16px|link=曲目列表 (移动版)]]' end if ns_id[id] then display_plat = display_plat .. '[[文件:Icon Nintendo switch.png|16px|link=曲目列表 (Nintendo Switch版)]]' elseif mo2ns[id] then display_plat = display_plat .. '[[文件:Icon Nintendo switch.png|16px|link=曲目列表 (Nintendo Switch版)]]' NSid = mo2ns[id] end if display_plat == '' then display_plat = '无' end data:insert(display_plat) -- 图片 data:insert(id) -- 标题与副标题 otherTitles data:insert(input '标题' or table.concat({'[[' .. mad.linkTitle(song) .. ']]', unpack(otherTitles(song))}, '<br>')) -- 曲师 local artist1 = cLink.artistLink(song.artist) local artist2 = cLink.artistLink(song.difficulties[4] and song.difficulties[4].artist or nil) if artist2 == artist1 then artist2 = nil end local artist = artist1 .. (artist2 and '<br />' .. artist2 .. mad.color { rc = 4,txt = '[Beyond]',inline = true } or '') data:insert(input '音乐家' or artist) -- 曲包 local pack_main = trans.packName[song.set] or packItem['name'] local pack_ml = cLink.packLink(pack_main,1) if mobile_id[id] and ns_id[NSid] then local song_ns = ns_song[NSid] local packItem_ns = mad.packQueryWrap(song_ns.set, 'ns') local pack_ns = trans.packName[ns_song[NSid].set] or packItem_ns['name'] local pack_nl = cLink.packLink(pack_ns,1,1) if pack_ns == pack_main then if discrete_pack[pack_main] then pack = pack_ml .. onlyMobile .. '<br \>--<br \>' ..pack_nl .. onlyNS else pack = pack_ml end else pack = pack_ml .. onlyMobile .. '<br \>--<br \>' .. pack_nl .. onlyNS end elseif mobile_id[id] then pack = pack_ml .. onlyMobile else pack = pack_ml .. onlyNS end data:insert(input '所属曲包' or pack) -- 其他信息 local bpm = tonumber(input 'BPM') or song.bpm_base data:insert((tonumber(song.bpm) ~= bpm and ('data-sort-value=%s|'):format(bpm) or '') .. song.bpm) data:insert(durArgs[id] or ' @ ') data:insert(song.version .. '.' .. (input '收录版本' or verQuery(song.date))) -- 难度等级 local main_lv = {} local lv_table ={} for _,diff in pairs(song.difficulties) do main_lv[diff.ratingClass] = diff.rating .. (diff.ratingPlus and '+' or '') end if mobile_id[id] and ns_id[NSid] then local song_ns = ns_song[NSid] local ns_lv = {} local c_chart = {} for _,diff in pairs(song_ns.difficulties) do ns_lv[diff.ratingClass] = diff.rating .. (diff.ratingPlus and '+' or '') if diff.has_controller_alt_chart then c_chart[diff.ratingClass] = 1 end end for i = 0, 4 do local lv if main_lv[i] and ns_lv[i] then if main_lv[i] == ns_lv[i] then lv = main_lv[i] .. (c_chart[i] and ('<br />' .. ctrlTouch .. ctrlJC) or '') else -- lv = main_lv[i] .. onlyMobile .. '<br />' .. ns_lv[i] .. (c_chart[i] and (ctrlTouch ..onlyNS .. '<br />' .. ns_lv[i] .. ctrlJC .. onlyNS) or onlyNS) lv = main_lv[i] .. onlyMobile .. '<br \>' .. ns_lv[i] .. onlyNS .. (c_chart[i] and ('<br />' .. ctrlTouch ..ctrlJC) or '') end elseif main_lv[i] then lv = main_lv[i] .. onlyMobile elseif ns_lv[i] then lv = ns_lv[i] .. onlyNS else lv = '/' end lv_table[i] = lv end else for i = 0, 4 do local lv = main_lv[i] or '/' lv_table[i] = lv end end -- 顺序:PST PRS FTR ETR BYD local lv_order = {0, 1, 2, 4, 3} for i=1, #lv_order do local j = lv_order[i] data:insert(input('等级', j) or lv_table[j]) end end table.sort(view, function(a, b) a, b = a.sort, b.sort for i = 1, 3 do local d = a[i] - b[i] if d ~= 0 then return d < 0 end end return false end) local res = {} local template = '|-\n|%s' .. '||[[文件:Songs %s.jpg|75px]]' .. ('||%s'):rep(11) for idx, value in ipairs(view) do res[idx] = template:format(unpack(value.data)) end return table.concat(res, '\n') end function p.multi(frame) for record in mw.text.gsplit(frame.args._ver_, '%s') do local date, name = record:match '(%d+):(.*)' table.insert(dates, tonumber(date)) table.insert(versionNames, name) end return main(frame:getParent().args, frame.args) end return p
本页使用的模板:
Module:SongCollectionMulti/doc
(
查看源代码
)
返回
Module:SongCollectionMulti
。