|
|
| (Не показано 5 проміжних версій цього користувача) |
| Рядок 1: |
Рядок 1: |
| --- Головна функція для виведення ігор гравця
| | |
| 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
| |
|
| |
| if #games == 0 then
| |
| return "''Ігор не знайдено''"
| |
| end
| |
|
| |
| -- Генеруємо таблицю з заголовками
| |
| local table_html = {
| |
| '{| class="wikitable sortable" style="width: 100%; font-size: 14.5px;"',
| |
| '! Турнір !! Роль !! Результат !! Запис',
| |
| '|-'
| |
| }
| |
|
| |
| for _, game in ipairs(games) do
| |
| local result_text = game.result
| |
| if game.result == "Перемога" then
| |
| result_text = "<span style='color:#4caf50; font-weight:normal;'>Перемога</span>"
| |
| elseif game.result == "Поразка" then
| |
| result_text = "<span style='color:indianred; font-weight:normal;'>Поразка</span>"
| |
| end
| |
|
| |
| local link_display = ""
| |
| if game.link and game.link ~= "" then
| |
| link_display = string.format(
| |
| '<a href="%s" target="_blank" style="display:inline-block; padding:4px 8px; background-color:white; color:black; border-radius:4px; font-size:13px; text-decoration:none; transition:opacity 0.2s;" onmouseover="this.style.opacity=\'0.7\'" onmouseout="this.style.opacity=\'1\'">Запис</a>',
| |
| game.link
| |
| )
| |
| end
| |
|
| |
| local tournament_link = get_tournament_link(game.short, game.tournament)
| |
|
| |
| table.insert(table_html, string.format(
| |
| '| style="text-align:center; padding: 8px;" | %s || style="text-align:center; padding: 8px;" | %s || style="text-align:center; padding: 8px;" | %s || style="text-align:center; padding: 8px;" | %s',
| |
| tournament_link,
| |
| game.role,
| |
| result_text,
| |
| link_display
| |
| ))
| |
| table.insert(table_html, '|-')
| |
| end
| |
|
| |
| table.insert(table_html, '|}')
| |
|
| |
| return table.concat(table_html, '\n')
| |
| end
| |