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

нема опису редагування
Немає опису редагування
Немає опису редагування
Рядок 91: Рядок 91:
end
end


--- Головна функція для виведення ігор гравця
--- Отримує список ігор гравця
function p.player_games(frame)
local function get_player_games_list(player_name)
    local player_name = frame.args.player
   
    if not player_name or player_name == "" then
        return error_output("No Player Name", "")
    end
   
     local title = mw.title.new("Ігри")
     local title = mw.title.new("Ігри")
     if not title or not title.exists then  
     if not title or not title.exists then  
         return error_output("Page Missing", "Ігри")
         return nil
     end
     end
      
      
     local content = title:getContent()
     local content = title:getContent()
     if not content then  
     if not content then  
         return error_output("Content Read Fail", "Ігри")
         return nil
     end
     end
      
      
Рядок 114: Рядок 108:
      
      
     if not table_start or not table_end then
     if not table_start or not table_end then
         return error_output("Table Missing", "Ігри")
         return nil
     end
     end
      
      
Рядок 174: Рядок 168:
             })
             })
         end
         end
    end
   
    return games
end
--- Головна функція для виведення ігор гравця
function p.player_games(frame)
    local player_name = frame.args.player
   
    if not player_name or player_name == "" then
        return error_output("No Player Name", "")
    end
   
    local games = get_player_games_list(player_name)
   
    if not games then
        return error_output("Cannot Load Games", "Ігри")
     end
     end
      
      
Рядок 197: Рядок 208:
         local link_display = ""
         local link_display = ""
         if game.link and game.link ~= "" then
         if game.link and game.link ~= "" then
             link_display = string.format('[%s <span style="font-size:16px;">▶️</span>]', game.link, "Дивитися")
             link_display = string.format('[%s Дивитися <span style="font-size:16px;">▶️</span>]', game.link)
         end
         end
          
          
Рядок 217: Рядок 228:
      
      
     return table.concat(table_html, '\n')
     return table.concat(table_html, '\n')
end
--- Функція для отримання кількості ігор гравця
function p.games_count(frame)
    local player_name = frame.args.player
   
    if not player_name or player_name == "" then
        return "0"
    end
   
    local games = get_player_games_list(player_name)
   
    if not games then
        return "0"
    end
   
    return tostring(#games)
end
end


return p
return p