Moduł:HistoriaWystepow: Różnice pomiędzy wersjami
Wygląd
Nie podano opisu zmian |
Nie podano opisu zmian |
||
| Linia 1: | Linia 1: | ||
local p = {} | local p = {} | ||
-- ========================================================= | |||
-- MODUŁ:HISTORIAWYSTĘPÓW | |||
-- | |||
-- Historia występów zawodnika | |||
-- | |||
-- UWAGA: | |||
-- Moduł pokazuje wyłącznie występy zawodnika | |||
-- w drużynach poznańskich. | |||
-- | |||
-- Liczy się UdzialZawodnika.druzyna, | |||
-- a NIE przeciwnik. | |||
-- | |||
-- Dzięki temu: | |||
-- Enea Basket Poznań vs Resovia -> TAK | |||
-- Resovia vs Enea Basket Poznań -> NIE | |||
-- ========================================================= | |||
-- ========================================================= | |||
-- DRUŻYNY POZNAŃSKIE | |||
-- ========================================================= | |||
-- | |||
-- Tutaj dopisujemy kolejne drużyny poznańskie. | |||
-- | |||
-- Nazwa musi być identyczna z wartością pola "druzyna" | |||
-- w UdzialZawodnika. | |||
-- | |||
local druzynyPoznanskie = { | |||
["Enea Basket Poznań"] = true, | |||
["Enea AZS Politechnika Poznań"] = true, | |||
["Lech Poznań"] = true, | |||
["Warta Poznań"] = true, | |||
["AZS Politechnika Poznań"] = true, | |||
["MUKS Poznań"] = true | |||
} | |||
function p.main(frame) | function p.main(frame) | ||
local zawodnik = frame.args.zawodnik | local zawodnik = | ||
mw.text.trim( | |||
frame.args.zawodnik or "" | |||
) | |||
if zawodnik == "" then | |||
zawodnik = | |||
mw.title | |||
.getCurrentTitle() | |||
.text | |||
end | end | ||
-- ===================================================== | -- ===================================================== | ||
| Linia 14: | Linia 69: | ||
local zawodnikSQL = | local zawodnikSQL = | ||
mw.ustring.gsub(zawodnik, "'", "''") | mw.ustring.gsub( | ||
zawodnik, | |||
"'", | |||
"''" | |||
) | |||
-- ===================================================== | -- ===================================================== | ||
| Linia 45: | Linia 105: | ||
}, ",") | }, ",") | ||
-- ===================================================== | -- ===================================================== | ||
-- ZAPYTANIE CARGO | -- ZAPYTANIE CARGO | ||
-- | |||
-- Pobieramy wszystkie występy zawodnika, | |||
-- a następnie filtrujemy je według drużyny. | |||
-- | |||
-- NIE filtrujemy Mecze.druzyna1/druzyna2, | |||
-- ponieważ przeciwnik może być drużyną poznańską. | |||
-- ===================================================== | -- ===================================================== | ||
| Linia 67: | Linia 134: | ||
} | } | ||
local rows = mw.ext.cargo.query( | |||
local rows = | |||
mw.ext.cargo.query( | |||
"UdzialZawodnika,Mecze", | |||
) | fields, | ||
args | |||
) | |||
-- ===================================================== | |||
-- FILTR DRUŻYN POZNAŃSKICH | |||
-- | |||
-- Sprawdzamy U.druzyna. | |||
-- | |||
-- Dzięki temu zawodnik występujący przeciwko | |||
-- drużynie poznańskiej, ale reprezentujący | |||
-- drużynę przyjezdną, NIE zostanie uwzględniony. | |||
-- ===================================================== | |||
local tylkoPoznanskie = {} | |||
if rows then | |||
for _, row in ipairs(rows) do | |||
local druzyna = | |||
mw.text.trim( | |||
row.druzyna or "" | |||
) | |||
if druzynyPoznanskie[druzyna] then | |||
table.insert( | |||
tylkoPoznanskie, | |||
row | |||
) | |||
end | |||
end | |||
end | |||
rows = | |||
tylkoPoznanskie | |||
-- ===================================================== | -- ===================================================== | ||
| Linia 79: | Linia 190: | ||
if not rows or #rows == 0 then | if not rows or #rows == 0 then | ||
return "''Brak wprowadzonych występów w bazie.''" | return | ||
"''Brak wprowadzonych występów zawodnika " | |||
.. "dla drużyn poznańskich w bazie.''" | |||
end | end | ||
-- ===================================================== | -- ===================================================== | ||
-- | -- PODSUMOWANIE | ||
-- ===================================================== | -- ===================================================== | ||
| Linia 109: | Linia 223: | ||
end | end | ||
-- ===================================================== | -- ===================================================== | ||
| Linia 116: | Linia 231: | ||
local suma = | local suma = | ||
nowePodsumowanie() | nowePodsumowanie() | ||
local dom = | local dom = | ||
nowePodsumowanie() | nowePodsumowanie() | ||
local wyjazd = | local wyjazd = | ||
nowePodsumowanie() | nowePodsumowanie() | ||
-- sezony | -- sezony | ||
local sezony = {} | local sezony = {} | ||
-- kluby | -- kluby | ||
local kluby = {} | local kluby = {} | ||
-- ===================================================== | -- ===================================================== | ||
| Linia 137: | Linia 259: | ||
local d1 = | local d1 = | ||
row.druzyna1 or "" | row.druzyna1 or "" | ||
local d2 = | local d2 = | ||
row.druzyna2 or "" | row.druzyna2 or "" | ||
local druzyna = | local druzyna = | ||
row.druzyna or "" | row.druzyna or "" | ||
local wynikMeczu = | local wynikMeczu = | ||
row.wynik or "" | row.wynik or "" | ||
local g1, g2 = | local g1, g2 = | ||
| Linia 151: | Linia 277: | ||
"(%d+)%s*:%s*(%d+)" | "(%d+)%s*:%s*(%d+)" | ||
) | ) | ||
if not g1 or not g2 then | if not g1 or not g2 then | ||
return nil | return nil | ||
end | end | ||
g1 = tonumber(g1) | |||
g2 = tonumber(g2) | g1 = | ||
tonumber(g1) | |||
g2 = | |||
tonumber(g2) | |||
if druzyna == d1 then | if druzyna == d1 then | ||
if g1 > g2 then | if g1 > g2 then | ||
return "W" | return "W" | ||
elseif g1 < g2 then | elseif g1 < g2 then | ||
return "P" | return "P" | ||
else | else | ||
return "R" | return "R" | ||
end | end | ||
elseif druzyna == d2 then | elseif druzyna == d2 then | ||
if g2 > g1 then | if g2 > g1 then | ||
return "W" | return "W" | ||
elseif g2 < g1 then | elseif g2 < g1 then | ||
return "P" | return "P" | ||
else | else | ||
return "R" | return "R" | ||
end | end | ||
end | end | ||
return nil | return nil | ||
end | end | ||
-- ===================================================== | -- ===================================================== | ||
| Linia 200: | Linia 346: | ||
stat.wystepy = | stat.wystepy = | ||
stat.wystepy + 1 | stat.wystepy + 1 | ||
stat.punkty = | stat.punkty = | ||
stat.punkty | stat.punkty | ||
+ tonumber(row.gol or 0) | + ( | ||
tonumber(row.gol or 0) | |||
or 0 | |||
) | |||
stat.minuty = | stat.minuty = | ||
stat.minuty | stat.minuty | ||
+ tonumber(row.minuty or 0) | + ( | ||
tonumber(row.minuty or 0) | |||
or 0 | |||
) | |||
stat.asysty = | stat.asysty = | ||
stat.asysty | stat.asysty | ||
+ tonumber(row.asysta or 0) | + ( | ||
tonumber(row.asysta or 0) | |||
or 0 | |||
) | |||
stat.zbiorki = | stat.zbiorki = | ||
stat.zbiorki | stat.zbiorki | ||
+ tonumber(row.zbiorka or 0) | + ( | ||
tonumber(row.zbiorka or 0) | |||
or 0 | |||
) | |||
stat.eval = | stat.eval = | ||
stat.eval | stat.eval | ||
+ tonumber(row.eval or 0) | + ( | ||
tonumber(row.eval or 0) | |||
or 0 | |||
) | |||
stat.plusminus = | stat.plusminus = | ||
stat.plusminus | stat.plusminus | ||
+ tonumber(row.plusminus or 0) | + ( | ||
tonumber(row.plusminus or 0) | |||
or 0 | |||
) | |||
local wynik = | local wynik = | ||
okreslWynik(row) | okreslWynik(row) | ||
if wynik == "W" then | if wynik == "W" then | ||
| Linia 232: | Linia 404: | ||
stat.zwyciestwa = | stat.zwyciestwa = | ||
stat.zwyciestwa + 1 | stat.zwyciestwa + 1 | ||
elseif wynik == "P" then | elseif wynik == "P" then | ||
| Linia 237: | Linia 410: | ||
stat.porazki = | stat.porazki = | ||
stat.porazki + 1 | stat.porazki + 1 | ||
elseif wynik == "R" then | elseif wynik == "R" then | ||
| Linia 246: | Linia 420: | ||
end | end | ||
-- ===================================================== | -- ===================================================== | ||
| Linia 252: | Linia 427: | ||
for _, row in ipairs(rows) do | for _, row in ipairs(rows) do | ||
-- ----------------------------------------------- | -- ----------------------------------------------- | ||
| Linia 261: | Linia 437: | ||
row | row | ||
) | ) | ||
-- ----------------------------------------------- | -- ----------------------------------------------- | ||
| Linia 268: | Linia 445: | ||
local d1 = | local d1 = | ||
row.druzyna1 or "" | row.druzyna1 or "" | ||
local d2 = | local d2 = | ||
row.druzyna2 or "" | row.druzyna2 or "" | ||
local druzyna = | local druzyna = | ||
row.druzyna or "" | row.druzyna or "" | ||
if druzyna == d1 then | if druzyna == d1 then | ||
| Linia 281: | Linia 461: | ||
row | row | ||
) | ) | ||
elseif druzyna == d2 then | elseif druzyna == d2 then | ||
| Linia 290: | Linia 471: | ||
end | end | ||
-- ----------------------------------------------- | -- ----------------------------------------------- | ||
| Linia 297: | Linia 479: | ||
local sezon = | local sezon = | ||
row.sezon or "" | row.sezon or "" | ||
if sezon == "" then | if sezon == "" then | ||
sezon = "Brak sezonu" | |||
sezon = | |||
"Brak sezonu" | |||
end | end | ||
if not sezony[sezon] then | if not sezony[sezon] then | ||
| Linia 308: | Linia 495: | ||
end | end | ||
dodajDoPodsumowania( | dodajDoPodsumowania( | ||
| Linia 313: | Linia 501: | ||
row | row | ||
) | ) | ||
-- ----------------------------------------------- | -- ----------------------------------------------- | ||
| Linia 319: | Linia 508: | ||
if druzyna == "" then | if druzyna == "" then | ||
druzyna = "Brak klubu" | |||
druzyna = | |||
"Brak klubu" | |||
end | end | ||
if not kluby[druzyna] then | if not kluby[druzyna] then | ||
| Linia 328: | Linia 521: | ||
end | end | ||
dodajDoPodsumowania( | dodajDoPodsumowania( | ||
| Linia 335: | Linia 529: | ||
end | end | ||
-- ===================================================== | -- ===================================================== | ||
| Linia 343: | Linia 538: | ||
local godziny = | local godziny = | ||
math.floor(minuty / 60) | math.floor( | ||
minuty / 60 | |||
) | |||
local min = | local min = | ||
minuty % 60 | minuty % 60 | ||
return string.format( | return string.format( | ||
| Linia 355: | Linia 554: | ||
end | end | ||
-- ===================================================== | -- ===================================================== | ||
| Linia 361: | Linia 561: | ||
local listaSezonow = {} | local listaSezonow = {} | ||
for sezon, _ in pairs(sezony) do | for sezon, _ in pairs(sezony) do | ||
| Linia 370: | Linia 571: | ||
end | end | ||
table.sort( | table.sort( | ||
| Linia 379: | Linia 581: | ||
end | end | ||
) | ) | ||
-- ===================================================== | -- ===================================================== | ||
| Linia 385: | Linia 588: | ||
local listaKlubow = {} | local listaKlubow = {} | ||
for klub, _ in pairs(kluby) do | for klub, _ in pairs(kluby) do | ||
| Linia 394: | Linia 598: | ||
end | end | ||
table.sort( | table.sort( | ||
| Linia 399: | Linia 604: | ||
) | ) | ||
-- ===================================================== | -- ===================================================== | ||
-- | -- OPIS MECZU | ||
-- ===================================================== | -- ===================================================== | ||
| Linia 426: | Linia 613: | ||
local d1 = | local d1 = | ||
row.druzyna1 or "" | row.druzyna1 or "" | ||
local d2 = | local d2 = | ||
row.druzyna2 or "" | row.druzyna2 or "" | ||
local data = | local data = | ||
row.data or "" | row.data or "" | ||
local wynikMeczu = | local wynikMeczu = | ||
row.wynik or "" | row.wynik or "" | ||
local strona = | local strona = | ||
row.strona_meczu or "" | row.strona_meczu or "" | ||
-- ----------------------------------------------- | -- ----------------------------------------------- | ||
| Linia 447: | Linia 639: | ||
.. " – " | .. " – " | ||
.. d2 | .. d2 | ||
-- ----------------------------------------------- | -- ----------------------------------------------- | ||
| Linia 464: | Linia 657: | ||
end | end | ||
-- ----------------------------------------------- | -- ----------------------------------------------- | ||
| Linia 478: | Linia 672: | ||
end | end | ||
-- ----------------------------------------------- | -- ----------------------------------------------- | ||
| Linia 491: | Linia 686: | ||
end | end | ||
return meczTekst | return meczTekst | ||
end | end | ||
-- ===================================================== | -- ===================================================== | ||
| Linia 504: | Linia 701: | ||
local rekordAsysty = -1 | local rekordAsysty = -1 | ||
local rekordZbiorki = -1 | local rekordZbiorki = -1 | ||
local meczePunkty = {} | local meczePunkty = {} | ||
| Linia 509: | Linia 707: | ||
local meczeAsysty = {} | local meczeAsysty = {} | ||
local meczeZbiorki = {} | local meczeZbiorki = {} | ||
-- ===================================================== | -- ===================================================== | ||
| Linia 518: | Linia 717: | ||
local punkty = | local punkty = | ||
tonumber(row.gol or 0) | tonumber(row.gol or 0) | ||
or 0 | |||
local minuty = | local minuty = | ||
tonumber(row.minuty or 0) | tonumber(row.minuty or 0) | ||
or 0 | |||
local asysty = | local asysty = | ||
tonumber(row.asysta or 0) | tonumber(row.asysta or 0) | ||
or 0 | |||
local zbiorki = | local zbiorki = | ||
tonumber(row.zbiorka or 0) | tonumber(row.zbiorka or 0) | ||
or 0 | |||
-- ----------------------------------------------- | -- ----------------------------------------------- | ||
| Linia 534: | Linia 741: | ||
if punkty > rekordPunkty then | if punkty > rekordPunkty then | ||
rekordPunkty = punkty | rekordPunkty = | ||
punkty | |||
meczePunkty = | |||
{ row } | |||
elseif punkty == rekordPunkty then | elseif punkty == rekordPunkty then | ||
| Linia 546: | Linia 756: | ||
end | end | ||
-- ----------------------------------------------- | -- ----------------------------------------------- | ||
| Linia 553: | Linia 764: | ||
if minuty > rekordMinuty then | if minuty > rekordMinuty then | ||
rekordMinuty = minuty | rekordMinuty = | ||
minuty | |||
meczeMinuty = | |||
{ row } | |||
elseif minuty == rekordMinuty then | elseif minuty == rekordMinuty then | ||
| Linia 565: | Linia 779: | ||
end | end | ||
-- ----------------------------------------------- | -- ----------------------------------------------- | ||
| Linia 572: | Linia 787: | ||
if asysty > rekordAsysty then | if asysty > rekordAsysty then | ||
rekordAsysty = asysty | rekordAsysty = | ||
asysty | |||
meczeAsysty = | |||
{ row } | |||
elseif asysty == rekordAsysty then | elseif asysty == rekordAsysty then | ||
| Linia 584: | Linia 802: | ||
end | end | ||
-- ----------------------------------------------- | -- ----------------------------------------------- | ||
| Linia 591: | Linia 810: | ||
if zbiorki > rekordZbiorki then | if zbiorki > rekordZbiorki then | ||
rekordZbiorki = zbiorki | rekordZbiorki = | ||
zbiorki | |||
meczeZbiorki = | |||
{ row } | |||
elseif zbiorki == rekordZbiorki then | elseif zbiorki == rekordZbiorki then | ||
| Linia 605: | Linia 827: | ||
end | end | ||
-- ===================================================== | -- ===================================================== | ||
| Linia 613: | Linia 836: | ||
local wynikRekordu = {} | local wynikRekordu = {} | ||
for _, row in ipairs(lista) do | for _, row in ipairs(lista) do | ||
| Linia 622: | Linia 846: | ||
end | end | ||
return table.concat( | return table.concat( | ||
| Linia 629: | Linia 854: | ||
end | end | ||
-- ===================================================== | -- ===================================================== | ||
| Linia 635: | Linia 861: | ||
local wynik = {} | local wynik = {} | ||
-- ===================================================== | -- ===================================================== | ||
| Linia 644: | Linia 871: | ||
"== Historia występów ==" | "== Historia występów ==" | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 649: | Linia 877: | ||
"" | "" | ||
) | ) | ||
-- ===================================================== | -- ===================================================== | ||
-- PODSUMOWANIE | -- PODSUMOWANIE | ||
-- ===================================================== | -- ===================================================== | ||
| Linia 658: | Linia 887: | ||
"=== Podsumowanie wszystkich spotkań ===" | "=== Podsumowanie wszystkich spotkań ===" | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 663: | Linia 893: | ||
"" | "" | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 668: | Linia 899: | ||
'{| class="wikitable" style="width:100%; text-align:center;"' | '{| class="wikitable" style="width:100%; text-align:center;"' | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 673: | Linia 905: | ||
"! " | "! " | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 678: | Linia 911: | ||
"! Wszystkie spotkania" | "! Wszystkie spotkania" | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 683: | Linia 917: | ||
"! 🏠 Mecze domowe" | "! 🏠 Mecze domowe" | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 688: | Linia 923: | ||
"! ✈️ Mecze wyjazdowe" | "! ✈️ Mecze wyjazdowe" | ||
) | ) | ||
-- WYSTĘPY | -- WYSTĘPY | ||
| Linia 696: | Linia 932: | ||
table.insert(wynik, "| '''" .. dom.wystepy .. "'''") | table.insert(wynik, "| '''" .. dom.wystepy .. "'''") | ||
table.insert(wynik, "| '''" .. wyjazd.wystepy .. "'''") | table.insert(wynik, "| '''" .. wyjazd.wystepy .. "'''") | ||
-- ZWYCIĘSTWA | -- ZWYCIĘSTWA | ||
| Linia 704: | Linia 941: | ||
table.insert(wynik, "| '''" .. dom.zwyciestwa .. "'''") | table.insert(wynik, "| '''" .. dom.zwyciestwa .. "'''") | ||
table.insert(wynik, "| '''" .. wyjazd.zwyciestwa .. "'''") | table.insert(wynik, "| '''" .. wyjazd.zwyciestwa .. "'''") | ||
-- PORAŻKI | -- PORAŻKI | ||
| Linia 712: | Linia 950: | ||
table.insert(wynik, "| '''" .. dom.porazki .. "'''") | table.insert(wynik, "| '''" .. dom.porazki .. "'''") | ||
table.insert(wynik, "| '''" .. wyjazd.porazki .. "'''") | table.insert(wynik, "| '''" .. wyjazd.porazki .. "'''") | ||
-- REMISY | -- REMISY | ||
| Linia 720: | Linia 959: | ||
table.insert(wynik, "| '''" .. dom.remisy .. "'''") | table.insert(wynik, "| '''" .. dom.remisy .. "'''") | ||
table.insert(wynik, "| '''" .. wyjazd.remisy .. "'''") | table.insert(wynik, "| '''" .. wyjazd.remisy .. "'''") | ||
-- PUNKTY | -- PUNKTY | ||
| Linia 728: | Linia 968: | ||
table.insert(wynik, "| '''" .. dom.punkty .. "'''") | table.insert(wynik, "| '''" .. dom.punkty .. "'''") | ||
table.insert(wynik, "| '''" .. wyjazd.punkty .. "'''") | table.insert(wynik, "| '''" .. wyjazd.punkty .. "'''") | ||
-- MINUTY | -- MINUTY | ||
| Linia 733: | Linia 974: | ||
table.insert(wynik, "|-") | table.insert(wynik, "|-") | ||
table.insert(wynik, "! Minuty") | table.insert(wynik, "! Minuty") | ||
table.insert(wynik, "| '''" .. formatujMinuty(suma.minuty) .. "'''") | table.insert( | ||
table.insert(wynik, "| '''" .. formatujMinuty(dom.minuty) .. "'''") | wynik, | ||
table.insert(wynik, "| '''" .. formatujMinuty(wyjazd.minuty) .. "'''") | "| '''" | ||
.. formatujMinuty(suma.minuty) | |||
.. "'''" | |||
) | |||
table.insert( | |||
wynik, | |||
"| '''" | |||
.. formatujMinuty(dom.minuty) | |||
.. "'''" | |||
) | |||
table.insert( | |||
wynik, | |||
"| '''" | |||
.. formatujMinuty(wyjazd.minuty) | |||
.. "'''" | |||
) | |||
-- ASYSTY | -- ASYSTY | ||
| Linia 744: | Linia 1001: | ||
table.insert(wynik, "| '''" .. dom.asysty .. "'''") | table.insert(wynik, "| '''" .. dom.asysty .. "'''") | ||
table.insert(wynik, "| '''" .. wyjazd.asysty .. "'''") | table.insert(wynik, "| '''" .. wyjazd.asysty .. "'''") | ||
-- ZBIÓRKI | -- ZBIÓRKI | ||
| Linia 752: | Linia 1010: | ||
table.insert(wynik, "| '''" .. dom.zbiorki .. "'''") | table.insert(wynik, "| '''" .. dom.zbiorki .. "'''") | ||
table.insert(wynik, "| '''" .. wyjazd.zbiorki .. "'''") | table.insert(wynik, "| '''" .. wyjazd.zbiorki .. "'''") | ||
-- EVAL | -- EVAL | ||
| Linia 760: | Linia 1019: | ||
table.insert(wynik, "| '''" .. dom.eval .. "'''") | table.insert(wynik, "| '''" .. dom.eval .. "'''") | ||
table.insert(wynik, "| '''" .. wyjazd.eval .. "'''") | table.insert(wynik, "| '''" .. wyjazd.eval .. "'''") | ||
-- PLUS/MINUS | -- PLUS/MINUS | ||
| Linia 768: | Linia 1028: | ||
table.insert(wynik, "| '''" .. dom.plusminus .. "'''") | table.insert(wynik, "| '''" .. dom.plusminus .. "'''") | ||
table.insert(wynik, "| '''" .. wyjazd.plusminus .. "'''") | table.insert(wynik, "| '''" .. wyjazd.plusminus .. "'''") | ||
table.insert( | table.insert( | ||
| Linia 773: | Linia 1034: | ||
"|}" | "|}" | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 778: | Linia 1040: | ||
"" | "" | ||
) | ) | ||
-- ===================================================== | -- ===================================================== | ||
-- REKORDY | -- REKORDY | ||
-- ===================================================== | -- ===================================================== | ||
| Linia 787: | Linia 1050: | ||
"=== Najlepsze występy ===" | "=== Najlepsze występy ===" | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 792: | Linia 1056: | ||
"" | "" | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 797: | Linia 1062: | ||
'{| class="wikitable" style="width:100%;"' | '{| class="wikitable" style="width:100%;"' | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 802: | Linia 1068: | ||
"! Rekord" | "! Rekord" | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 807: | Linia 1074: | ||
"! Wynik" | "! Wynik" | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 812: | Linia 1080: | ||
"! Mecz / mecze" | "! Mecz / mecze" | ||
) | ) | ||
-- PUNKTY | -- PUNKTY | ||
table.insert(wynik, "|-") | table.insert(wynik, "|-") | ||
table.insert(wynik, "! 🏀 Najwięcej punktów") | table.insert( | ||
table.insert(wynik, "| '''" .. rekordPunkty .. "'''") | wynik, | ||
table.insert(wynik, "| " .. listaRekordow(meczePunkty)) | "! 🏀 Najwięcej punktów" | ||
) | |||
table.insert( | |||
wynik, | |||
"| '''" .. rekordPunkty .. "'''" | |||
) | |||
table.insert( | |||
wynik, | |||
"| " .. listaRekordow(meczePunkty) | |||
) | |||
-- MINUTY | -- MINUTY | ||
table.insert(wynik, "|-") | table.insert(wynik, "|-") | ||
table.insert(wynik, "! ⏱ Najwięcej minut") | table.insert( | ||
table.insert(wynik, "| '''" .. formatujMinuty(rekordMinuty) .. "'''") | wynik, | ||
table.insert(wynik, "| " .. listaRekordow(meczeMinuty)) | "! ⏱ Najwięcej minut" | ||
) | |||
table.insert( | |||
wynik, | |||
"| '''" | |||
.. formatujMinuty(rekordMinuty) | |||
.. "'''" | |||
) | |||
table.insert( | |||
wynik, | |||
"| " .. listaRekordow(meczeMinuty) | |||
) | |||
-- ASYSTY | -- ASYSTY | ||
table.insert(wynik, "|-") | table.insert(wynik, "|-") | ||
table.insert(wynik, "! 🎯 Najwięcej asyst") | table.insert( | ||
table.insert(wynik, "| '''" .. rekordAsysty .. "'''") | wynik, | ||
table.insert(wynik, "| " .. listaRekordow(meczeAsysty)) | "! 🎯 Najwięcej asyst" | ||
) | |||
table.insert( | |||
wynik, | |||
"| '''" .. rekordAsysty .. "'''" | |||
) | |||
table.insert( | |||
wynik, | |||
"| " .. listaRekordow(meczeAsysty) | |||
) | |||
-- ZBIÓRKI | -- ZBIÓRKI | ||
table.insert(wynik, "|-") | table.insert(wynik, "|-") | ||
table.insert(wynik, "! 🏀 Najwięcej zbiórek") | table.insert( | ||
table.insert(wynik, "| '''" .. rekordZbiorki .. "'''") | wynik, | ||
table.insert(wynik, "| " .. listaRekordow(meczeZbiorki)) | "! 🏀 Najwięcej zbiórek" | ||
) | |||
table.insert( | |||
wynik, | |||
"| '''" .. rekordZbiorki .. "'''" | |||
) | |||
table.insert( | |||
wynik, | |||
"| " .. listaRekordow(meczeZbiorki) | |||
) | |||
table.insert( | table.insert( | ||
| Linia 845: | Linia 1156: | ||
"|}" | "|}" | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 850: | Linia 1162: | ||
"" | "" | ||
) | ) | ||
-- ===================================================== | -- ===================================================== | ||
| Linia 859: | Linia 1172: | ||
"=== Podsumowanie sezonów ===" | "=== Podsumowanie sezonów ===" | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 864: | Linia 1178: | ||
"" | "" | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 869: | Linia 1184: | ||
'{| class="wikitable sortable" style="width:100%; text-align:center;"' | '{| class="wikitable sortable" style="width:100%; text-align:center;"' | ||
) | ) | ||
table.insert(wynik, "! Sezon") | table.insert(wynik, "! Sezon") | ||
| Linia 881: | Linia 1197: | ||
table.insert(wynik, "! EVAL") | table.insert(wynik, "! EVAL") | ||
table.insert(wynik, "! +/-") | table.insert(wynik, "! +/-") | ||
for _, sezon in ipairs(listaSezonow) do | for _, sezon in ipairs(listaSezonow) do | ||
| Linia 887: | Linia 1204: | ||
sezony[sezon] | sezony[sezon] | ||
table.insert( | table.insert( | ||
wynik, | wynik, | ||
"| | "|-" | ||
) | ) | ||
table.insert( | |||
wynik, | |||
"| '''" | |||
.. sezon | |||
.. "'''" | |||
) | |||
table.insert( | table.insert( | ||
| Linia 898: | Linia 1223: | ||
"| " .. stat.wystepy | "| " .. stat.wystepy | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 903: | Linia 1229: | ||
"| " .. stat.zwyciestwa | "| " .. stat.zwyciestwa | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 908: | Linia 1235: | ||
"| " .. stat.porazki | "| " .. stat.porazki | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 913: | Linia 1241: | ||
"| " .. stat.remisy | "| " .. stat.remisy | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 918: | Linia 1247: | ||
"| " .. stat.punkty | "| " .. stat.punkty | ||
) | ) | ||
table.insert( | table.insert( | ||
wynik, | wynik, | ||
"| " .. formatujMinuty(stat.minuty) | "| " | ||
.. formatujMinuty( | |||
stat.minuty | |||
) | |||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 928: | Linia 1262: | ||
"| " .. stat.asysty | "| " .. stat.asysty | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 933: | Linia 1268: | ||
"| " .. stat.zbiorki | "| " .. stat.zbiorki | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 938: | Linia 1274: | ||
"| " .. stat.eval | "| " .. stat.eval | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 945: | Linia 1282: | ||
end | end | ||
table.insert( | table.insert( | ||
| Linia 950: | Linia 1288: | ||
"|}" | "|}" | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 955: | Linia 1294: | ||
"" | "" | ||
) | ) | ||
-- ===================================================== | -- ===================================================== | ||
| Linia 964: | Linia 1304: | ||
"=== Podsumowanie według klubu ===" | "=== Podsumowanie według klubu ===" | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 969: | Linia 1310: | ||
"" | "" | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 974: | Linia 1316: | ||
'{| class="wikitable sortable" style="width:100%; text-align:center;"' | '{| class="wikitable sortable" style="width:100%; text-align:center;"' | ||
) | ) | ||
table.insert(wynik, "! Klub") | table.insert(wynik, "! Klub") | ||
| Linia 986: | Linia 1329: | ||
table.insert(wynik, "! EVAL") | table.insert(wynik, "! EVAL") | ||
table.insert(wynik, "! +/-") | table.insert(wynik, "! +/-") | ||
for _, klub in ipairs(listaKlubow) do | for _, klub in ipairs(listaKlubow) do | ||
| Linia 991: | Linia 1335: | ||
local stat = | local stat = | ||
kluby[klub] | kluby[klub] | ||
table.insert( | table.insert( | ||
| Linia 996: | Linia 1341: | ||
"|-" | "|-" | ||
) | ) | ||
table.insert( | table.insert( | ||
wynik, | wynik, | ||
"| '''" .. klub .. "'''" | "| '''" | ||
.. klub | |||
.. "'''" | |||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 1006: | Linia 1355: | ||
"| " .. stat.wystepy | "| " .. stat.wystepy | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 1011: | Linia 1361: | ||
"| " .. stat.zwyciestwa | "| " .. stat.zwyciestwa | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 1016: | Linia 1367: | ||
"| " .. stat.porazki | "| " .. stat.porazki | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 1021: | Linia 1373: | ||
"| " .. stat.remisy | "| " .. stat.remisy | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 1026: | Linia 1379: | ||
"| " .. stat.punkty | "| " .. stat.punkty | ||
) | ) | ||
table.insert( | table.insert( | ||
wynik, | wynik, | ||
"| " .. formatujMinuty(stat.minuty) | "| " | ||
.. formatujMinuty( | |||
stat.minuty | |||
) | |||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 1036: | Linia 1394: | ||
"| " .. stat.asysty | "| " .. stat.asysty | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 1041: | Linia 1400: | ||
"| " .. stat.zbiorki | "| " .. stat.zbiorki | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 1046: | Linia 1406: | ||
"| " .. stat.eval | "| " .. stat.eval | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 1053: | Linia 1414: | ||
end | end | ||
table.insert( | table.insert( | ||
| Linia 1058: | Linia 1420: | ||
"|}" | "|}" | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 1063: | Linia 1426: | ||
"" | "" | ||
) | ) | ||
-- ===================================================== | -- ===================================================== | ||
| Linia 1072: | Linia 1436: | ||
"=== Mecze ===" | "=== Mecze ===" | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 1077: | Linia 1442: | ||
"" | "" | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 1082: | Linia 1448: | ||
'{| class="wikitable sortable" style="width:100%;"' | '{| class="wikitable sortable" style="width:100%;"' | ||
) | ) | ||
table.insert(wynik, "! Nr") | table.insert(wynik, "! Nr") | ||
| Linia 1096: | Linia 1463: | ||
table.insert(wynik, "! +/-") | table.insert(wynik, "! +/-") | ||
table.insert(wynik, "! Jubileusz") | table.insert(wynik, "! Jubileusz") | ||
-- ===================================================== | -- ===================================================== | ||
| Linia 1105: | Linia 1473: | ||
local data = | local data = | ||
row.data or "" | row.data or "" | ||
local sezon = | local sezon = | ||
row.sezon or "" | row.sezon or "" | ||
local d1 = | local d1 = | ||
row.druzyna1 or "" | row.druzyna1 or "" | ||
local d2 = | local d2 = | ||
row.druzyna2 or "" | row.druzyna2 or "" | ||
local druzyna = | local druzyna = | ||
row.druzyna or "" | row.druzyna or "" | ||
local wynikMeczu = | local wynikMeczu = | ||
row.wynik or "" | row.wynik or "" | ||
local strona = | local strona = | ||
row.strona_meczu or "" | row.strona_meczu or "" | ||
local minutyFormat = | local minutyFormat = | ||
row.minuty_format or "" | row.minuty_format or "" | ||
local pkt = | local pkt = | ||
row.gol or "0" | row.gol or "0" | ||
local asysty = | local asysty = | ||
row.asysta or "0" | row.asysta or "0" | ||
local zbiorki = | local zbiorki = | ||
row.zbiorka or "0" | row.zbiorka or "0" | ||
local eval = | local eval = | ||
row.eval or "0" | row.eval or "0" | ||
local plusminus = | local plusminus = | ||
row.plusminus or "0" | row.plusminus or "0" | ||
-- ----------------------------------------------- | -- ----------------------------------------------- | ||
| Linia 1147: | Linia 1528: | ||
local miejsce = "" | local miejsce = "" | ||
if druzyna == d1 then | if druzyna == d1 then | ||
| Linia 1152: | Linia 1534: | ||
miejsce = | miejsce = | ||
"🏠 Dom" | "🏠 Dom" | ||
elseif druzyna == d2 then | elseif druzyna == d2 then | ||
| Linia 1159: | Linia 1542: | ||
end | end | ||
-- ----------------------------------------------- | -- ----------------------------------------------- | ||
| Linia 1165: | Linia 1549: | ||
local przeciwnik = "" | local przeciwnik = "" | ||
if druzyna == d1 then | if druzyna == d1 then | ||
| Linia 1170: | Linia 1555: | ||
przeciwnik = | przeciwnik = | ||
d2 | d2 | ||
elseif druzyna == d2 then | elseif druzyna == d2 then | ||
| Linia 1175: | Linia 1561: | ||
przeciwnik = | przeciwnik = | ||
d1 | d1 | ||
else | else | ||
| Linia 1182: | Linia 1569: | ||
end | end | ||
-- ----------------------------------------------- | -- ----------------------------------------------- | ||
| Linia 1189: | Linia 1577: | ||
local meczTekst = | local meczTekst = | ||
przeciwnik | przeciwnik | ||
if strona ~= "" then | if strona ~= "" then | ||
| Linia 1200: | Linia 1589: | ||
end | end | ||
-- ----------------------------------------------- | -- ----------------------------------------------- | ||
| Linia 1206: | Linia 1596: | ||
local jubileusz = "" | local jubileusz = "" | ||
if i % 50 == 0 then | if i % 50 == 0 then | ||
| Linia 1215: | Linia 1606: | ||
end | end | ||
-- ----------------------------------------------- | -- ----------------------------------------------- | ||
| Linia 1224: | Linia 1616: | ||
"|-" | "|-" | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 1229: | Linia 1622: | ||
"| " .. i | "| " .. i | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 1234: | Linia 1628: | ||
"| " .. sezon | "| " .. sezon | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 1239: | Linia 1634: | ||
"| " .. data | "| " .. data | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 1244: | Linia 1640: | ||
"| " .. miejsce | "| " .. miejsce | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 1249: | Linia 1646: | ||
"| " .. meczTekst | "| " .. meczTekst | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 1254: | Linia 1652: | ||
"| " .. wynikMeczu | "| " .. wynikMeczu | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 1259: | Linia 1658: | ||
"| " .. minutyFormat | "| " .. minutyFormat | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 1264: | Linia 1664: | ||
"| " .. pkt | "| " .. pkt | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 1269: | Linia 1670: | ||
"| " .. asysty | "| " .. asysty | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 1274: | Linia 1676: | ||
"| " .. zbiorki | "| " .. zbiorki | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 1279: | Linia 1682: | ||
"| " .. eval | "| " .. eval | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 1284: | Linia 1688: | ||
"| " .. plusminus | "| " .. plusminus | ||
) | ) | ||
table.insert( | table.insert( | ||
| Linia 1291: | Linia 1696: | ||
end | end | ||
-- ===================================================== | -- ===================================================== | ||
| Linia 1300: | Linia 1706: | ||
"|}" | "|}" | ||
) | ) | ||
-- ===================================================== | -- ===================================================== | ||
| Linia 1311: | Linia 1718: | ||
end | end | ||
return p | return p | ||
Wersja z 06:05, 19 sie 2026
Dokumentacja dla tego modułu może zostać utworzona pod nazwą Moduł:HistoriaWystepow/opis
local p = {}
-- =========================================================
-- MODUŁ:HISTORIAWYSTĘPÓW
--
-- Historia występów zawodnika
--
-- UWAGA:
-- Moduł pokazuje wyłącznie występy zawodnika
-- w drużynach poznańskich.
--
-- Liczy się UdzialZawodnika.druzyna,
-- a NIE przeciwnik.
--
-- Dzięki temu:
-- Enea Basket Poznań vs Resovia -> TAK
-- Resovia vs Enea Basket Poznań -> NIE
-- =========================================================
-- =========================================================
-- DRUŻYNY POZNAŃSKIE
-- =========================================================
--
-- Tutaj dopisujemy kolejne drużyny poznańskie.
--
-- Nazwa musi być identyczna z wartością pola "druzyna"
-- w UdzialZawodnika.
--
local druzynyPoznanskie = {
["Enea Basket Poznań"] = true,
["Enea AZS Politechnika Poznań"] = true,
["Lech Poznań"] = true,
["Warta Poznań"] = true,
["AZS Politechnika Poznań"] = true,
["MUKS Poznań"] = true
}
function p.main(frame)
local zawodnik =
mw.text.trim(
frame.args.zawodnik or ""
)
if zawodnik == "" then
zawodnik =
mw.title
.getCurrentTitle()
.text
end
-- =====================================================
-- BEZPIECZNE PRZYGOTOWANIE NAZWY ZAWODNIKA
-- =====================================================
local zawodnikSQL =
mw.ustring.gsub(
zawodnik,
"'",
"''"
)
-- =====================================================
-- POLA POBIERANE Z CARGO
-- =====================================================
local fields = table.concat({
"UdzialZawodnika.mecz=mecz",
"UdzialZawodnika.druzyna=druzyna",
"UdzialZawodnika.minuty=minuty",
"UdzialZawodnika.minuty_format=minuty_format",
"UdzialZawodnika.gol=gol",
"UdzialZawodnika.asysta=asysta",
"UdzialZawodnika.zbiorka=zbiorka",
"UdzialZawodnika.eval=eval",
"UdzialZawodnika.plusminus=plusminus",
"Mecze.data=data",
"Mecze.sezon=sezon",
"Mecze.druzyna1=druzyna1",
"Mecze.druzyna2=druzyna2",
"Mecze.wynik=wynik",
"Mecze.strona_meczu=strona_meczu"
}, ",")
-- =====================================================
-- ZAPYTANIE CARGO
--
-- Pobieramy wszystkie występy zawodnika,
-- a następnie filtrujemy je według drużyny.
--
-- NIE filtrujemy Mecze.druzyna1/druzyna2,
-- ponieważ przeciwnik może być drużyną poznańską.
-- =====================================================
local args = {
join =
"UdzialZawodnika.mecz=Mecze.id",
where =
"UdzialZawodnika.zawodnik='"
.. zawodnikSQL
.. "' AND UdzialZawodnika.minuty > 0",
orderBy =
"Mecze.data ASC",
limit = 5000
}
local rows =
mw.ext.cargo.query(
"UdzialZawodnika,Mecze",
fields,
args
)
-- =====================================================
-- FILTR DRUŻYN POZNAŃSKICH
--
-- Sprawdzamy U.druzyna.
--
-- Dzięki temu zawodnik występujący przeciwko
-- drużynie poznańskiej, ale reprezentujący
-- drużynę przyjezdną, NIE zostanie uwzględniony.
-- =====================================================
local tylkoPoznanskie = {}
if rows then
for _, row in ipairs(rows) do
local druzyna =
mw.text.trim(
row.druzyna or ""
)
if druzynyPoznanskie[druzyna] then
table.insert(
tylkoPoznanskie,
row
)
end
end
end
rows =
tylkoPoznanskie
-- =====================================================
-- BRAK DANYCH
-- =====================================================
if not rows or #rows == 0 then
return
"''Brak wprowadzonych występów zawodnika "
.. "dla drużyn poznańskich w bazie.''"
end
-- =====================================================
-- PODSUMOWANIE
-- =====================================================
local function nowePodsumowanie()
return {
wystepy = 0,
zwyciestwa = 0,
porazki = 0,
remisy = 0,
punkty = 0,
minuty = 0,
asysty = 0,
zbiorki = 0,
eval = 0,
plusminus = 0
}
end
-- =====================================================
-- PODSUMOWANIA
-- =====================================================
local suma =
nowePodsumowanie()
local dom =
nowePodsumowanie()
local wyjazd =
nowePodsumowanie()
-- sezony
local sezony = {}
-- kluby
local kluby = {}
-- =====================================================
-- OKREŚLENIE WYNIKU MECZU
-- =====================================================
local function okreslWynik(row)
local d1 =
row.druzyna1 or ""
local d2 =
row.druzyna2 or ""
local druzyna =
row.druzyna or ""
local wynikMeczu =
row.wynik or ""
local g1, g2 =
wynikMeczu:match(
"(%d+)%s*:%s*(%d+)"
)
if not g1 or not g2 then
return nil
end
g1 =
tonumber(g1)
g2 =
tonumber(g2)
if druzyna == d1 then
if g1 > g2 then
return "W"
elseif g1 < g2 then
return "P"
else
return "R"
end
elseif druzyna == d2 then
if g2 > g1 then
return "W"
elseif g2 < g1 then
return "P"
else
return "R"
end
end
return nil
end
-- =====================================================
-- DODANIE MECZU DO PODSUMOWANIA
-- =====================================================
local function dodajDoPodsumowania(
stat,
row
)
stat.wystepy =
stat.wystepy + 1
stat.punkty =
stat.punkty
+ (
tonumber(row.gol or 0)
or 0
)
stat.minuty =
stat.minuty
+ (
tonumber(row.minuty or 0)
or 0
)
stat.asysty =
stat.asysty
+ (
tonumber(row.asysta or 0)
or 0
)
stat.zbiorki =
stat.zbiorki
+ (
tonumber(row.zbiorka or 0)
or 0
)
stat.eval =
stat.eval
+ (
tonumber(row.eval or 0)
or 0
)
stat.plusminus =
stat.plusminus
+ (
tonumber(row.plusminus or 0)
or 0
)
local wynik =
okreslWynik(row)
if wynik == "W" then
stat.zwyciestwa =
stat.zwyciestwa + 1
elseif wynik == "P" then
stat.porazki =
stat.porazki + 1
elseif wynik == "R" then
stat.remisy =
stat.remisy + 1
end
end
-- =====================================================
-- PRZEJŚCIE PRZEZ WSZYSTKIE MECZE
-- =====================================================
for _, row in ipairs(rows) do
-- -----------------------------------------------
-- WSZYSTKIE
-- -----------------------------------------------
dodajDoPodsumowania(
suma,
row
)
-- -----------------------------------------------
-- DOM / WYJAZD
-- -----------------------------------------------
local d1 =
row.druzyna1 or ""
local d2 =
row.druzyna2 or ""
local druzyna =
row.druzyna or ""
if druzyna == d1 then
dodajDoPodsumowania(
dom,
row
)
elseif druzyna == d2 then
dodajDoPodsumowania(
wyjazd,
row
)
end
-- -----------------------------------------------
-- SEZON
-- -----------------------------------------------
local sezon =
row.sezon or ""
if sezon == "" then
sezon =
"Brak sezonu"
end
if not sezony[sezon] then
sezony[sezon] =
nowePodsumowanie()
end
dodajDoPodsumowania(
sezony[sezon],
row
)
-- -----------------------------------------------
-- KLUB
-- -----------------------------------------------
if druzyna == "" then
druzyna =
"Brak klubu"
end
if not kluby[druzyna] then
kluby[druzyna] =
nowePodsumowanie()
end
dodajDoPodsumowania(
kluby[druzyna],
row
)
end
-- =====================================================
-- FORMATOWANIE MINUT
-- =====================================================
local function formatujMinuty(minuty)
local godziny =
math.floor(
minuty / 60
)
local min =
minuty % 60
return string.format(
"%d:%02d",
godziny,
min
)
end
-- =====================================================
-- SORTOWANIE SEZONÓW
-- =====================================================
local listaSezonow = {}
for sezon, _ in pairs(sezony) do
table.insert(
listaSezonow,
sezon
)
end
table.sort(
listaSezonow,
function(a, b)
return a > b
end
)
-- =====================================================
-- SORTOWANIE KLUBÓW
-- =====================================================
local listaKlubow = {}
for klub, _ in pairs(kluby) do
table.insert(
listaKlubow,
klub
)
end
table.sort(
listaKlubow
)
-- =====================================================
-- OPIS MECZU
-- =====================================================
local function rekordMecz(row)
local d1 =
row.druzyna1 or ""
local d2 =
row.druzyna2 or ""
local data =
row.data or ""
local wynikMeczu =
row.wynik or ""
local strona =
row.strona_meczu or ""
-- -----------------------------------------------
-- FAKTYCZNY ZAPIS MECZU
-- -----------------------------------------------
local meczTekst =
d1
.. " – "
.. d2
-- -----------------------------------------------
-- LINK DO STRONY MECZU
-- -----------------------------------------------
if strona ~= "" then
meczTekst =
"[["
.. strona
.. "|"
.. d1
.. " – "
.. d2
.. "]]"
end
-- -----------------------------------------------
-- DATA
-- -----------------------------------------------
if data ~= "" then
meczTekst =
meczTekst
.. " ("
.. data
.. ")"
end
-- -----------------------------------------------
-- WYNIK
-- -----------------------------------------------
if wynikMeczu ~= "" then
meczTekst =
meczTekst
.. " "
.. wynikMeczu
end
return meczTekst
end
-- =====================================================
-- REKORDY
-- =====================================================
local rekordPunkty = -1
local rekordMinuty = -1
local rekordAsysty = -1
local rekordZbiorki = -1
local meczePunkty = {}
local meczeMinuty = {}
local meczeAsysty = {}
local meczeZbiorki = {}
-- =====================================================
-- WYSZUKIWANIE REKORDÓW
-- =====================================================
for _, row in ipairs(rows) do
local punkty =
tonumber(row.gol or 0)
or 0
local minuty =
tonumber(row.minuty or 0)
or 0
local asysty =
tonumber(row.asysta or 0)
or 0
local zbiorki =
tonumber(row.zbiorka or 0)
or 0
-- -----------------------------------------------
-- PUNKTY
-- -----------------------------------------------
if punkty > rekordPunkty then
rekordPunkty =
punkty
meczePunkty =
{ row }
elseif punkty == rekordPunkty then
table.insert(
meczePunkty,
row
)
end
-- -----------------------------------------------
-- MINUTY
-- -----------------------------------------------
if minuty > rekordMinuty then
rekordMinuty =
minuty
meczeMinuty =
{ row }
elseif minuty == rekordMinuty then
table.insert(
meczeMinuty,
row
)
end
-- -----------------------------------------------
-- ASYSTY
-- -----------------------------------------------
if asysty > rekordAsysty then
rekordAsysty =
asysty
meczeAsysty =
{ row }
elseif asysty == rekordAsysty then
table.insert(
meczeAsysty,
row
)
end
-- -----------------------------------------------
-- ZBIÓRKI
-- -----------------------------------------------
if zbiorki > rekordZbiorki then
rekordZbiorki =
zbiorki
meczeZbiorki =
{ row }
elseif zbiorki == rekordZbiorki then
table.insert(
meczeZbiorki,
row
)
end
end
-- =====================================================
-- LISTA MECZÓW W REKORDZIE
-- =====================================================
local function listaRekordow(lista)
local wynikRekordu = {}
for _, row in ipairs(lista) do
table.insert(
wynikRekordu,
rekordMecz(row)
)
end
return table.concat(
wynikRekordu,
"<br>"
)
end
-- =====================================================
-- WYNIK
-- =====================================================
local wynik = {}
-- =====================================================
-- HISTORIA
-- =====================================================
table.insert(
wynik,
"== Historia występów =="
)
table.insert(
wynik,
""
)
-- =====================================================
-- PODSUMOWANIE
-- =====================================================
table.insert(
wynik,
"=== Podsumowanie wszystkich spotkań ==="
)
table.insert(
wynik,
""
)
table.insert(
wynik,
'{| class="wikitable" style="width:100%; text-align:center;"'
)
table.insert(
wynik,
"! "
)
table.insert(
wynik,
"! Wszystkie spotkania"
)
table.insert(
wynik,
"! 🏠 Mecze domowe"
)
table.insert(
wynik,
"! ✈️ Mecze wyjazdowe"
)
-- WYSTĘPY
table.insert(wynik, "|-")
table.insert(wynik, "! Występy")
table.insert(wynik, "| '''" .. suma.wystepy .. "'''")
table.insert(wynik, "| '''" .. dom.wystepy .. "'''")
table.insert(wynik, "| '''" .. wyjazd.wystepy .. "'''")
-- ZWYCIĘSTWA
table.insert(wynik, "|-")
table.insert(wynik, "! Zwycięstwa")
table.insert(wynik, "| '''" .. suma.zwyciestwa .. "'''")
table.insert(wynik, "| '''" .. dom.zwyciestwa .. "'''")
table.insert(wynik, "| '''" .. wyjazd.zwyciestwa .. "'''")
-- PORAŻKI
table.insert(wynik, "|-")
table.insert(wynik, "! Porażki")
table.insert(wynik, "| '''" .. suma.porazki .. "'''")
table.insert(wynik, "| '''" .. dom.porazki .. "'''")
table.insert(wynik, "| '''" .. wyjazd.porazki .. "'''")
-- REMISY
table.insert(wynik, "|-")
table.insert(wynik, "! Remisy")
table.insert(wynik, "| '''" .. suma.remisy .. "'''")
table.insert(wynik, "| '''" .. dom.remisy .. "'''")
table.insert(wynik, "| '''" .. wyjazd.remisy .. "'''")
-- PUNKTY
table.insert(wynik, "|-")
table.insert(wynik, "! Punkty")
table.insert(wynik, "| '''" .. suma.punkty .. "'''")
table.insert(wynik, "| '''" .. dom.punkty .. "'''")
table.insert(wynik, "| '''" .. wyjazd.punkty .. "'''")
-- MINUTY
table.insert(wynik, "|-")
table.insert(wynik, "! Minuty")
table.insert(
wynik,
"| '''"
.. formatujMinuty(suma.minuty)
.. "'''"
)
table.insert(
wynik,
"| '''"
.. formatujMinuty(dom.minuty)
.. "'''"
)
table.insert(
wynik,
"| '''"
.. formatujMinuty(wyjazd.minuty)
.. "'''"
)
-- ASYSTY
table.insert(wynik, "|-")
table.insert(wynik, "! Asysty")
table.insert(wynik, "| '''" .. suma.asysty .. "'''")
table.insert(wynik, "| '''" .. dom.asysty .. "'''")
table.insert(wynik, "| '''" .. wyjazd.asysty .. "'''")
-- ZBIÓRKI
table.insert(wynik, "|-")
table.insert(wynik, "! Zbiórki")
table.insert(wynik, "| '''" .. suma.zbiorki .. "'''")
table.insert(wynik, "| '''" .. dom.zbiorki .. "'''")
table.insert(wynik, "| '''" .. wyjazd.zbiorki .. "'''")
-- EVAL
table.insert(wynik, "|-")
table.insert(wynik, "! EVAL")
table.insert(wynik, "| '''" .. suma.eval .. "'''")
table.insert(wynik, "| '''" .. dom.eval .. "'''")
table.insert(wynik, "| '''" .. wyjazd.eval .. "'''")
-- PLUS/MINUS
table.insert(wynik, "|-")
table.insert(wynik, "! +/-")
table.insert(wynik, "| '''" .. suma.plusminus .. "'''")
table.insert(wynik, "| '''" .. dom.plusminus .. "'''")
table.insert(wynik, "| '''" .. wyjazd.plusminus .. "'''")
table.insert(
wynik,
"|}"
)
table.insert(
wynik,
""
)
-- =====================================================
-- REKORDY
-- =====================================================
table.insert(
wynik,
"=== Najlepsze występy ==="
)
table.insert(
wynik,
""
)
table.insert(
wynik,
'{| class="wikitable" style="width:100%;"'
)
table.insert(
wynik,
"! Rekord"
)
table.insert(
wynik,
"! Wynik"
)
table.insert(
wynik,
"! Mecz / mecze"
)
-- PUNKTY
table.insert(wynik, "|-")
table.insert(
wynik,
"! 🏀 Najwięcej punktów"
)
table.insert(
wynik,
"| '''" .. rekordPunkty .. "'''"
)
table.insert(
wynik,
"| " .. listaRekordow(meczePunkty)
)
-- MINUTY
table.insert(wynik, "|-")
table.insert(
wynik,
"! ⏱ Najwięcej minut"
)
table.insert(
wynik,
"| '''"
.. formatujMinuty(rekordMinuty)
.. "'''"
)
table.insert(
wynik,
"| " .. listaRekordow(meczeMinuty)
)
-- ASYSTY
table.insert(wynik, "|-")
table.insert(
wynik,
"! 🎯 Najwięcej asyst"
)
table.insert(
wynik,
"| '''" .. rekordAsysty .. "'''"
)
table.insert(
wynik,
"| " .. listaRekordow(meczeAsysty)
)
-- ZBIÓRKI
table.insert(wynik, "|-")
table.insert(
wynik,
"! 🏀 Najwięcej zbiórek"
)
table.insert(
wynik,
"| '''" .. rekordZbiorki .. "'''"
)
table.insert(
wynik,
"| " .. listaRekordow(meczeZbiorki)
)
table.insert(
wynik,
"|}"
)
table.insert(
wynik,
""
)
-- =====================================================
-- PODSUMOWANIE SEZONÓW
-- =====================================================
table.insert(
wynik,
"=== Podsumowanie sezonów ==="
)
table.insert(
wynik,
""
)
table.insert(
wynik,
'{| class="wikitable sortable" style="width:100%; text-align:center;"'
)
table.insert(wynik, "! Sezon")
table.insert(wynik, "! Występy")
table.insert(wynik, "! Zwycięstwa")
table.insert(wynik, "! Porażki")
table.insert(wynik, "! Remisy")
table.insert(wynik, "! Punkty")
table.insert(wynik, "! Minuty")
table.insert(wynik, "! Asysty")
table.insert(wynik, "! Zbiórki")
table.insert(wynik, "! EVAL")
table.insert(wynik, "! +/-")
for _, sezon in ipairs(listaSezonow) do
local stat =
sezony[sezon]
table.insert(
wynik,
"|-"
)
table.insert(
wynik,
"| '''"
.. sezon
.. "'''"
)
table.insert(
wynik,
"| " .. stat.wystepy
)
table.insert(
wynik,
"| " .. stat.zwyciestwa
)
table.insert(
wynik,
"| " .. stat.porazki
)
table.insert(
wynik,
"| " .. stat.remisy
)
table.insert(
wynik,
"| " .. stat.punkty
)
table.insert(
wynik,
"| "
.. formatujMinuty(
stat.minuty
)
)
table.insert(
wynik,
"| " .. stat.asysty
)
table.insert(
wynik,
"| " .. stat.zbiorki
)
table.insert(
wynik,
"| " .. stat.eval
)
table.insert(
wynik,
"| " .. stat.plusminus
)
end
table.insert(
wynik,
"|}"
)
table.insert(
wynik,
""
)
-- =====================================================
-- PODSUMOWANIE WEDŁUG KLUBU
-- =====================================================
table.insert(
wynik,
"=== Podsumowanie według klubu ==="
)
table.insert(
wynik,
""
)
table.insert(
wynik,
'{| class="wikitable sortable" style="width:100%; text-align:center;"'
)
table.insert(wynik, "! Klub")
table.insert(wynik, "! Występy")
table.insert(wynik, "! Zwycięstwa")
table.insert(wynik, "! Porażki")
table.insert(wynik, "! Remisy")
table.insert(wynik, "! Punkty")
table.insert(wynik, "! Minuty")
table.insert(wynik, "! Asysty")
table.insert(wynik, "! Zbiórki")
table.insert(wynik, "! EVAL")
table.insert(wynik, "! +/-")
for _, klub in ipairs(listaKlubow) do
local stat =
kluby[klub]
table.insert(
wynik,
"|-"
)
table.insert(
wynik,
"| '''"
.. klub
.. "'''"
)
table.insert(
wynik,
"| " .. stat.wystepy
)
table.insert(
wynik,
"| " .. stat.zwyciestwa
)
table.insert(
wynik,
"| " .. stat.porazki
)
table.insert(
wynik,
"| " .. stat.remisy
)
table.insert(
wynik,
"| " .. stat.punkty
)
table.insert(
wynik,
"| "
.. formatujMinuty(
stat.minuty
)
)
table.insert(
wynik,
"| " .. stat.asysty
)
table.insert(
wynik,
"| " .. stat.zbiorki
)
table.insert(
wynik,
"| " .. stat.eval
)
table.insert(
wynik,
"| " .. stat.plusminus
)
end
table.insert(
wynik,
"|}"
)
table.insert(
wynik,
""
)
-- =====================================================
-- TABELA WSZYSTKICH WYSTĘPÓW
-- =====================================================
table.insert(
wynik,
"=== Mecze ==="
)
table.insert(
wynik,
""
)
table.insert(
wynik,
'{| class="wikitable sortable" style="width:100%;"'
)
table.insert(wynik, "! Nr")
table.insert(wynik, "! Sezon")
table.insert(wynik, "! Data")
table.insert(wynik, "! Miejsce")
table.insert(wynik, "! Przeciwnik")
table.insert(wynik, "! Wynik")
table.insert(wynik, "! Min.")
table.insert(wynik, "! Pkt")
table.insert(wynik, "! As.")
table.insert(wynik, "! Zb.")
table.insert(wynik, "! EVAL")
table.insert(wynik, "! +/-")
table.insert(wynik, "! Jubileusz")
-- =====================================================
-- POSZCZEGÓLNE MECZE
-- =====================================================
for i, row in ipairs(rows) do
local data =
row.data or ""
local sezon =
row.sezon or ""
local d1 =
row.druzyna1 or ""
local d2 =
row.druzyna2 or ""
local druzyna =
row.druzyna or ""
local wynikMeczu =
row.wynik or ""
local strona =
row.strona_meczu or ""
local minutyFormat =
row.minuty_format or ""
local pkt =
row.gol or "0"
local asysty =
row.asysta or "0"
local zbiorki =
row.zbiorka or "0"
local eval =
row.eval or "0"
local plusminus =
row.plusminus or "0"
-- -----------------------------------------------
-- DOM / WYJAZD
-- -----------------------------------------------
local miejsce = ""
if druzyna == d1 then
miejsce =
"🏠 Dom"
elseif druzyna == d2 then
miejsce =
"✈️ Wyjazd"
end
-- -----------------------------------------------
-- PRZECIWNIK
-- -----------------------------------------------
local przeciwnik = ""
if druzyna == d1 then
przeciwnik =
d2
elseif druzyna == d2 then
przeciwnik =
d1
else
przeciwnik =
d1
end
-- -----------------------------------------------
-- LINK DO MECZU
-- -----------------------------------------------
local meczTekst =
przeciwnik
if strona ~= "" then
meczTekst =
"[["
.. strona
.. "|"
.. przeciwnik
.. "]]"
end
-- -----------------------------------------------
-- JUBILEUSZ
-- -----------------------------------------------
local jubileusz = ""
if i % 50 == 0 then
jubileusz =
"'''🏆 "
.. i
.. ". występ'''"
end
-- -----------------------------------------------
-- WIERSZ
-- -----------------------------------------------
table.insert(
wynik,
"|-"
)
table.insert(
wynik,
"| " .. i
)
table.insert(
wynik,
"| " .. sezon
)
table.insert(
wynik,
"| " .. data
)
table.insert(
wynik,
"| " .. miejsce
)
table.insert(
wynik,
"| " .. meczTekst
)
table.insert(
wynik,
"| " .. wynikMeczu
)
table.insert(
wynik,
"| " .. minutyFormat
)
table.insert(
wynik,
"| " .. pkt
)
table.insert(
wynik,
"| " .. asysty
)
table.insert(
wynik,
"| " .. zbiorki
)
table.insert(
wynik,
"| " .. eval
)
table.insert(
wynik,
"| " .. plusminus
)
table.insert(
wynik,
"| " .. jubileusz
)
end
-- =====================================================
-- KONIEC TABELI
-- =====================================================
table.insert(
wynik,
"|}"
)
-- =====================================================
-- ZWRÓCENIE WYNIKU
-- =====================================================
return table.concat(
wynik,
"\n"
)
end
return p