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

нема опису редагування
Немає опису редагування
Немає опису редагування
Рядок 411: Рядок 411:
     end
     end
      
      
     -- Дата
     -- Дата (рахуємо до 26.10.2024)
     local date_added = "Лише Бог знає"
     local date_added = "Лише Бог знає"
     if player_info and #player_info >= 3 then
     if player_info and #player_info >= 3 then
Рядок 418: Рядок 418:
             local day, month, year = mw.ustring.match(raw_date, "(%d+)%.(%d+)%.(%d+)")
             local day, month, year = mw.ustring.match(raw_date, "(%d+)%.(%d+)%.(%d+)")
             if day and month and year then
             if day and month and year then
                 local end_date = os.time({year=2024, month=12, day=1})
                 local end_date = os.time({year=2024, month=10, day=26})
                 local start_date = os.time({year=tonumber(year), month=tonumber(month), day=tonumber(day)})
                 local start_date = os.time({year=tonumber(year), month=tonumber(month), day=tonumber(day)})
                 local days_diff = math.floor((end_date - start_date) / 86400)
                 local days_diff = math.floor((end_date - start_date) / 86400)
Рядок 426: Рядок 426:
     end
     end
      
      
     -- Recruiter (ВИПРАВЛЕННЯ: колонка 2, а не cells[2])
     -- Recruiter (залишаємо з вікілінком)
     local recruiter = "Не вказано"
     local recruiter = "Не вказано"
     if player_info and #player_info >= 4 then
     if player_info and #player_info >= 4 then
         local raw = mw.text.trim(player_info[4])  -- ВИПРАВЛЕНО: колонка 4 (№, Пан/Пані, Дата, Рекрутер)
         local raw = mw.text.trim(player_info[4])
         if raw ~= "Відсутній" and raw ~= "-" and raw ~= "" then
         if raw ~= "Відсутній" and raw ~= "-" and raw ~= "" then
             recruiter = raw
             recruiter = raw -- Залишаємо [[Демон]] як є
         end
         end
     end
     end
Рядок 448: Рядок 448:
     table.insert(output, "| nickname = " .. player_name)
     table.insert(output, "| nickname = " .. player_name)
      
      
     if stats and #stats >= 5 then
     -- ВИПРАВЛЕНО: Правильна структура таблиці Статистика
        -- ВИПРАВЛЕННЯ: Правильна структура колонок (, Пан/Пані, Ігри, Виграші, Поразки, %)
    -- Колонки: | Пан/Пані | Ігри | Виграші | Поразки | %
         table.insert(output, "| games = " .. (clean_wikilinks(stats[2]) or "0"))
    if stats and #stats >= 6 then
         table.insert(output, "| wins = " .. (stats[3] or "0"))
         local games = stats[3] or "0"
         table.insert(output, "| losses = " .. (stats[4] or "0"))
         local wins = stats[4] or "0"
         local winrate = stats[5] or "0"
         local losses = stats[5] or "0"
         local winrate = stats[6] or "0"
       
        -- Видаляємо % з winrate
         winrate = mw.ustring.gsub(winrate, "%%", "")
         winrate = mw.ustring.gsub(winrate, "%%", "")
        winrate = mw.text.trim(winrate)
       
        table.insert(output, "| games = " .. games)
        table.insert(output, "| wins = " .. wins)
        table.insert(output, "| losses = " .. losses)
         table.insert(output, "| winrate = " .. winrate)
         table.insert(output, "| winrate = " .. winrate)
     else
     else
Рядок 467: Рядок 475:
     table.insert(output, "| date_added = " .. date_added)
     table.insert(output, "| date_added = " .. date_added)
      
      
    -- Foundation (колонка 3 в таблиці Фундація: № | Пан/Пані | Сума)
     if foundation and #foundation >= 3 then
     if foundation and #foundation >= 3 then
         local found = mw.ustring.gsub(foundation[3] or "0", "[^%d]", "")
         local found = mw.ustring.gsub(foundation[3] or "0", "[^%d]", "")
Рядок 474: Рядок 483:
     end
     end
      
      
    -- Prize pool (колонка 2 в таблиці Призовий_фонд: № | Сума)
     if prize_pool and #prize_pool >= 2 then
     if prize_pool and #prize_pool >= 2 then
         local prize = mw.ustring.gsub(prize_pool[2] or "0", "[^%d]", "")
         local prize = mw.ustring.gsub(prize_pool[2] or "0", "[^%d]", "")
Рядок 481: Рядок 491:
     end
     end
      
      
    -- Finalist (колонка 3 в таблиці Фіналіст: № | Пан/Пані | К-сть)
     if finalist and #finalist >= 3 then
     if finalist and #finalist >= 3 then
         local fin = mw.ustring.gsub(finalist[3] or "0", "[^%d]", "")
         local fin = mw.ustring.gsub(finalist[3] or "0", "[^%d]", "")