5233
редагування
Admin (обговорення | внесок) (Створена сторінка: local p = {} -- ================================================ -- УТИЛІТИ -- ================================================ local function get_table_from_page(page_name) local title = mw.title.new(page_name) if not title or not title.exists then return nil end local content = title:getContent() if not content then return nil end local table_start = mw.ustring.find(content, "{|") local table_end = mw.ustring.fi...) |
Admin (обговорення | внесок) Немає опису редагування |
||
| Рядок 209: | Рядок 209: | ||
local function generate_titles(player_name) | local function generate_titles(player_name) | ||
local titles_data = get_player_row_with_headers("Титули", player_name) | local titles_data = get_player_row_with_headers("Титули", player_name) | ||
if not titles_data then return " | if not titles_data then return "''Відсутні''" end | ||
local prize_data = get_player_row_with_headers("Призові", player_name) | local prize_data = get_player_row_with_headers("Призові", player_name) | ||
if not prize_data then return " | if not prize_data then return "''Помилка: не знайдено призові''" end | ||
local results = {} | local results = {} | ||
| Рядок 249: | Рядок 249: | ||
end | end | ||
if #results == 0 then return " | if #results == 0 then return "''Відсутні''" end | ||
local output = {} | local output = {} | ||
table.insert(output, "{| class=\"wikitable sortable\" style=\"font-size: 14.5px;\"") | table.insert(output, "{| class=\"wikitable sortable\" style=\"font-size: 14.5px;\"") | ||
| Рядок 427: | Рядок 426: | ||
end | end | ||
-- Recruiter | -- Recruiter (ВИПРАВЛЕННЯ: колонка 2, а не cells[2]) | ||
local recruiter = "Не вказано" | local recruiter = "Не вказано" | ||
if player_info and #player_info >= | if player_info and #player_info >= 4 then | ||
local raw = mw.text.trim(player_info[ | local raw = mw.text.trim(player_info[4]) -- ВИПРАВЛЕНО: колонка 4 (№, Пан/Пані, Дата, Рекрутер) | ||
if raw ~= "Відсутній" and raw ~= "-" and raw ~= "" then | if raw ~= "Відсутній" and raw ~= "-" and raw ~= "" then | ||
recruiter = raw | recruiter = raw | ||
| Рядок 450: | Рядок 449: | ||
if stats and #stats >= 5 then | if stats and #stats >= 5 then | ||
table.insert(output, "| games = " .. (stats[2] or "0")) | -- ВИПРАВЛЕННЯ: Правильна структура колонок (№, Пан/Пані, Ігри, Виграші, Поразки, %) | ||
table.insert(output, "| games = " .. (clean_wikilinks(stats[2]) or "0")) | |||
table.insert(output, "| wins = " .. (stats[3] or "0")) | table.insert(output, "| wins = " .. (stats[3] or "0")) | ||
table.insert(output, "| losses = " .. (stats[4] or "0")) | table.insert(output, "| losses = " .. (stats[4] or "0")) | ||
table.insert(output, "| winrate = " .. | local winrate = stats[5] or "0" | ||
winrate = mw.ustring.gsub(winrate, "%%", "") | |||
table.insert(output, "| winrate = " .. winrate) | |||
else | else | ||
table.insert(output, "| games = 0") | table.insert(output, "| games = 0") | ||
| Рядок 465: | Рядок 467: | ||
table.insert(output, "| date_added = " .. date_added) | table.insert(output, "| date_added = " .. date_added) | ||
if foundation and #foundation >= | if foundation and #foundation >= 3 then | ||
local found = mw.ustring.gsub(foundation[ | local found = mw.ustring.gsub(foundation[3] or "0", "[^%d]", "") | ||
table.insert(output, "| foundation = " .. found) | table.insert(output, "| foundation = " .. found) | ||
else | else | ||
| Рядок 479: | Рядок 481: | ||
end | end | ||
if finalist and #finalist >= | if finalist and #finalist >= 3 then | ||
local fin = mw.ustring.gsub(finalist[ | local fin = mw.ustring.gsub(finalist[3] or "0", "[^%d]", "") | ||
table.insert(output, "| finalist = " .. fin) | table.insert(output, "| finalist = " .. fin) | ||
else | else | ||