5261
редагування
Admin (обговорення | внесок) Немає опису редагування |
Admin (обговорення | внесок) Немає опису редагування |
||
| Рядок 3: | Рядок 3: | ||
---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ||
-- ГОЛОВНИЙ ПОШУК | -- ГОЛОВНИЙ ПОШУК | ||
-- Індексація: 1=№, 2=Ім'я, 3=Значення, 4=Додатково | -- Індексація: 1=№, 2=Ім'я, 3=Значення, 4=Додатково | ||
---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ||
| Рядок 19: | Рядок 17: | ||
local player_pattern = "%[%[" .. escaped .. "%]%]" | local player_pattern = "%[%[" .. escaped .. "%]%]" | ||
-- 1. Вилучаємо вміст таблиці wikitable | -- 1. Вилучаємо вміст таблиці wikitable | ||
local table_content = mw.ustring.match(content, "{|.-([|].-.-[|]})") | local table_content = mw.ustring.match(content, "{|.-([|].-.-[|]})") | ||
if not table_content then return nil end | if not table_content then return nil end | ||
-- 2. Знаходимо весь блок даних гравця (4 комірки) | -- 2. Знаходимо весь блок даних гравця (4 комірки: №, Ім'я, Значення, Додатково) | ||
-- | -- Шукаємо | <№> | [[Ім'я]] | <Значення> | <Додатково> | ||
local full_row_pattern = "([|]%s*.-%s*[|]%s*" .. player_pattern .. "%s*[|]%s*.-%s*[|]%s*.-%s*)" | local full_row_pattern = "([|]%s*.-%s*[|]%s*" .. player_pattern .. "%s*[|]%s*.-%s*[|]%s*.-%s*)" | ||
local full_row_match = mw.ustring.match(table_content, full_row_pattern) | local full_row_match = mw.ustring.match(table_content, full_row_pattern) | ||
| Рядок 33: | Рядок 31: | ||
local cells = {} | local cells = {} | ||
for cell in mw.ustring.gmatch(full_row_match, "[|](.-)") do | for cell in mw.ustring.gmatch(full_row_match, "[|](.-)") do | ||
local trimmed_cell = mw.text.trim(cell) | local trimmed_cell = mw.text.trim(cell) | ||
| Рядок 40: | Рядок 37: | ||
end | end | ||
end | end | ||
local result = cells[column_index] | local result = cells[column_index] | ||
| Рядок 47: | Рядок 42: | ||
-- 4. Прибираємо [[link|text]] і [[link]] | -- 4. Прибираємо [[link|text]] і [[link]] | ||
result = mw.ustring.gsub(result, "%[%[([^%]|]+)|([^%]]+)%]%]", "%2") | result = mw.ustring.gsub(result, "%[%[([^%]|]+)|([^%]]+)%]%]", "%2") | ||
result = mw.ustring.gsub(result, "%[%[([^%]]+)%]%]", "%1") | result = mw.ustring.gsub(result, "%[%[([^%]]+)%]%]", "%1") | ||
return mw.text.trim(result) | return mw.text.trim(result) | ||
| Рядок 76: | Рядок 71: | ||
---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ||
-- ПОЛЯ | -- ПОЛЯ (ОТРИМУЮТЬ ІМ'Я З frame.args.player) | ||
---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ||
function p.recruiter(frame) | function p.recruiter(frame) | ||
local name = | -- Беремо ім'я з параметра 'player' | ||
local raw = fetch_from_table("Гравці", name, 4) | local name = frame.args.player | ||
local raw = fetch_from_table("Гравці", name, 4) -- Колонка 4 | |||
if raw == "Відсутній" then return "Не вказано" end | if raw == "Відсутній" then return "Не вказано" end | ||
return raw or "Не вказано" | return raw or "Не вказано" | ||
| Рядок 88: | Рядок 83: | ||
function p.date_added(frame) | function p.date_added(frame) | ||
local name = | -- Беремо ім'я з параметра 'player' | ||
local raw = fetch_from_table("Гравці", name, 3) | local name = frame.args.player | ||
local raw = fetch_from_table("Гравці", name, 3) -- Колонка 3 | |||
return raw and date_with_days(raw) or "Невідомо" | return raw and date_with_days(raw) or "Невідомо" | ||
end | end | ||
function p.prize_pool(frame) | |||
function p. | -- Беремо ім'я з параметра 'player' | ||
local name = | local name = frame.args.player | ||
local raw = fetch_from_table("Призовий_фонд", name, 3) -- Колонка 3 | |||
local raw = fetch_from_table(" | |||
if raw then | if raw then | ||
raw = mw.ustring.gsub(raw, "[^%d%s]", "") | raw = mw.ustring.gsub(raw, "[^%d%s]", "") | ||
| Рядок 106: | Рядок 100: | ||
end | end | ||
function p.foundation(frame) | |||
function p. | -- Беремо ім'я з параметра 'player' | ||
local name = | local name = frame.args.player | ||
local raw = fetch_from_table("Фундація", name, 3) -- Колонка 3 | |||
local raw = fetch_from_table(" | |||
if raw then | if raw then | ||
raw = mw.ustring.gsub(raw, "[^%d%s]", "") | raw = mw.ustring.gsub(raw, "[^%d%s]", "") | ||
| Рядок 118: | Рядок 111: | ||
end | end | ||
function p.final(frame) | function p.final(frame) | ||
local name = | -- Беремо ім'я з параметра 'player' | ||
local name = frame.args.player | |||
local raw = fetch_from_table("Фіналіст", name, 3) | local raw = fetch_from_table("Фіналіст", name, 3) -- Колонка 3 | ||
local count = raw and mw.ustring.match(raw, "(%d+)") | local count = raw and mw.ustring.match(raw, "(%d+)") | ||