Module:Setlist/AlbumSelector: Difference between revisions

From TwentyOneWiki
Jump to navigation Jump to search
(Created page with "local p = {} -- ВСПОМОГАТЕЛЬНАЯ ФУНКЦИЯ: Получение года из названия страницы function p.extractYear(title) -- ищет ".20XX" или ".19XX" в конце строки local year = mw.ustring.match(title, "%.([12]%d%d%d)$") return year and tonumber(year) end -- Определяет альбом по году для песен, входящих в Regional At Best и Vessel function p.detectAlbumByYear(ye...")
 
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
-- Module:Setlist/AlbumSelector
local p = {}
local p = {}


-- ВСПОМОГАТЕЛЬНАЯ ФУНКЦИЯ: Получение года из названия страницы
-- Годы, при которых песня будет считаться из "Regional At Best"
function p.extractYear(title)
local rabYears = {
     -- ищет ".20XX" или ".19XX" в конце строки
     ["2009"] = true, ["2010"] = true, ["2011"] = true, ["2012"] = true
    local year = mw.ustring.match(title, "%.([12]%d%d%d)$")
}
    return year and tonumber(year)
end


-- Определяет альбом по году для песен, входящих в Regional At Best и Vessel
-- Годы, при которых песня будет считаться из "Vessel"
function p.detectAlbumByYear(year)
local vesselYears = {
     if not year then return "Vessel" end -- По умолчанию Vessel, если год не определен
    ["2013"] = true, ["2014"] = true, ["2015"] = true, ["2016"] = true,
     if year <= 2012 then
    ["2017"] = true, ["2018"] = true, ["2019"] = true, ["2020"] = true,
        return "Regional At Best"
    ["2021"] = true, ["2022"] = true, ["2023"] = true, ["2024"] = true, ["2025"] = true
     else
}
        return "Vessel"
 
     end
-- Перечень песен, которые одновременно находятся в RAB и Vessel
end
local conflictSongs = {
     ["Guns For Hands"] = true,
     ["Holding On To You"] = true,
    ["Ode To Sleep"] = true,
     ["Car Radio"] = true,
    ["Trees"] = true
}
 
-- Главная функция
function p.getAlbumForSong(songTitle)
     local page = mw.title.getCurrentTitle().text
    local year = string.match(page, '%.(%d%d%d%d)$')
 
    local data = mw.loadData('Module:Setlist/Songs')
    local original = data.songs[songTitle]


-- Выбирает альбом для песни на основе данных и года страницы
     if not original then
function p.selectAlbum(songTitle, albums, year)
         return nil
     if not albums then
         return { "Non-Album" }
     end
     end


    -- Проверяем, входит ли песня одновременно в Regional At Best и Vessel
     if conflictSongs[songTitle] and year then
     if #albums == 2 and
         if rabYears[year] then
      ((albums[1] == "Regional At Best" and albums[2] == "Vessel") or
            return {"Regional At Best"}
         (albums[1] == "Vessel" and albums[2] == "Regional At Best")) then
         elseif vesselYears[year] then
         local forcedAlbum = p.detectAlbumByYear(year)
            return {"Vessel"}
        return { forcedAlbum }
        end
     end
     end


    -- Для всех остальных песен возвращаем альбомы из data.songs
     return original
     return albums
end
end


return p
return p

Latest revision as of 19:23, 11 July 2025

Documentation for this module may be created at Module:Setlist/AlbumSelector/doc

-- Module:Setlist/AlbumSelector
local p = {}

-- Годы, при которых песня будет считаться из "Regional At Best"
local rabYears = {
    ["2009"] = true, ["2010"] = true, ["2011"] = true, ["2012"] = true
}

-- Годы, при которых песня будет считаться из "Vessel"
local vesselYears = {
    ["2013"] = true, ["2014"] = true, ["2015"] = true, ["2016"] = true,
    ["2017"] = true, ["2018"] = true, ["2019"] = true, ["2020"] = true,
    ["2021"] = true, ["2022"] = true, ["2023"] = true, ["2024"] = true, ["2025"] = true
}

-- Перечень песен, которые одновременно находятся в RAB и Vessel
local conflictSongs = {
    ["Guns For Hands"] = true,
    ["Holding On To You"] = true,
    ["Ode To Sleep"] = true,
    ["Car Radio"] = true,
    ["Trees"] = true
}

-- Главная функция
function p.getAlbumForSong(songTitle)
    local page = mw.title.getCurrentTitle().text
    local year = string.match(page, '%.(%d%d%d%d)$')

    local data = mw.loadData('Module:Setlist/Songs')
    local original = data.songs[songTitle]

    if not original then
        return nil
    end

    if conflictSongs[songTitle] and year then
        if rabYears[year] then
            return {"Regional At Best"}
        elseif vesselYears[year] then
            return {"Vessel"}
        end
    end

    return original
end

return p