Module:沙盒/锦年、/testlua
可在Module:沙盒/锦年、/testlua/doc创建此模块的帮助文档
local p = {}
function p.get_total_song()
local songlist = require("Module:Songlist")['songs']
local total_song = 0
for idx,song in pairs(songlist) do
total_song = total_song + 1
end
return total_song
end
function p.get_max_ptt()
local TotalPtt = {0.0,0.0,0.0}
local maxIndex = 1
local ConstantList = {}
local ChartConstant = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'ChartConstant.json' } )
for CIndex,Charts in pairs(ChartConstant) do
for DIndex,CDiff in pairs(Charts) do
table.insert(ConstantList,CDiff.constant)
end
end
table.sort(ConstantList,function(a,b)
if a> b then
return true
else
return false
end
end)
while maxIndex <= 30
do
if maxIndex <= 10 then
TotalPtt[3] = TotalPtt[3] + (ConstantList[maxIndex] + 2)
end
TotalPtt[2] = TotalPtt[2] + (ConstantList[maxIndex] + 2)
maxIndex = maxIndex + 1
end
TotalPtt[1] = (TotalPtt[2] + TotalPtt[3]) / 40
TotalPtt[3] = TotalPtt[3] / 10
TotalPtt[2] = TotalPtt[2] / 30
return TotalPtt
end
return p