Модуль:Участники финального турнира: различия между версиями
Lord (обсуждение | вклад) Нет описания правки |
Lord (обсуждение | вклад) Нет описания правки |
||
| Строка 62: | Строка 62: | ||
local prefix = args[1] or args.prefix | local prefix = args[1] or args.prefix | ||
local target_year = tonumber(args[2] or args.year) | local target_year = tonumber(args[2] or args.year) | ||
local manual_teams = args[3] or args.teams -- Новый параметр для ручного списка | |||
if not prefix or not target_year then | if not prefix or not target_year then | ||
| Строка 74: | Строка 75: | ||
local champion_code = nil | local champion_code = nil | ||
local champion_found = false | local champion_found = false | ||
local manual_mode = false | |||
-- === ОБРАБОТКА РУЧНОГО СПИСКА (ЕСЛИ ЕСТЬ) === | |||
if manual_teams and manual_teams ~= "" then | |||
manual_mode = true | |||
-- Разбиваем список по запятой | |||
for item in mw.text.gsplit(manual_teams, ",") do | |||
local team_input = mw.text.trim(item) | |||
if team_input ~= "" then | |||
local code = mw.ustring.upper(team_input) | |||
-- Проверяем, ввёл ли юзер код или название. Если название — получаем код. | |||
if not teams_module.getTeam(code) then | |||
local resolved_code = teams_module.getCode(team_input) | |||
if resolved_code then code = resolved_code end | |||
end | |||
participants[code] = true | |||
appearances[code] = 1 -- Засчитываем участие в будущем турнире | |||
end | |||
end | |||
end | |||
-- Если список задан вручную, начинаем сканировать БД с прошлого года | |||
local start_year = manual_mode and (target_year - 1) or target_year | |||
-- === 1 ПРОХОД ПО БАЗАМ ДАННЫХ === | -- === 1 ПРОХОД ПО БАЗАМ ДАННЫХ === | ||
for y = | for y = start_year, 2006, -1 do | ||
if not SKIP_YEARS[y] then | if not SKIP_YEARS[y] then | ||
local success, year_db = pcall(require, "Модуль:Data/Tournaments/" .. y) | local success, year_db = pcall(require, "Модуль:Data/Tournaments/" .. y) | ||
| Строка 86: | Строка 112: | ||
local unique_teams = extract_teams(t_data) | local unique_teams = extract_teams(t_data) | ||
if y == target_year then | if not manual_mode and y == target_year then | ||
-- | -- Работаем в автоматическом режиме: фиксируем состав участников целевого турнира | ||
for code in pairs(unique_teams) do | for code in pairs(unique_teams) do | ||
participants[code] = true | participants[code] = true | ||
| Строка 131: | Строка 157: | ||
end | end | ||
-- Чемпион идёт первым, остальные по алфавиту | -- Сортировка: Чемпион идёт первым, остальные по алфавиту | ||
table.sort(list, function(a, b) | table.sort(list, function(a, b) | ||
if a.is_champ ~= b.is_champ then | if a.is_champ ~= b.is_champ then | ||
| Строка 158: | Строка 184: | ||
if team then | if team then | ||
-- | -- Ячейка с флагом | ||
tr:tag('td') | tr:tag('td') | ||
:attr('align', 'center') | :attr('align', 'center') | ||
| Строка 164: | Строка 190: | ||
:wikitext(string.format('[[Файл:%s.jpg|50x100px]]', team.short)) | :wikitext(string.format('[[Файл:%s.jpg|50x100px]]', team.short)) | ||
-- | -- Умная ссылка на команду (Полное имя | Короткое имя) | ||
local link = (team.full == team.short) and string.format('[[%s]]', team.short) | local link = (team.full == team.short) and string.format('[[%s]]', team.short) | ||
or string.format('[[%s|%s]]', team.full, team.short) | or string.format('[[%s|%s]]', team.full, team.short) | ||