Przejdź do zawartości

Moduł:Rekordy sezon: Różnice pomiędzy wersjami

Z Encyklopedia Poznanskiego Sportu
Nie podano opisu zmian
Nie podano opisu zmian
 
(Nie pokazano 7 pośrednich wersji utworzonych przez tego samego użytkownika)
Linia 4: Linia 4:
-- Moduł:Rekordy_sezon
-- Moduł:Rekordy_sezon
--
--
-- Wspólny moduł rekordów sezonu.
-- Jeden moduł dla różnych dyscyplin.
--
--
-- Wywołanie:
-- Wywołanie:
Linia 14: Linia 14:
-- }}
-- }}
--
--
-- Obsługiwane dyscypliny:
-- lub:
--   - koszykówka
--
--   - piłka nożna
-- {{#invoke:Rekordy_sezon|main
--  |sezon=2026/2027
--  |druzyna=Enea Basket Poznań
--  |dyscyplina=koszykówka
-- }}
--
--
-- =========================================================
-- =========================================================
Linia 24: Linia 28:
-- FUNKCJE WSPÓLNE
-- FUNKCJE WSPÓLNE
-- =========================================================
-- =========================================================
local function escapeSQL(value)
    value = value or ""
    return mw.ustring.gsub(
        tostring(value),
        "'",
        "''"
    )
end


local function liczba(value)
local function liczba(value)
Linia 57: Linia 48:




-- =========================================================
local function escapeSQL(value)
-- WYNIK MECZU
--
-- WAŻNE:
-- funkcja jest lokalna i dostępna dla całego modułu.
-- =========================================================


local function wynikMeczu(row)
    value = tostring(value or "")


     local g1 = tonumber(
     return mw.ustring.gsub(
         row.gole1 or ""
         value,
        "'",
        "''"
     )
     )


    local g2 = tonumber(
end
        row.gole2 or ""
    )


    if g1 and g2 then
        return g1, g2
    end


-- =========================================================
-- ROZPOZNANIE MIEJSCA MECZU
-- =========================================================


    local wynik =
local function miejsceMeczu(row, druzyna)
        row.wynik or ""


    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
-- =========================================================
-- WYNIK MECZU
-- =========================================================
local function wynikMeczu(row)
    local g1 =
        tonumber(row.gole1 or "")
    local g2 =
        tonumber(row.gole2 or "")
    if g1 ~= nil and g2 ~= nil then
        return g1, g2
    end
    local wynik =
        tostring(row.wynik or "")


     local a, b =
     local a, b =
         wynik:match(
         mw.ustring.match(
            wynik,
             "(%d+)%s*:%s*(%d+)"
             "(%d+)%s*:%s*(%d+)"
         )
         )


     if a and b then
     if a and b then
Linia 104: Linia 127:


-- =========================================================
-- =========================================================
-- MIEJSCE MECZU
-- WYNIK Z PERSPEKTYWY DRUŻYNY
-- =========================================================
-- =========================================================


local function miejsceMeczu(
local function wynikZPerspektywy(row, druzyna)
     row,
 
     druzyna
     local g1, g2 =
)
        wynikMeczu(row)
 
    if g1 == nil or g2 == nil then
        return nil, nil
     end


     local d1 =
     local miejsce =
         row.druzyna1 or ""
         miejsceMeczu(
            row,
            druzyna
        )


     local d2 =
     if miejsce == "dom" then
        row.druzyna2 or ""


        return g1, g2


     if d1 == druzyna then
     elseif miejsce == "wyjazd" then
        return "dom"
    end


        return g2, g1


    if d2 == druzyna then
        return "wyjazd"
     end
     end


 
     return nil, nil
     return nil


end
end
Linia 141: Linia 167:


     local d1 =
     local d1 =
         row.druzyna1 or ""
         tostring(row.druzyna1 or "")


     local d2 =
     local d2 =
         row.druzyna2 or ""
         tostring(row.druzyna2 or "")
 
    local strona =
        tostring(row.strona_meczu or "")


     local tekst =
     local tekst =
         d1 .. " – " .. d2
         d1 ..
 
        " – " ..
 
         d2
    local strona =
         row.strona_meczu or ""




     if strona ~= "" then
     if strona ~= "" then


         return "[[" ..
         return
            "[[" ..
             strona ..
             strona ..
             "|" ..
             "|" ..
Linia 163: Linia 191:


     end
     end


     return tekst
     return tekst
Linia 171: Linia 198:


