497
次編輯
(bruh bruh bruh) |
(强制免费曲在第一个,两个付费曲按更新时间排序;加入delay参数表示几天后) |
||
第33行: | 第33行: | ||
-- time: unix时间戳 | -- time: unix时间戳 | ||
-- date: YYYY/MM/DD格式的时间, 按这一天的北京时间12:30算 | -- date: YYYY/MM/DD格式的时间, 按这一天的北京时间12:30算 | ||
-- delay: 在得到的时间基础上再往后若干天 | |||
-- 优先级: time > date > 读取当前时间 | -- 优先级: time > date > 读取当前时间 | ||
local time = args['time'] or dateStringToTime(args['date']) or os.time() | local time = args['time'] or dateStringToTime(args['date']) or os.time() | ||
time=time+86400*(args['delay'] or 0) | |||
local seed = math.floor((time-144e2)/864e2) | local seed = math.floor((time-144e2)/864e2) | ||
initRandomizer(seed) | initRandomizer(seed) | ||
local length=5000 | local length=5000 | ||
local arr={} | local arr={} | ||
第49行: | 第52行: | ||
arr[swapPos]=temp | arr[swapPos]=temp | ||
end | end | ||
local | |||
local | local resultFree={} | ||
local | local currentFreeCount=0 | ||
local | local resultPaid={} | ||
local currentPaidCount=0 | |||
local songSize=table.getn(songlist) | local songSize=table.getn(songlist) | ||
for i=0,length-1,1 do | for i=0,length-1,1 do | ||
if | if currentFreeCount+currentPaidCount>=3 then break end | ||
local value=arr[i] | local value=arr[i] | ||
if value<songSize then | if value<songSize then | ||
local info=songlist[value+1] | local info=songlist[value+1] | ||
if info.set=='base' or info.id=='innocence' then | if info.set=='base' or info.id=='innocence' then | ||
if | if currentFreeCount<1 then | ||
currentFreeCount=currentFreeCount+1 | |||
resultFree[currentFreeCount]=info | |||
end | end | ||
else | else | ||
if | if currentPaidCount<2 then | ||
currentPaidCount=currentPaidCount+1 | |||
resultPaid[currentPaidCount]=info | |||
end | end | ||
end | end | ||
end | end | ||
end | end | ||
local result | |||
if resultPaid[1].date<resultPaid[2].date then | |||
result={resultFree[1],resultPaid[1],resultPaid[2]} | |||
else | |||
result={resultFree[1],resultPaid[2],resultPaid[1]} | |||
end | |||
local frame = mw.getCurrentFrame() | local frame = mw.getCurrentFrame() | ||
local text = mw.html.create 'div' | local text = mw.html.create 'div' |
次編輯