Модуль:Players: відмінності між версіями

476 байтів додано ,  22 квітня 2024
нема опису редагування
Немає опису редагування
Немає опису редагування
 
(Не показано 5 проміжних версій цього користувача)
Рядок 1: Рядок 1:
local p = {}
local p = {}


function p.fetchCategoryData(frame)
function p.showRandomPlayers(frame)
     local categoryName = "Учасники_спільноти_MCC" -- The category to fetch from
    -- List of players provided
     local count = mw.site.stats.pagesInCategory(categoryName, 'all')  -- Get the number of pages
     local players = {
    local pages = mw.site.pagesInCategory(categoryName, 'all', count)  -- Fetch all pages in the category
        "Індиго", "Адамант", "Алоха", "Аріель", "Берлін", "Бетмен", "Браун", "ВВ",
        "Дантес", "Демон", "Джордж", "Доктор Хаус", "Доктор Ямато", "Емесай", "ЕХС", "Кексік",
        "Керміт", "Клайд", "Клей", "Комар", "Лемур", "Містер Тен", "Малена", "Мальвінка",
        "Маска", "Мері", "Механік", "Ніколетта", "Оттерія", "Расм", "Сімон", "Справа",
        "Тайєр", "Тян", "Фавер", "Фаза", "Фейт", "Хантер", "Хоррорчік", "Шостік"
    }
   
    -- Shuffling the list to randomize
     for i = #players, 2, -1 do
        local j = math.random(i)
        players[i], players[j] = players[j], players[i]
    end


     -- Start the wikitable
     -- Selecting the first four players after shuffling
     local output = '{| class="wikitable sortable" style="text-align:center;"\n! Учасник\n! Page Link\n'
     local output = {}
   
     for i = 1, math.min(4, #players) do
    -- Add rows to the wikitable
         table.insert(output, string.format('<p>[[%s|%s]]</p>', players[i], players[i]))
     for title in pages do
         output = output .. '|-\n| ' .. title.fullText .. '\n| [[' .. title.fullText .. ']]\n'
     end
     end


     -- Close the wikitable
     return table.concat(output, "\n")
    output = output .. '|}\n'
    return output
end
end


return p
return p