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

429 байтів додано ,  У неділю о 00:34
нема опису редагування
Немає опису редагування
Немає опису редагування
Рядок 666: Рядок 666:
      
      
     return cells
     return cells
end
local function has_unknown_roles(cells)
    local res = cells[16]
    if not res or mw.text.trim(res) == "" then return true end
    return mw.ustring.find(res, "?", 1, true) ~= nil
end
end


local function get_player_role(player_name, cells)
local function get_player_role(player_name, cells)
    if has_unknown_roles(cells) then return "—" end
     -- Колонки 6-11: мирні
     -- Колонки 6-11: мирні
     for i = 6, 11 do
     for i = 6, 11 do
Рядок 697: Рядок 704:


local function get_player_result(role, game_result)
local function get_player_result(role, game_result)
     if not game_result or game_result == "" then return "Невідомо" end
     if not game_result or game_result == "" then return "" end
   
 
     game_result = mw.text.trim(game_result)
     game_result = mw.text.trim(game_result)
      
 
     -- Маркер невідомості: ролі не читаються, отже і результат гравця теж
    if mw.ustring.find(game_result, "?", 1, true) then return "—" end
 
     if game_result == "Місто" or game_result == "Мирні" then
     if game_result == "Місто" or game_result == "Мирні" then
         return (role == "Мир" or role == "Шер") and "Перемога" or "Поразка"
         return (role == "Мир" or role == "Шер") and "Перемога" or "Поразка"
     end
     end
   
 
     if game_result == "Мафія" then
     if game_result == "Мафія" then
         return (role == "Маф" or role == "Дон") and "Перемога" or "Поразка"
         return (role == "Маф" or role == "Дон") and "Перемога" or "Поразка"
     end
     end
   
 
     return "Невідомо"
     return ""
end
end


Рядок 798: Рядок 808:
          
          
       -- Роль (білий колір)
       -- Роль (білий колір)
        -- Роль
         local roleCell = row:tag('td')
         local roleCell = row:tag('td')
             :css('text-align', 'center')
             :css('text-align', 'center')
             :css('padding', '8px')
             :css('padding', '8px')
       
 
         roleCell:tag('span')
         roleCell:tag('span')
             :css('color', '#fff')
             :css('color', game.role == "—" and '#777' or '#fff')
             :wikitext(game.role)
             :wikitext(game.role)
       
 
         -- Час
         -- Час
         row:tag('td')
         row:tag('td')
Рядок 811: Рядок 822:
             :css('padding', '8px')
             :css('padding', '8px')
             :wikitext(game.time)
             :wikitext(game.time)
       
 
         -- Результат (з кольором)
         -- Результат
         local resultCell = row:tag('td')
         local resultCell = row:tag('td')
             :css('text-align', 'center')
             :css('text-align', 'center')
             :css('padding', '8px')
             :css('padding', '8px')
       
 
         if game.result == "Перемога" then
         if game.result == "Перемога" then
             resultCell:tag('span')
             resultCell:tag('span')
                 :css('color', '#4caf50')
                 :css('color', '#4caf50')
                 :wikitext('В')
                 :wikitext('В')
      elseif game.result == "Поразка" then
        elseif game.result == "Поразка" then
             resultCell:tag('span')
             resultCell:tag('span')
                 :css('color', 'indianred')
                 :css('color', 'indianred')
                 :wikitext('П')
                 :wikitext('П')
         else
         else
             resultCell:wikitext(game.result)
             resultCell:tag('span'):css('color', '#777'):wikitext('—')
         end
         end