Moduł:Rekordy sezon: Różnice pomiędzy wersjami
Wygląd
Nie podano opisu zmian |
Nie podano opisu zmian |
||
| Linia 2: | Linia 2: | ||
-- ========================================================= | -- ========================================================= | ||
-- | -- Moduł:Rekordy_sezon | ||
-- | -- | ||
-- | -- Wspólny moduł rekordów sezonu. | ||
-- | -- | ||
-- Wywołanie: | -- Wywołanie: | ||
| Linia 14: | Linia 14: | ||
-- }} | -- }} | ||
-- | -- | ||
-- | -- Obsługiwane dyscypliny: | ||
-- | -- - koszykówka | ||
-- - piłka nożna | |||
-- | |||
-- | -- | ||
-- ========================================================= | -- ========================================================= | ||
-- ========================================================= | |||
-- FUNKCJE WSPÓLNE | |||
-- ========================================================= | |||
local function escapeSQL(value) | |||
value = value or "" | |||
return mw.ustring.gsub( | |||
tostring(value), | |||
"'", | |||
"''" | |||
) | |||
end | |||
local function liczba(value) | |||
if | if value == nil or value == "" then | ||
return | return 0 | ||
end | end | ||
value = tostring(value) | |||
value = mw.ustring.gsub( | |||
value, | |||
"%s+", | |||
"" | |||
) | |||
return tonumber(value) or 0 | |||
end | |||
-- ========================================================= | |||
-- WYNIK MECZU | |||
-- | |||
-- WAŻNE: | |||
-- funkcja jest lokalna i dostępna dla całego modułu. | |||
-- ========================================================= | |||
local function wynikMeczu(row) | |||
local g1 = tonumber( | |||
row.gole1 or "" | |||
) | |||
local | local g2 = tonumber( | ||
row.gole2 or "" | |||
) | |||
if g1 and g2 then | |||
return g1, g2 | |||
end | end | ||
local | local wynik = | ||
row.wynik or "" | |||
local a, b = | |||
wynik:match( | |||
"(%d+)%s*:%s*(%d+)" | |||
) | |||
if a and b then | |||
return | return | ||
tonumber(a), | |||
tonumber(b) | |||
end | end | ||
return nil, nil | |||
end | |||
-- ========================================================= | |||
-- MIEJSCE MECZU | |||
-- ========================================================= | |||
local function miejsceMeczu( | |||
row, | |||
druzyna | |||
) | |||
local d1 = | |||
row.druzyna1 or "" | |||
local d2 = | |||
row.druzyna2 or "" | |||
if d1 == druzyna then | |||
return "dom" | |||
end | end | ||
if d2 == druzyna then | |||
return "wyjazd" | |||
end | |||
return nil | |||
end | |||
-- ========================================================= | |||
-- NAZWA MECZU | |||
-- ========================================================= | |||
local function nazwaMeczu(row) | |||
local d1 = | |||
row.druzyna1 or "" | |||
local d2 = | |||
row.druzyna2 or "" | |||
local tekst = | |||
d1 .. " – " .. d2 | |||
local | local strona = | ||
row.strona_meczu or "" | |||
if strona ~= "" then | |||
return | return "[[" .. | ||
strona .. | |||
"|" .. | |||
tekst .. | |||
"]]" | |||
end | end | ||
return tekst | |||
end | |||
-- ========================================================= | |||
-- PARSOWANIE MINUTY GOLA | |||
-- | |||
-- Obsługujemy: | |||
-- | |||
-- 14 | |||
-- 45 | |||
-- 45+2 | |||
-- 90+4 | |||
-- 105 | |||
-- 120+1 | |||
-- | |||
-- Zwracamy: | |||
-- minuta podstawowa | |||
-- doliczony czas | |||
-- ========================================================= | |||
local function parsujMinute(value) | |||
if value == nil or value == "" then | |||
return nil, 0 | |||
end | |||
value = | |||
tostring(value) | |||
value = | |||
mw.ustring.gsub( | |||
value, | |||
"%s+", | |||
"" | |||
) | |||
local minuta, | |||
doliczona = | |||
value:match( | |||
"^(%d+)%+(%d+)$" | |||
) | |||
if minuta then | |||
return | |||
tonumber(minuta), | |||
tonumber(doliczona) | |||
end | end | ||
minuta = | |||
value:match( | |||
"^(%d+)" | |||
) | |||
if | if minuta then | ||
return | return | ||
tonumber(minuta), | |||
0 | |||
end | end | ||
return nil, 0 | |||
return | |||
end | end | ||
-- ========================================================= | -- ========================================================= | ||
-- PRZEDZIAŁ CZASOWY GOLA | |||
-- ========================================================= | -- ========================================================= | ||
local function przedzialGola(value) | |||
local minuta, | |||
doliczona = | |||
parsujMinute(value) | |||
if not minuta then | |||
return nil | |||
end | |||
-- 45+ oraz 90+ itd. | |||
if minuta == 45 and doliczona > 0 then | |||
return "45+" | |||
end | |||
if minuta == 90 and doliczona > 0 then | |||
return "90+" | |||
end | |||
if minuta == 105 and doliczona > 0 then | |||
return "105+" | |||
end | |||
if minuta == 120 and doliczona > 0 then | |||
return "120+" | |||
end | |||
" | |||