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

нема опису редагування
Немає опису редагування
Мітка: Ручний відкіт
Немає опису редагування
Рядок 390: Рядок 390:


local function get_tournament_link(header_name)
local function get_tournament_link(header_name)
     local season_num = mw.ustring.match(header_name, "([А-Яа-яЁёІіЏїЄєҐґ']+) сезон %(фінал%)")
     local season_num = mw.ustring.match(header_name, "([А-Яа-яЁёІіЇїЄєҐґ']+) сезон %(фінал%)")
     if not season_num then
     if not season_num then
         season_num = mw.ustring.match(header_name, "([А-Яа-яЁёІіЇїЄєҐґ']+) сезон %(рейтинг%)")
         season_num = mw.ustring.match(header_name, "([А-Яа-яЁёІіЇїЄєҐґ']+) сезон %(рейтинг%)")
Рядок 593: Рядок 593:


-- ================================================
-- ================================================
-- FETCHDATA5 (записи ігор)
-- FETCHDATA5 (записи ігор) - ОНОВЛЕНО З ЧАСОМ
-- ================================================
-- ================================================


Рядок 609: Рядок 609:


local function get_player_role(player_name, cells)
local function get_player_role(player_name, cells)
     for i = 5, 10 do
    -- ОНОВЛЕНО: після додавання колонки "Час", гравці тепер в позиціях 6-15
     for i = 6, 11 do -- 6 мирних
         if cells[i] and clean_wikilinks(cells[i]) == player_name then
         if cells[i] and clean_wikilinks(cells[i]) == player_name then
             return "Мирний"
             return "Мирний"
Рядок 615: Рядок 616:
     end
     end
      
      
     if cells[11] and clean_wikilinks(cells[11]) == player_name then
     if cells[12] and clean_wikilinks(cells[12]) == player_name then -- Шериф
         return "Шериф"
         return "Шериф"
     end
     end
      
      
     for i = 12, 13 do
     for i = 13, 14 do -- 2 мафії
         if cells[i] and clean_wikilinks(cells[i]) == player_name then
         if cells[i] and clean_wikilinks(cells[i]) == player_name then
             return "Мафія"
             return "Мафія"
Рядок 625: Рядок 626:
     end
     end
      
      
     if cells[14] and clean_wikilinks(cells[14]) == player_name then
     if cells[15] and clean_wikilinks(cells[15]) == player_name then -- Дон
         return "Дон"
         return "Дон"
     end
     end
Рядок 659: Рядок 660:
          
          
         local player_in_game = false
         local player_in_game = false
         for i = 5, 14 do
        -- ОНОВЛЕНО: гравці тепер в колонках 6-15
         for i = 6, 15 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
Рядок 666: Рядок 668:
         end
         end
          
          
         if player_in_game and #cells >= 15 then
         if player_in_game and #cells >= 17 then
             local role = get_player_role(player_name, cells)
             local role = get_player_role(player_name, cells)
             local result = get_player_result(role, cells[15])
             local result = get_player_result(role, cells[16])
              
              
             table.insert(games, {
             table.insert(games, {
                 tournament = cells[3] or "",
                 tournament = clean_wikilinks(cells[4]) or "", -- Турнір (колонка 4)
                 short = cells[4] or "",
                short = cells[3] or "", -- Скорочення (колонка 3)
                 time = cells[5] or "", -- ЧАС (НОВА КОЛОНКА 5!)
                 role = role,
                 role = role,
                 result = result,
                 result = result,
                 link = cells[16] or ""
                 link = cells[17] or "" -- Посилання (колонка 17)
             })
             })
         end
         end
Рядок 705: Рядок 708:
     local headerRow = htmlTable:tag('tr')
     local headerRow = htmlTable:tag('tr')
     headerRow:tag('th'):wikitext('Турнір')
     headerRow:tag('th'):wikitext('Турнір')
    headerRow:tag('th'):wikitext('Час') -- НОВА КОЛОНКА!
     headerRow:tag('th'):wikitext('Роль')
     headerRow:tag('th'):wikitext('Роль')
     headerRow:tag('th'):wikitext('Результат')
     headerRow:tag('th'):wikitext('Результат')
Рядок 714: Рядок 718:
         row:tag('td'):css('text-align', 'center'):css('padding', '8px')
         row:tag('td'):css('text-align', 'center'):css('padding', '8px')
             :wikitext(get_tournament_link_games(game.short, game.tournament))
             :wikitext(get_tournament_link_games(game.short, game.tournament))
       
        -- НОВА КОЛОНКА - ЧАС
        row:tag('td'):css('text-align', 'center'):css('padding', '8px')
            :wikitext(game.time)
          
          
         row:tag('td'):css('text-align', 'center'):css('padding', '8px'):wikitext(game.role)
         row:tag('td'):css('text-align', 'center'):css('padding', '8px'):wikitext(game.role)