Moduł:H2H: Różnice pomiędzy wersjami
Wygląd
Nie podano opisu zmian |
Nie podano opisu zmian |
||
| Linia 2: | Linia 2: | ||
-- ========================================================= | -- ========================================================= | ||
-- | -- Moduł:H2H | ||
-- | -- | ||
-- Historia bezpośrednich spotkań dwóch drużyn | -- Historia bezpośrednich spotkań dwóch drużyn | ||
-- | -- | ||
-- | -- Funkcje: | ||
-- | -- • bilans spotkań | ||
-- | -- • suma punktów obu drużyn | ||
-- | -- • wszystkie mecze | ||
-- | -- • najlepsi strzelcy rywalizacji | ||
-- • trenerzy prowadzący zespół przeciwko rywalowi | |||
-- • rekordy meczowe dom / wyjazd | |||
-- • rekordy indywidualne dom / wyjazd | |||
-- • serie zwycięstw / porażek | |||
-- • porównanie wyniku poszczególnych kwart | |||
-- • obsługa do 3 dogrywek | |||
-- | -- | ||
-- | -- Identyfikacja drużyn odbywa się przez: | ||
-- | -- nazwa_statystyki1 | ||
-- | -- nazwa_statystyki2 | ||
-- | -- | ||
-- Dzięki temu można zachować jedną nazwę drużyny | |||
-- niezależnie od późniejszych zmian sponsora. | |||
-- ========================================================= | -- ========================================================= | ||
| Linia 32: | Linia 33: | ||
-- ===================================================== | -- ===================================================== | ||
local team1 = | local team1 = mw.text.trim(frame.args.team1 or "") | ||
local team2 = mw.text.trim(frame.args.team2 or "") | |||
if team1 == "" then | |||
return "'''Błąd:''' nie podano parametru '''team1'''." | |||
end | |||
if team1 | |||
return "'''Błąd:''' | |||
if team2 == "" then | |||
return "'''Błąd:''' nie podano parametru '''team2'''." | |||
end | end | ||
-- ===================================================== | -- ===================================================== | ||
-- | -- BEZPIECZNE SQL | ||
-- ===================================================== | -- ===================================================== | ||
local | local team1SQL = | ||
mw.ustring.gsub(team1, "'", "''") | |||
local | local team2SQL = | ||
mw.ustring.gsub(team2, "'", "''") | |||
| Linia 89: | Linia 60: | ||
-- ===================================================== | -- ===================================================== | ||
local function | local function liczba(value) | ||
if value == nil or value == "" then | if value == nil or value == "" then | ||
| Linia 98: | Linia 69: | ||
value = | value = | ||
mw.ustring.gsub( | mw.ustring.gsub(value, "%s+", "") | ||
return tonumber(value) or 0 | return tonumber(value) or 0 | ||
| Linia 109: | Linia 76: | ||
local function | local function minutyNaSekundy(value) | ||
if value == nil or value == "" then | |||
return 0 | |||
end | |||
local tekst = tostring(value) | |||
local min, sek = | |||
tekst:match("^(%d+):(%d+)$") | |||
if | if min and sek then | ||
return | return tonumber(min) * 60 + tonumber(sek) | ||
end | end | ||
return tonumber(tekst) or 0 | |||
end | |||
local function sekundyNaMinuty(sek) | |||
if | if not sek then | ||
return | return "0:00" | ||
end | end | ||
return | local min = | ||
math.floor(sek / 60) | |||
local s = | |||
sek % 60 | |||
return string.format( | |||
"%d:%02d", | |||
min, | |||
s | |||
) | |||
end | end | ||
local function | local function wynikMeczu(row) | ||
local g1 = | local g1 = | ||
| Linia 141: | Linia 129: | ||
end | end | ||
local wynik = | |||
row.wynik or "" | |||
local a, b = | |||
wynik:match( | |||
"(%d+)%s*:%s*(%d+)" | |||
) | |||
if a and b then | |||
return tonumber(a), tonumber(b) | |||
end | |||
return nil, nil | |||
end | end | ||
local function | local function miejsceMeczu(row) | ||
local d1 = | local d1 = | ||
| Linia 153: | Linia 153: | ||
local d2 = | local d2 = | ||
row.nazwa_statystyki2 or "" | row.nazwa_statystyki2 or "" | ||
if d1 == team1 then | if d1 == team1 then | ||
| Linia 168: | Linia 167: | ||
local function | local function przeciwnik(row) | ||
local d1 = | |||
row.nazwa_statystyki1 or "" | |||
local | local d2 = | ||
row.nazwa_statystyki2 or "" | |||
if | if d1 == team1 then | ||
return | return d2 | ||
end | end | ||
if d2 == team1 then | |||
if | return d1 | ||
return | |||
end | end | ||
return | return "" | ||
end | end | ||
local function | local function linkMeczu(row) | ||
local | local strona = | ||
row.strona_meczu or "" | |||
local d1 = | local d1 = | ||
| Linia 217: | Linia 199: | ||
row.druzyna2 or "" | row.druzyna2 or "" | ||
local | local tekst = | ||
d1 .. " – " .. d2 | |||
d1 .. | |||
if | if strona ~= "" then | ||
return | return "[[" .. | ||
strona .. | |||
"|" .. | "|" .. | ||
tekst .. | |||
"]]" | "]]" | ||
end | end | ||
return | return tekst | ||
end | end | ||
local function | local function bezpiecznyLinkOsoby(osoba) | ||
if | if not osoba or osoba == "" then | ||
return " | return "" | ||
end | end | ||
return | return "[[" .. | ||
osoba .. | |||
"|" .. | |||
osoba .. | |||
"]]" | |||
end | end | ||
local function wartoscNajwieksza(lista) | |||
if not lista or #lista == 0 then | |||
return nil | |||
end | |||
local max = lista[1].wartosc | |||
for _, item in ipairs(lista) do | |||
if item.wartosc > max then | |||
max = item.wartosc | |||
end | |||
end | |||
return max | |||
end | |||
local function dodajRekord(lista, item) | |||
if #lista == 0 then | |||
table.insert( | |||
lista, | |||
item | |||
) | |||
return | |||
end | |||
local max = | |||
lista[1].wartosc | |||
if item.wartosc > max then | |||
lista = {} | |||
end | |||
end | end | ||
| Linia 317: | Linia 279: | ||
-- ===================================================== | -- ===================================================== | ||
-- | -- POBRANIE MECZÓW H2H | ||
-- ===================================================== | -- ===================================================== | ||
local | local fieldsMecze = table.concat({ | ||
"M.id=mecz", | |||
"M.data=data", | |||
"M.sezon=sezon", | |||
"M.rozgrywki=rozgrywki", | |||
"M.kolejka=kolejka", | |||
"M.druzyna1=druzyna1", | |||
"M.druzyna2=druzyna2", | |||
"M.nazwa_statystyki1=nazwa_statystyki1", | |||
"M.nazwa_statystyki2=nazwa_statystyki2", | |||
"M.wynik=wynik", | |||
"M.gole1=gole1", | |||
"M.gole2=gole2", | |||
"M.hala=hala", | |||
"M.widzowie=widzowie", | |||
"M.sedziowie=sedziowie", | |||
"M.strona_meczu=strona_meczu", | |||
"M.kwarta1=kwarta1", | |||
"M.kwarta2=kwarta2", | |||
"M.kwarta3=kwarta3", | |||
"M.kwarta4=kwarta4", | |||
"M.dogrywka1=dogrywka1", | |||
"M.dogrywka2=dogrywka2", | |||
"M.dogrywka3=dogrywka3" | |||
}, ",") | |||