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

нема опису редагування
(Створена сторінка: local p = {} --- Функція для виведення помилки local function error_output(context, error_details) local safe_details = error_details or "N/A" return string.format("<span style='color:red; font-weight:bold;'>[Games Error: %s. Details: %s]</span>", context or "Unknown Context", safe_details) end --- Видаляє вікі-посилання link local function clean_wikilinks(text) if not text then retu...)
 
Немає опису редагування
Рядок 19: Рядок 19:
local function get_player_role(player_name, cells)
local function get_player_role(player_name, cells)
     -- Колонки: 1-Формат, 2-Тип, 3-Турнір, 4-Скорочення
     -- Колонки: 1-Формат, 2-Тип, 3-Турнір, 4-Скорочення
     -- 5-11: Мирні (6 гравців)
     -- 5-10: Мирні (6 гравців)
     -- 12: Шериф
     -- 11: Шериф
     -- 13-14: Мафія (2 гравці)
     -- 12-13: Мафія (2 гравці)
     -- 15: Дон
     -- 14: Дон
     -- 16: Результат
     -- 15: Результат
     -- 17: Посилання
     -- 16: Посилання
      
      
     for i = 5, 11 do
    -- Перевіряємо Мирних (колонки 5-10)
     for i = 5, 10 do
         if cells[i] and clean_wikilinks(cells[i]) == player_name then
         if cells[i] and clean_wikilinks(cells[i]) == player_name then
             if i == 11 then
             return "Мирний"
                return "Шериф"
            else
                return "Мирний"
            end
         end
         end
     end
     end
      
      
     -- Перевіряємо Шерифа (колонка 12)
     -- Перевіряємо Шерифа (колонка 11)
     if cells[12] and clean_wikilinks(cells[12]) == player_name then
     if cells[11] and clean_wikilinks(cells[11]) == player_name then
         return "Шериф"
         return "Шериф"
     end
     end
      
      
     -- Перевіряємо Мафію (колонки 13-14)
     -- Перевіряємо Мафію (колонки 12-13)
     for i = 13, 14 do
     for i = 12, 13 do
         if cells[i] and clean_wikilinks(cells[i]) == player_name then
         if cells[i] and clean_wikilinks(cells[i]) == player_name then
             return "Мафія"
             return "Мафія"
Рядок 48: Рядок 45:
     end
     end
      
      
     -- Перевіряємо Дона (колонка 15)
     -- Перевіряємо Дона (колонка 14)
     if cells[15] and clean_wikilinks(cells[15]) == player_name then
     if cells[14] and clean_wikilinks(cells[14]) == player_name then
         return "Дон"
         return "Дон"
     end
     end
Рядок 61: Рядок 58:
         return "Невідомо"
         return "Невідомо"
     end
     end
   
    game_result = mw.text.trim(game_result)
      
      
     -- Місто перемогло
     -- Місто перемогло
Рядок 138: Рядок 137:
         -- Перевіряємо чи гравець є в цій грі
         -- Перевіряємо чи гравець є в цій грі
         local player_in_game = false
         local player_in_game = false
         for i = 5, 15 do
         for i = 5, 14 do
             if cells[i] and clean_wikilinks(cells[i]) == player_name then
             if cells[i] and clean_wikilinks(cells[i]) == player_name then
                 player_in_game = true
                 player_in_game = true
Рядок 145: Рядок 144:
         end
         end
          
          
         if player_in_game and #cells >= 16 then
         if player_in_game and #cells >= 15 then
             local format = cells[1] or ""
             local format = cells[1] or ""
             local type_game = cells[2] or ""
             local type_game = cells[2] or ""
             local tournament = cells[3] or ""
             local tournament = cells[3] or ""
             local short_name = cells[4] or ""
             local short_name = cells[4] or ""
             local game_result = cells[16] or ""
             local game_result = cells[15] or ""
             local link = cells[17] or ""
             local link = cells[16] or ""
              
              
             local role = get_player_role(player_name, cells)
             local role = get_player_role(player_name, cells)