-- =========================================================
-- =========================================================
-- PARSOWANIE MINUTY GOLA
-- FUNKCJA DODAWANIA REKORDU
--
-- UŻYWANA PRZEZ PIŁKĘ NOŻNĄ
-- Obsługujemy:
--
-- 14
-- 45
-- 45+2
-- 90+4
-- 105
-- 120+1
--
-- Zwracamy:
--  minuta podstawowa
--  doliczony czas
-- =========================================================
-- =========================================================


local function parsujMinute(value)
local function dodajRekord(
 
    tabela,
     if value == nil or value == "" then
    miejsce,
         return nil, 0
    wartosc,
    item
)
 
     if wartosc == nil then
         return
     end
     end


    local lista =
        tabela[miejsce]


     value =
     if #lista == 0 then
        tostring(value)


        table.insert(
            lista,
            item
        )


    value =
         return
         mw.ustring.gsub(
            value,
            "%s+",
            ""
        )


    end


    local minuta,
          doliczona =
        value:match(
            "^(%d+)%+(%d+)$"
        )


    local obecna =
        lista[1].wartosc


    if minuta then


        return
    if wartosc > obecna then
            tonumber(minuta),
            tonumber(doliczona)


    end
        tabela[miejsce] = {
            item
        }


    elseif wartosc == obecna then


    minuta =
         table.insert(
         value:match(
             lista,
             "^(%d+)"
            item
         )
         )


    end


    if minuta then
end
 
        return
            tonumber(minuta),
            0
 
    end
 
 
    return nil, 0
 
end




-- =========================================================
-- =========================================================
-- PRZEDZIAŁ CZASOWY GOLA
-- FORMAT REKORDÓW MECZOWYCH
-- =========================================================
-- =========================================================


local function przedzialGola(value)
local function tekstMeczow(lista)


    local minuta,
     if not lista or #lista == 0 then
          doliczona =
         return "—"
        parsujMinute(value)
 
 
     if not minuta then
         return nil
     end
     end


    local wynik = {}


     -- 45+ oraz 90+ itd.
     for _, item in ipairs(lista) do
    if minuta == 45 and doliczona > 0 then
        return "45+"
    end


        local roznica =
            item.roznica or 0


    if minuta == 90 and doliczona > 0 then
         local roznicaTekst
         return "90+"
    end


        if roznica >= 0 then


    if minuta == 105 and doliczona > 0 then
            roznicaTekst =
        return "105+"
                "+" ..
    end
                tostring(roznica)


        else


    if minuta == 120 and doliczona > 0 then
            roznicaTekst =
        return "120+"
                tostring(roznica)
    end


        end


    if minuta >= 1 and minuta <= 15 then
        return "0–15"
    end


        table.insert(
            wynik,


    if minuta >= 16 and minuta <= 30 then
            item.tekst ..
        return "16–30"
            " (" ..
    end
            item.wynik ..
            ", " ..
            roznicaTekst ..
            ")"


        )


    if minuta >= 31 and minuta <= 45 then
        return "31–45"
     end
     end




     if minuta >= 46 and minuta <= 60 then
     return table.concat(
         return "46–60"
        wynik,
     end
         "<br>"
     )


end


    if minuta >= 61 and minuta <= 75 then
        return "61–75"
    end


-- =========================================================
-- FORMAT REKORDÓW ZAWODNIKÓW
-- =========================================================


     if minuta >= 76 and minuta <= 90 then
local function tekstZawodnikow(
        return "76–90"
     lista,
    end
    typ
)


 
     if not lista or #lista == 0 then
     if minuta >= 91 and minuta <= 105 then
         return ""
         return "91–105"
     end
     end


    local wynik = {}


    if minuta >= 106 and minuta <= 120 then
        return "106–120"
    end


    for _, item in ipairs(lista) do


    if minuta > 120 then
        local zawodnikLink =
        return "120+"
            "[[" ..
    end
            tostring(item.zawodnik or "") ..
            "]]"




    return nil
        local wartosc = ""


end


        if typ == "punkty" then


-- =========================================================
            wartosc =
-- DODANIE REKORDU DO LISTY
                tostring(item.punkty) ..
-- =========================================================
                " pkt"


local function dodajRekord(
    tabela,
    miejsce,
    wartosc,
    item
)


    local lista =
        elseif typ == "minuty" then
        tabela[miejsce]


            wartosc =
                tostring(
                    item.minuty_format or ""
                )


    if not lista then
            if wartosc == "" then


        tabela[miejsce] = {}
                wartosc =
                    tostring(
                        item.minuty or 0
                    )
 
            end


        lista =
            wartosc =