5466
редагувань
Admin (обговорення | внесок) (Створена сторінка: local p = {} --- Функція для виведення помилки local function error_output(context, error_details) local safe_details = error_details or "N/A" return string.format("<span style='color:red; font-weight:bold;'>[Games Error: %s. Details: %s]</span>", context or "Unknown Context", safe_details) end --- Видаляє вікі-посилання link local function clean_wikilinks(text) if not text then retu...) |
Admin (обговорення | внесок) Немає опису редагування |
||
| Рядок 19: | Рядок 19: | ||
local function get_player_role(player_name, cells) | local function get_player_role(player_name, cells) | ||
-- Колонки: 1-Формат, 2-Тип, 3-Турнір, 4-Скорочення | -- Колонки: 1-Формат, 2-Тип, 3-Турнір, 4-Скорочення | ||
-- 5- | -- 5-10: Мирні (6 гравців) | ||
-- | -- 11: Шериф | ||
-- 13 | -- 12-13: Мафія (2 гравці) | ||
-- | -- 14: Дон | ||
-- | -- 15: Результат | ||
-- | -- 16: Посилання | ||
for i = 5, | -- Перевіряємо Мирних (колонки 5-10) | ||
for i = 5, 10 do | |||
if cells[i] and clean_wikilinks(cells[i]) == player_name then | if cells[i] and clean_wikilinks(cells[i]) == player_name then | ||
return "Мирний" | |||
end | end | ||
end | end | ||
-- Перевіряємо Шерифа (колонка | -- Перевіряємо Шерифа (колонка 11) | ||
if cells[ | if cells[11] and clean_wikilinks(cells[11]) == player_name then | ||
return "Шериф" | return "Шериф" | ||
end | end | ||
-- Перевіряємо Мафію (колонки 13 | -- Перевіряємо Мафію (колонки 12-13) | ||
for i = 13 | for i = 12, 13 do | ||
if cells[i] and clean_wikilinks(cells[i]) == player_name then | if cells[i] and clean_wikilinks(cells[i]) == player_name then | ||
return "Мафія" | return "Мафія" | ||
| Рядок 48: | Рядок 45: | ||
end | end | ||
-- Перевіряємо Дона (колонка | -- Перевіряємо Дона (колонка 14) | ||
if cells[ | if cells[14] and clean_wikilinks(cells[14]) == player_name then | ||
return "Дон" | return "Дон" | ||
end | end | ||
| Рядок 61: | Рядок 58: | ||
return "Невідомо" | return "Невідомо" | ||
end | end | ||
game_result = mw.text.trim(game_result) | |||
-- Місто перемогло | -- Місто перемогло | ||
| Рядок 138: | Рядок 137: | ||
-- Перевіряємо чи гравець є в цій грі | -- Перевіряємо чи гравець є в цій грі | ||
local player_in_game = false | local player_in_game = false | ||
for i = 5, | for i = 5, 14 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 | ||
| Рядок 145: | Рядок 144: | ||
end | end | ||
if player_in_game and #cells >= | if player_in_game and #cells >= 15 then | ||
local format = cells[1] or "" | local format = cells[1] or "" | ||
local type_game = cells[2] or "" | local type_game = cells[2] or "" | ||
local tournament = cells[3] or "" | local tournament = cells[3] or "" | ||
local short_name = cells[4] or "" | local short_name = cells[4] or "" | ||
local game_result = cells[ | local game_result = cells[15] or "" | ||
local link = cells[ | local link = cells[16] or "" | ||
local role = get_player_role(player_name, cells) | local role = get_player_role(player_name, cells) | ||