FANDOM


local p = {}
 
local quest = require('Module:Quest')
local unit = require('Module:Unit')
 
local function push_time_range(result, columns)
    result[#result+1] = '|-\n| '
    result[#result+1] = columns[1]
    result[#result+1] = '時~'
    if columns[2] ~= '' then
        result[#result+1] = columns[2]
        result[#result+1] = '時'
    end
end
 
function p.Daily(frame)
    local rows = mw.text.split(frame.args[1], '\n')
    local result = {'<center><div class=titleBar3>緊急/亂入時間表</div></center>\n\n'}
    local classname = ''
    for i, row in ipairs(rows) do
        local columns = mw.text.split(row, ',')
        if #columns == 2 then
            result[#result+1] = '{| class="wikitable daily-event-table '
            result[#result+1] = classname
            result[#result+1] = '"\n!colspan=3| '
            result[#result+1] = columns[1]
            result[#result+1] = '\n'
        elseif row == 'end' then
            result[#result+1] = '|}\n'
            if classname == '' then
                classname = 'mw-collapsible mw-collapsed'
                result[#result+1] = '{| class="mw-collapsible mw-collapsed wikitable future-events-table"\n! 未來活動\n|-\n|\n'
            end
        elseif #columns == 3 then
            push_time_range(result, columns)
            result[#result+1] = '\n|colspan=2| '
            result[#result+1] = quest.DLink{args={columns[3], text='yes'}}
            result[#result+1] = '\n'
        elseif #columns == 4 then
            push_time_range(result, columns)
            result[#result+1] = '\n| '
            if columns[3] == 'any-jotunn' then
                result[#result+1] = 'ヨトゥン:?号機 亂入\n| '
            else
                result[#result+1] = unit.Monster{args={columns[3]}}
                result[#result+1] = ' 亂入\n| '
            end
            result[#result+1] = quest.QLinkLong{args={columns[4]}}
            result[#result+1] = '\n'
        end
    end
    result[#result+1] = '|}\n\n*港台時區 (UTC+8)<div style="float:right">['
    result[#result+1] = mw.site.server
    result[#result+1] = '/wiki/Template:緊急時間表?action=edit&editintro=Template:緊急時間表說明 協助更新]</div>'
    return table.concat(result)
end
 
local special_weekly_events = {
    {'炎聖石殿ロストロスVIP', '水聖石殿ロストロスVIP', '風聖石殿ロストロスVIP', '光聖石殿ロストロスVIP', '闇聖石殿ロストロスVIP', '無聖石殿ロストロスVIP',  'カラフルラッシュVIP', '黄金郷エルドラドⅠ', '黄金郷エルドラドⅡ'},
    {'闇聖石殿ロストロスVIP'},
    {'炎聖石殿ロストロスVIP'},
    {'水聖石殿ロストロスVIP'},
    {'風聖石殿ロストロスVIP'},
    {'光聖石殿ロストロスVIP'},
    {'無聖石殿ロストロスVIP', '黄金郷エルドラドⅠ', '黄金郷エルドラドⅡ'},
}
 
local function push_event(res, begin_time, end_time, event)
    res[#res+1] = '\n|-\n|class=eStart| '
    res[#res+1] = begin_time
    res[#res+1] = '\n|class=eEnd| '
    res[#res+1] = end_time
    res[#res+1] = '\n| '
    if mw.ustring.sub(event, -2, -1) == '亂入' then
        res[#res+1] = unit.Monster{args={mw.ustring.sub(event, 1, -3)}}
        res[#res+1] = ' 亂入'
    else
        local dlink_res = quest.DLink{args={event, text='yes', allow_fail=true}}
        res[#res+1] = dlink_res or event
    end
end
 
function p.Weekly(frame)
    local res = {'<center><div class=titleBar3>活動時間表</div></center>\n\n{| class="wikitable shadow" id=currentEvents\n|-\n!width=16%| 開始\n!width=16%| 結束\n! 活動/副本'}
 
    local now = os.time()
    local jst_now = now + 9*3600
    local day_begin = (jst_now - jst_now % 86400) - 1*3600
    local day_end = day_begin + 86400
 
    local day_begin_str = os.date('!%m月%d日%H時', day_begin)
    local day_end_str = os.date('!%m月%d日%H時', day_end)
 
    local weekday = os.date('!%w', day_end) + 1
    for _, event in ipairs(special_weekly_events[weekday]) do
        push_event(res, day_begin_str, day_end_str, event)
    end
 
    local rows = mw.text.split(frame.args[1], '\n')
    local time_begin, time_end
    for _, row in ipairs(rows) do
        if row ~= '' then
            local s, e = mw.ustring.match(row, '^%*([^--]+)[--]([^--]+)$')
            if s then
                time_begin = s
                time_end = e
            else
                push_event(res, time_begin, time_end, row)
            end
        end
    end
 
    res[#res+1] = '\n|}\n\n*港台時區 (UTC+8)<div style="float:right">['
    res[#res+1] = mw.site.server
    res[#res+1] = '/wiki/Template:活動時間表?action=edit&editintro=Template:活動時間表說明 協助更新]</div>'
 
    return table.concat(res)
end
 
return p
除了特别提示,社区内容遵循CC-BY-SA 授权许可。