1,109
个编辑
(创建页面,内容为“local p = "" --local songlist = require("Module:Songlist") function p.calc_song_conut() return "hello world!" end return p”) |
小无编辑摘要 |
||
第1行: | 第1行: | ||
local p = | local p = {} | ||
function p. | function p.get_total_song() | ||
return | 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 | end | ||
return p | return p |
个编辑