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

нема опису редагування
Немає опису редагування
Немає опису редагування
 
(Не показані 4 проміжні версії цього користувача)
Рядок 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 category = mw.title.makeTitle(14, categoryName)  -- Namespace 14 for Category
     local players = {
    local members = category:getCategoryMembers()
        "Індиго", "Адамант", "Алоха", "Аріель", "Берлін", "Бетмен", "Браун", "ВВ",
     local output = '{| class="wikitable sortable" style="text-align:center;"\n! Учасник\n! Page Link\n'
        "Дантес", "Демон", "Джордж", "Доктор Хаус", "Доктор Ямато", "Емесай", "ЕХС", "Кексік",
        "Керміт", "Клайд", "Клей", "Комар", "Лемур", "Містер Тен", "Малена", "Мальвінка",
        "Маска", "Мері", "Механік", "Ніколетта", "Оттерія", "Расм", "Сімон", "Справа",
        "Тайєр", "Тян", "Фавер", "Фаза", "Фейт", "Хантер", "Хоррорчік", "Шостік"
    }
   
    -- 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


     -- Iterate through each member of the category
     -- Selecting the first four players after shuffling
     for _, member in ipairs(members) do
    local output = {}
         local title = member.fullText  -- Get the full text of the page title
     for i = 1, math.min(4, #players) do
        output = output .. '|-\n| ' .. title .. '\n| [[' .. title .. ']]\n'
         table.insert(output, string.format('<p>[[%s|%s]]</p>', players[i], players[i]))
     end
     end


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


return p
return p