Moduł:Rekordy sezon: Różnice pomiędzy wersjami
Wygląd
Nie podano opisu zmian |
Nie podano opisu zmian |
||
| (Nie pokazano 6 pośrednich wersji utworzonych przez tego samego użytkownika) | |||
| Linia 4: | Linia 4: | ||
-- Moduł:Rekordy_sezon | -- Moduł:Rekordy_sezon | ||
-- | -- | ||
-- | -- Jeden moduł dla różnych dyscyplin. | ||
-- | -- | ||
-- Wywołanie: | -- Wywołanie: | ||
| Linia 13: | Linia 11: | ||
-- |sezon=2026/2027 | -- |sezon=2026/2027 | ||
-- |druzyna=Lech Poznań | -- |druzyna=Lech Poznań | ||
-- |dyscyplina= | -- |dyscyplina=piłka nożna | ||
-- }} | -- }} | ||
-- | -- | ||
-- | -- lub: | ||
-- | -- | ||
-- | -- {{#invoke:Rekordy_sezon|main | ||
-- | -- |sezon=2026/2027 | ||
-- |druzyna=Enea Basket Poznań | |||
-- |dyscyplina=koszykówka | |||
-- }} | |||
-- | -- | ||
-- ========================================================= | -- ========================================================= | ||
| Linia 38: | Linia 36: | ||
value = tostring(value) | value = tostring(value) | ||
value = mw.ustring.gsub(value, "%s+", "") | |||
value = mw.ustring.gsub( | |||
value, | |||
"%s+", | |||
"" | |||
) | |||
return tonumber(value) or 0 | return tonumber(value) or 0 | ||
| Linia 45: | Linia 48: | ||
local function | local function escapeSQL(value) | ||
value = tostring(value or "") | value = tostring(value or "") | ||
return mw.ustring.gsub(value, "'", "''") | return mw.ustring.gsub( | ||
value, | |||
"'", | |||
"''" | |||
) | |||
end | |||
-- ========================================================= | |||
-- ROZPOZNANIE MIEJSCA MECZU | |||
-- ========================================================= | |||
local function miejsceMeczu(row, druzyna) | |||
local d1 = | |||
tostring(row.druzyna1 or "") | |||
local d2 = | |||
tostring(row.druzyna2 or "") | |||
if d1 == druzyna then | |||
return "dom" | |||
end | |||
if d2 == druzyna then | |||
return "wyjazd" | |||
end | |||
return nil | |||
end | end | ||
| Linia 60: | Linia 92: | ||
local function wynikMeczu(row) | local function wynikMeczu(row) | ||
local g1 = | local g1 = | ||
tonumber(row.gole1 or "") | |||
local g2 = | |||
tonumber(row.gole2 or "") | |||
if g1 ~= nil and g2 ~= nil then | |||
return g1, g2 | return g1, g2 | ||
end | end | ||
local wynik = tostring(row.wynik or "") | local wynik = | ||
tostring(row.wynik or "") | |||
local a, b = | local a, b = | ||
| Linia 80: | Linia 113: | ||
if a and b then | if a and b then | ||
return tonumber(a), tonumber(b) | |||
end | return | ||
tonumber(a), | |||
tonumber(b) | |||
end | |||
return nil, nil | return nil, nil | ||
| Linia 89: | Linia 127: | ||
-- ========================================================= | -- ========================================================= | ||
-- | -- WYNIK Z PERSPEKTYWY DRUŻYNY | ||
-- ========================================================= | -- ========================================================= | ||
local function | local function wynikZPerspektywy(row, druzyna) | ||
local | local g1, g2 = | ||
wynikMeczu(row) | |||
if | if g1 == nil or g2 == nil then | ||
return | return nil, nil | ||
end | end | ||
if | local miejsce = | ||
return "wyjazd" | miejsceMeczu( | ||
row, | |||
druzyna | |||
) | |||
if miejsce == "dom" then | |||
return g1, g2 | |||
elseif miejsce == "wyjazd" then | |||
return g2, g1 | |||
end | end | ||
return nil | return nil, nil | ||
end | end | ||
| Linia 116: | Linia 166: | ||
local function nazwaMeczu(row) | local function nazwaMeczu(row) | ||
local d1 = tostring(row.druzyna1 or "") | local d1 = | ||
local d2 = tostring(row.druzyna2 or "") | tostring(row.druzyna1 or "") | ||
local strona = tostring(row.strona_meczu or "") | |||
local d2 = | |||
tostring(row.druzyna2 or "") | |||
local strona = | |||
tostring(row.strona_meczu or "") | |||
local tekst = | local tekst = | ||
d1 .. " – " .. d2 | d1 .. | ||
" – " .. | |||
d2 | |||
if strona ~= "" then | if strona ~= "" then | ||
return "[[" .. | return | ||
"[[" .. | |||
strona .. | strona .. | ||
"|" .. | "|" .. | ||
| Linia 139: | Linia 198: | ||
-- ========================================================= | -- ========================================================= | ||
-- | -- FUNKCJA DODAWANIA REKORDU | ||
-- UŻYWANA PRZEZ PIŁKĘ NOŻNĄ | |||
-- ========================================================= | -- ========================================================= | ||
local function dodajRekord(tabela, miejsce, wartosc, item) | local function dodajRekord( | ||
tabela, | |||
miejsce, | |||
wartosc, | |||
item | |||
) | |||
if | if wartosc == nil then | ||
return | |||
end | end | ||
local lista = tabela[miejsce] | local lista = | ||
tabela[miejsce] | |||
if #lista == 0 then | if #lista == 0 then | ||
table.insert(lista, item) | table.insert( | ||
lista, | |||
item | |||
) | |||
return | return | ||
| Linia 161: | Linia 229: | ||
local obecna = | local obecna = | ||
lista[1].wartosc | |||
| Linia 183: | Linia 251: | ||
-- ========================================================= | -- ========================================================= | ||
-- | -- FORMAT REKORDÓW MECZOWYCH | ||
-- ========================================================= | -- ========================================================= | ||
local function | local function tekstMeczow(lista) | ||
if not lista or #lista == 0 then | |||
) | return "—" | ||
end | |||
local wynik = {} | |||
for _, item in ipairs(lista) do | |||
local roznica = | |||
item.roznica or 0 | |||
local roznicaTekst | |||
if roznica >= 0 then | |||
roznicaTekst = | |||
"+" .. | |||
tostring(roznica) | |||
else | |||
roznicaTekst = | |||
tostring(roznica) | |||
end | |||
table.insert( | |||
wynik, | |||
item.tekst .. | |||
" (" .. | |||
item.wynik .. | |||
", " .. | |||
roznicaTekst .. | |||
")" | |||
) | |||
end | end | ||
return table.concat( | |||
wynik, | |||
"<br>" | |||
) | |||
end | |||
-- ========================================================= | |||
-- FORMAT REKORDÓW ZAWODNIKÓW | |||
-- ========================================================= | |||
local function tekstZawodnikow( | |||
lista, | |||
typ | |||
) | |||
if not lista or #lista == 0 then | |||
return "—" | |||
end | |||
local wynik = {} | |||
for _, item in ipairs(lista) do | |||
local zawodnikLink = | |||
"[[" .. | |||
tostring(item.zawodnik or "") .. | |||
"]]" | |||
local wartosc = "" | |||
if typ == "punkty" then | |||
wartosc = | |||
tostring(item.punkty) .. | |||
" pkt" | |||
elseif typ == "minuty" then | |||
wartosc = | |||
tostring( | |||
item.minuty_format or "" | |||
) | |||
if wartosc == "" then | |||
wartosc = | |||
tostring( | tostring( | ||
item.minuty or 0 | |||
) | |||
end | |||
wartosc = | |||
wartosc .. | |||
" min" | |||
elseif typ == "asysty" then | |||
wartosc = | |||
tostring(item.asysty) .. | |||
" as." | |||
elseif typ == "zbiorki" then | |||
wartosc = | |||
tostring(item.zbiorki) .. | |||
" zb." | |||
elseif typ == "eval" then | |||
wartosc = | |||
tostring(item.eval) .. | |||
" EVAL" | |||
elseif typ == "plusminus" then | |||
local pm = | |||
item.plusminus or 0 | |||
if pm >= 0 then | |||