Module:ChartConstant:修订间差异

来自Arcaea中文维基
无编辑摘要
(加点说明书()
 
(未显示6个用户的28个中间版本)
第1行: 第1行:
local mad = require 'Module:AnotherData'
local p = {}
local p = {}
local json = require("Module:LoadJson").ChartConstant()
-- ns待补充(ns也不需要这个)
-- 需要输出详表(如存档旧ptt数据)的话控制台直接print(p.detail())就行了


function cv()
local function itData(datas, cc)
local songlist = require("Module:LoadJson").Songlist()
cc = cc or 13
local list = {}
local step, format = unpack(cc > 11 and {1, '%d'} or {.1, '%.1f'})
for i,k in pairs(songlist['songs'])
cc = cc - step
do
local id = format:format(cc)
list[k['id']] = k['title_localized']['en']
local data = datas[id]
if not data then return nil end
return cc, id, data
end
function p.main()
local datas = {}
local songCcs = mw.text.jsonDecode(mw.title.new('ChartConstant.json', 'Template'):getContent())
for _, song in ipairs(mad.listOf 'songs') do
local id, titleBase, dateBase = song.id, mad.title(song), song.date
local songCc = songCcs[id] or {}
local link = mad.linkName(song) or titleBase
if not song.deleted then
for _, chart in ipairs {}, song.difficulties, 1 do
local rc = chart.ratingClass + 1
local chartCc = songCc[rc]
-- fk lua donot support continue. use single-loop & break for subst
repeat
if not chartCc or chartCc.old ~= false then break end
local nCc = chartCc.constant
if nCc < 8 then break end
local title, date = mad.title(chart) or titleBase, chart.date or dateBase
 
local rowId, sCc
if nCc >= 11 then
rowId = ('%d'):format(nCc)
sCc = ('%.1f'):format(nCc)
else
rowId = ('%.1f'):format(nCc)
end
local rowData = datas[rowId]
if not rowData then
rowData = {}
datas[rowId] = rowData
end
table.insert(rowData, {
data = {title, id, ({'PST', 'PRS', 'FTR', 'BYD', 'ETR'})[rc], link = link, CC = sCc},
sort = {nCc, rc, date}
})
until (true)
end
end
end
end
 
return list
local frame = mw.getCurrentFrame()
local text = mw.html.create 'div':addClass 'notaninfobox dstable'
for _, rowId, rowData in itData, datas do
text = text
:tag 'div':addClass 'ds':wikitext(rowId):done()
:tag 'div':addClass 'number'
:wikitext(frame:expandTemplate {title = '组排列', args = {height = 'auto'}})
table.sort(rowData, function(a, b)
a, b = a.sort, b.sort
if a[1] ~= b[1] then return a[1] > b[1] end
if a[2] ~= b[2] then return a[2] > b[2] end
return a[3] < b[3]
end)
for _, rowItem in ipairs(rowData) do
text:wikitext(frame:expandTemplate {title = '组排单元', args = rowItem.data})
end
text = text:wikitext(frame:expandTemplate {title = '组排列-end'}):done()
end
 
return tostring(text)
end
end


function p.main()
function p.detail()
local list = {}
local datas = {}
local name
local songCcs = mw.text.jsonDecode(mw.title.new('ChartConstant.json', 'Template'):getContent())
local cvList = cv()
for _, song in ipairs(mad.listOf 'songs') do
   for i, k in pairs(json)
if not song.deleted then
   do
local id = song.id
   if k[2] or k[3] or k[4]
local songCc = songCcs[id] or {}
   then
--
   name = cvList[i]
local data = {mad.linkTitle(song)}
   end
local sort = {0, song.date}
   if k[2] and tonumber(k[2]['constant'])>=8 and not(k[2]['old']) then
table.insert(datas, {data = data, sort = sort})
   table.insert(list, { i, name, k[2]['constant'], "PRS" })
for _, chart in ipairs(song.difficulties) do
   end
local rc = chart.ratingClass + 1
   if k[3] and tonumber(k[3]['constant'])>=8 and not(k[3]['old']) then
local chartCc = songCc[rc]
   table.insert(list, { i, name, k[3]['constant'], "FTR" })
repeat
   end
if not chartCc then break end
   if k[4] and tonumber(k[4]['constant'])>=8 and not(k[4]['old']) then
local nCc = chartCc.constant
   table.insert(list, { i, name, k[4]['constant'], "BYD" })
if not chart.date then sort[1] = nCc end
   end
local sCc = ('%.1f'):format(nCc)
   end
data[rc + 1] = chartCc.old ~= false and tostring(mw.html.create 'span':addClass 'old-constant':wikitext(sCc)) or sCc
  
until (true)
   local result = {}
end
  
for i = 2, 6 do
   result[11], result[12] = {}, {}
data[i] = data[i] or ' '
   for s, k in pairs(list) do
end
   if k[3]<11
end
   then
end
   if not(result[k[3]]) then result[k[3]]={} end
 
   table.insert(result[k[3]],mw.getCurrentFrame():expandTemplate { title = ' 组排单元', args = { k[2], k[1], k[4] } } )
table.sort(datas, function(a, b)
   else
a, b = a.sort, b.sort
   if k[3]<12
if a[1] == b[1] then return a[2] < b[2] end
   then
return a[1] > b[1]
   table.insert(result[11],mw.getCurrentFrame():expandTemplate { title = '组排单元', args = { k[2], k[1], k[4] } } )
end)
   else
   table.insert(result[12],mw.getCurrentFrame():expandTemplate { title = '组排单元', args = { k[2], k[1], k[4] } } )
   end
   end
   end


local textList = {}
local texts = {}
textList[1] = "<div class='notaninfobox dstable'>\n"
local template = '|-\n|[[%s]]' .. ('||%s'):rep(5)
textList[2]= "</div>"
for _, value in ipairs(datas) do
table.insert(texts, template:format(unpack(value.data)))
local sText = ""
for i,k in pairs(result)
do
sText = "<div class='ds'>"..string.format("%.1f", i).."</div>\n<div class='number'>"..mw.getCurrentFrame():expandTemplate { title = '组排列' }
..table.concat(k)..mw.getCurrentFrame():expandTemplate { title = '组排列-end' }.."</div>\n"
table.insert (textList, 2, sText)
end
end


  return table.concat(textList)
return table.concat(texts, '\n')
end
end


return p
return p

2024年11月18日 (一) 12:56的最新版本

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

local mad = require 'Module:AnotherData'
local p = {}
-- ns待补充(ns也不需要这个)
-- 需要输出详表(如存档旧ptt数据)的话控制台直接print(p.detail())就行了

local function itData(datas, cc)
	cc = cc or 13
	local step, format = unpack(cc > 11 and {1, '%d'} or {.1, '%.1f'})
	cc = cc - step
	local id = format:format(cc)
	local data = datas[id]
	if not data then return nil end
	return cc, id, data
end
function p.main()
	local datas = {}
	local songCcs = mw.text.jsonDecode(mw.title.new('ChartConstant.json', 'Template'):getContent())
	for _, song in ipairs(mad.listOf 'songs') do
		local id, titleBase, dateBase = song.id, mad.title(song), song.date
		local songCc = songCcs[id] or {}
		local link = mad.linkName(song) or titleBase
		if not song.deleted then
			for _, chart in ipairs {}, song.difficulties, 1 do
				local rc = chart.ratingClass + 1
				local chartCc = songCc[rc]
				-- fk lua donot support continue. use single-loop & break for subst
				repeat
					if not chartCc or chartCc.old ~= false then break end
					local nCc = chartCc.constant
					if nCc < 8 then break end
					local title, date = mad.title(chart) or titleBase, chart.date or dateBase

					local rowId, sCc
					if nCc >= 11 then
						rowId = ('%d'):format(nCc)
						sCc = ('%.1f'):format(nCc)
					else
						rowId = ('%.1f'):format(nCc)
					end
					local rowData = datas[rowId]
					if not rowData then
						rowData = {}
						datas[rowId] = rowData
					end
					table.insert(rowData, {
						data = {title, id, ({'PST', 'PRS', 'FTR', 'BYD', 'ETR'})[rc], link = link, CC = sCc},
						sort = {nCc, rc, date}
					})
				until (true)
			end
		end
	end

	local frame = mw.getCurrentFrame()
	local text = mw.html.create 'div':addClass 'notaninfobox dstable'
	for _, rowId, rowData in itData, datas do
		text = text
			:tag 'div':addClass 'ds':wikitext(rowId):done()
			:tag 'div':addClass 'number'
			:wikitext(frame:expandTemplate {title = '组排列', args = {height = 'auto'}})
		table.sort(rowData, function(a, b)
			a, b = a.sort, b.sort
			if a[1] ~= b[1] then return a[1] > b[1] end
			if a[2] ~= b[2] then return a[2] > b[2] end
			return a[3] < b[3]
		end)
		for _, rowItem in ipairs(rowData) do
			text:wikitext(frame:expandTemplate {title = '组排单元', args = rowItem.data})
		end
		text = text:wikitext(frame:expandTemplate {title = '组排列-end'}):done()
	end

	return tostring(text)
end

function p.detail()
	local datas = {}
	local songCcs = mw.text.jsonDecode(mw.title.new('ChartConstant.json', 'Template'):getContent())
	for _, song in ipairs(mad.listOf 'songs') do
		if not song.deleted then
			local id = song.id
			local songCc = songCcs[id] or {}
			--
			local data = {mad.linkTitle(song)}
			local sort = {0, song.date}
			table.insert(datas, {data = data, sort = sort})
			for _, chart in ipairs(song.difficulties) do
				local rc = chart.ratingClass + 1
				local chartCc = songCc[rc]
				repeat
					if not chartCc then break end
					local nCc = chartCc.constant
					if not chart.date then sort[1] = nCc end
					local sCc = ('%.1f'):format(nCc)
					data[rc + 1] = chartCc.old ~= false and tostring(mw.html.create 'span':addClass 'old-constant':wikitext(sCc)) or sCc
				until (true)
			end
			for i = 2, 6 do
				data[i] = data[i] or ' '
			end
		end
	end

	table.sort(datas, function(a, b)
		a, b = a.sort, b.sort
		if a[1] == b[1] then return a[2] < b[2] end
		return a[1] > b[1]
	end)

	local texts = {}
	local template = '|-\n|[[%s]]' .. ('||%s'):rep(5)
	for _, value in ipairs(datas) do
		table.insert(texts, template:format(unpack(value.data)))
	end

	return table.concat(texts, '\n')
end

return p