6369
редагувань
Admin (обговорення | внесок) Немає опису редагування |
Admin (обговорення | внесок) Немає опису редагування |
||
| (Не показано 6 проміжних версій цього користувача) | |||
| Рядок 411: | Рядок 411: | ||
end | end | ||
-- Дата | -- Дата (рахуємо до 26.10.2024) | ||
local date_added = "Лише Бог знає" | local date_added = "Лише Бог знає" | ||
if player_info and #player_info >= 3 then | if player_info and #player_info >= 3 then | ||
| Рядок 418: | Рядок 418: | ||
local day, month, year = mw.ustring.match(raw_date, "(%d+)%.(%d+)%.(%d+)") | local day, month, year = mw.ustring.match(raw_date, "(%d+)%.(%d+)%.(%d+)") | ||
if day and month and year then | if day and month and year then | ||
local end_date = os.time({year=2024, month= | local end_date = os.time({year=2024, month=10, day=26}) | ||
local start_date = os.time({year=tonumber(year), month=tonumber(month), day=tonumber(day)}) | local start_date = os.time({year=tonumber(year), month=tonumber(month), day=tonumber(day)}) | ||
local days_diff = math.floor((end_date - start_date) / 86400) | local days_diff = math.floor((end_date - start_date) / 86400) | ||
| Рядок 426: | Рядок 426: | ||
end | end | ||
-- Recruiter ( | -- Recruiter (залишаємо з вікілінком) | ||
local recruiter = "Не вказано" | local recruiter = "Не вказано" | ||
if player_info and #player_info >= 4 then | if player_info and #player_info >= 4 then | ||
local raw = mw.text.trim(player_info[4] | local raw = mw.text.trim(player_info[4]) | ||
if raw ~= "Відсутній" and raw ~= "-" and raw ~= "" then | if raw ~= "Відсутній" and raw ~= "-" and raw ~= "" then | ||
recruiter = raw | recruiter = raw | ||
| Рядок 444: | Рядок 444: | ||
local output = {} | local output = {} | ||
table.insert(output, "{{MCC Player New") | table.insert(output, "{{MCC Player New") | ||
table.insert(output, "| nickname = " .. player_name) | table.insert(output, "| nickname = " .. player_name) | ||
if stats and #stats >= | if stats and #stats >= 6 then | ||
local games = stats[3] or "0" | |||
local wins = stats[4] or "0" | |||
local losses = stats[5] or "0" | |||
local winrate = stats[6] or "0" | |||
local winrate = stats[ | |||
winrate = mw.ustring.gsub(winrate, "%%", "") | winrate = mw.ustring.gsub(winrate, "%%", "") | ||
winrate = mw.text.trim(winrate) | |||
table.insert(output, "| games = " .. games) | |||
table.insert(output, "| wins = " .. wins) | |||
table.insert(output, "| losses = " .. losses) | |||
table.insert(output, "| winrate = " .. winrate) | table.insert(output, "| winrate = " .. winrate) | ||
else | else | ||
| Рядок 487: | Рядок 491: | ||
table.insert(output, "| finalist = 0") | table.insert(output, "| finalist = 0") | ||
end | end | ||
table.insert(output, "}}") | table.insert(output, "}}") | ||
table.insert(output, "") | table.insert(output, "") | ||
table.insert(output, "''[Тут додай опис гравця]''") | table.insert(output, "''[Тут додай опис гравця]''") | ||
table.insert(output, "") | table.insert(output, "") | ||
table.insert(output, "== Сезони ==") | table.insert(output, "== Сезони ==") | ||
table.insert(output, "{{#invoke:FetchData|season_achievements|player=" .. player_name .. "}}") | table.insert(output, "{{#invoke:FetchData|season_achievements|player=" .. player_name .. "}}") | ||
table.insert(output, "") | table.insert(output, "") | ||
table.insert(output, "== Нагороди в MCC ==") | table.insert(output, "== Нагороди в MCC ==") | ||
table.insert(output, titles_code) | table.insert(output, titles_code) | ||
table.insert(output, "") | table.insert(output, "") | ||
table.insert(output, "== Записи ігор ({{#invoke:FetchData|games_count_records|player=" .. player_name .. "}}) ==") | table.insert(output, "== Записи ігор ({{#invoke:FetchData|games_count_records|player=" .. player_name .. "}}) ==") | ||
table.insert(output, "{{#invoke:FetchData|player_games|player=" .. player_name .. "}}") | table.insert(output, "{{#invoke:FetchData|player_games|player=" .. player_name .. "}}") | ||
table.insert(output, "") | table.insert(output, "") | ||
table.insert(output, "== Цікаві факти ==") | table.insert(output, "== Цікаві факти ==") | ||
table.insert(output, facts_code) | table.insert(output, facts_code) | ||
-- НАЙПРОСТІШЕ РІШЕННЯ: Додаємо пробіл на початку кожного рядка | |||
local final_code = table.concat(output, "\n") | |||
-- Розбиваємо на рядки та додаємо пробіл | |||
local result = {} | |||
for line in final_code:gmatch("([^\n]*)\n?") do | |||
if line ~= "" then | |||
table.insert(result, " " .. line) | |||
else | |||
table.insert(result, "") | |||
end | |||
end | |||
-- Додаємо заголовок | |||
return "'''Код для гравця " .. player_name .. ":'''\n\n" .. table.concat(result, "\n") | |||
end | end | ||
-- Генерувати для всіх гравців | -- Генерувати для всіх гравців | ||