Przejdź do zawartości

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

Z Encyklopedia Poznanskiego Sportu
Nie podano opisu zmian
Nie podano opisu zmian
Linia 5: Linia 5:
--
--
-- Jeden moduł dla różnych dyscyplin.
-- Jeden moduł dla różnych dyscyplin.
--
-- Wywołanie:
--
-- {{#invoke:Rekordy_sezon|main
--  |sezon=2026/2027
--  |druzyna=Lech Poznań
--  |dyscyplina=piłka nożna
-- }}
--
-- lub:
--
-- {{#invoke:Rekordy_sezon|main
--  |sezon=2026/2027
--  |druzyna=Enea Basket Poznań
--  |dyscyplina=koszykówka
-- }}
-- =========================================================
-- =========================================================


Linia 47: Linia 31:




-- =========================================================
local function escapeSQL(value)
-- MINUTY
--
-- Obsługuje:
-- 32
-- 32.0
-- 32:15
-- 32:15.5
--
-- Do porównywania rekordów używamy sekund.
-- =========================================================


local function minutyNaSekundy(value)
    value = tostring(value or "")


     if value == nil or value == "" then
     return mw.ustring.gsub(
        return 0
    end
 
    value = tostring(value)
 
    value = mw.ustring.gsub(
         value,
         value,
         "%s+",
         "'",
         ""
         "''"
     )
     )


    local minuty, sekundy =
end
        mw.ustring.match(
            value,
            "^(%d+):(%d+)$"
        )


    if minuty and sekundy then


        return
-- =========================================================
            tonumber(minuty) * 60 +
-- ROZPOZNANIE MIEJSCA MECZU
            tonumber(sekundy)
-- =========================================================


    end
local function miejsceMeczu(row, druzyna)


     local liczbaMinut =
     local d1 =
         tonumber(value)
         tostring(row.druzyna1 or "")
 
    local d2 =
        tostring(row.druzyna2 or "")
 
    if d1 == druzyna then
        return "dom"
    end


     if liczbaMinut then
     if d2 == druzyna then
         return liczbaMinut * 60
         return "wyjazd"
     end
     end


     return 0
     return nil


end
end
Linia 100: Linia 70:


-- =========================================================
-- =========================================================
-- FORMAT MINUT
-- WYNIK MECZU
-- =========================================================
-- =========================================================


local function formatMinut(sekundy)
local function wynikMeczu(row)


     sekundy = tonumber(sekundy) or 0
     local g1 =
        tonumber(row.gole1 or "")


     local minuty =
     local g2 =
         math.floor(
         tonumber(row.gole2 or "")
            sekundy / 60
        )


    local sek =
     if g1 ~= nil and g2 ~= nil then
        sekundy % 60
         return g1, g2
 
     if sek == 0 then
         return tostring(minuty) .. " min"
     end
     end


    return
        tostring(minuty) ..
        ":" ..
        string.format(
            "%02d",
            sek
        ) ..
        " min"


end
    local wynik =
        tostring(row.wynik or "")


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


local function escapeSQL(value)
    if a and b then
 
        return
            tonumber(a),
            tonumber(b)
 
    end


    value = tostring(value or "")


     return mw.ustring.gsub(
     return nil, nil
        value,
        "'",
        "''"
    )


end
end
Linia 145: Linia 110:


-- =========================================================
-- =========================================================
-- ROZPOZNANIE MIEJSCA MECZU
-- WYNIK Z PERSPEKTYWY DRUŻYNY
-- =========================================================
-- =========================================================


local function miejsceMeczu(row, druzyna)
local function wynikZPerspektywy(row, druzyna)


     local d1 =
     local g1, g2 =
         tostring(row.druzyna1 or "")
         wynikMeczu(row)


     local d2 =
     if g1 == nil or g2 == nil then
        tostring(row.druzyna2 or "")
         return nil, nil
 
    if d1 == druzyna then
         return "dom"
     end
     end


     if d2 == druzyna then
    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 170: Linia 144:


-- =========================================================
-- =========================================================
-- WYNIK MECZU
-- NAZWA MECZU
-- =========================================================
-- =========================================================


local function wynikMeczu(row)
local function nazwaMeczu(row)


     local g1 =
     local d1 =
         tonumber(row.gole1 or "")
         tostring(row.druzyna1 or "")


     local g2 =
     local d2 =
         tonumber(row.gole2 or "")
         tostring(row.druzyna2 or "")


     if g1 ~= nil and g2 ~= nil then
     local strona =
         return g1, g2
         tostring(row.strona_meczu or "")
    end


    local tekst =
        d1 ..
        " – " ..
        d2


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


     if a and b then
     if strona ~= "" then


         return
         return
             tonumber(a),
             "[[" ..
             tonumber(b)
             strona ..
            "|" ..
            tekst ..
            "]]"


     end
     end


 
     return tekst
     return nil, nil


end
end
Linia 210: Linia 181:


-- =========================================================
-- =========================================================
-- WYNIK Z PERSPEKTYWY DRUŻYNY
-- FUNKCJA DODAWANIA REKORDU
--
-- WAŻNE:
-- item.wartosc MUSI być zapisana w elemencie.
-- Dzięki temu kolejne rekordy są porównywane
-- z rzeczywistą wartością danego rekordu.
-- =========================================================
-- =========================================================


local function wynikZPerspektywy(row, druzyna)
local function dodajRekord(
    tabela,
    miejsce,
    wartosc,
    item
)


     local g1, g2 =
     if wartosc == nil then
         wynikMeczu(row)
         return
    end


     if g1 == nil or g2 == nil then
     local lista =
         return nil, nil
         tabela[miejsce]
    end


     local miejsce =
     -- KLUCZOWA POPRAWKA
        miejsceMeczu(
    item.wartosc = wartosc
            row,
            druzyna
        )


    if miejsce == "dom" then


        return g1, g2
    if #lista == 0 then


    elseif miejsce == "wyjazd" then
        table.insert(
            lista,
            item
        )


         return g2, g1
         return


     end
     end


    return nil, nil


end
    local obecna =
        lista[1].wartosc




-- =========================================================
    if obecna == nil then
-- NAZWA MECZU
        obecna = 0
-- =========================================================
    end


local function nazwaMeczu(row)


     local d1 =
     if wartosc > obecna then
        tostring(row.druzyna1 or "")


    local d2 =
        tabela[miejsce] = {
         tostring(row.druzyna2 or "")
            item
         }


     local strona =
     elseif wartosc == obecna then
        tostring(row.strona_meczu or "")


    local tekst =
         table.insert(
        d1 ..
             lista,
        " – " ..
             item
        d2
        )
 
 
    if strona ~= "" then
 
         return
            "[[" ..
            strona ..
             "|" ..
             tekst ..
            "]]"


     end
     end
    return tekst


end
end
Linia 281: Linia 247:


-- =========================================================
-- =========================================================
-- DODAWANIE REKORDU
-- FORMAT REKORDÓW MECZOWYCH
--
-- KLUCZOWA POPRAWKA:
--
-- zapisujemy wartość rekordu bezpośrednio w item.wartosc.
--
-- Dzięki temu nie ma już:
-- attempt to compare nil with number
-- =========================================================
-- =========================================================


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


     if wartosc == nil then
     if not lista or #lista == 0 then
         return
         return "—"
     end
     end


     wartosc =
     local wynik = {}
        tonumber(wartosc)


     if wartosc == nil then
     for _, item in ipairs(lista) do
        return
    end


    item.wartosc =
        local roznica =
        wartosc
            item.roznica or 0


    local lista =
        local roznicaTekst
        tabela[miejsce]


    if #lista == 0 then


         table.insert(
         if roznica >= 0 then
            lista,
            item
        )


        return
            roznicaTekst =
                "+" ..
                tostring(roznica)


    end
        else


            roznicaTekst =
                tostring(roznica)


    local obecna =
         end
         tonumber(
            lista[1].wartosc
        ) or 0




    if wartosc > obecna then
        table.insert(
            wynik,


        tabela[miejsce] = {
            item.tekst ..
             item
            " (" ..
        }
             item.wynik ..
 
            ", " ..
    elseif wartosc == obecna then
            roznicaTekst ..
            ")"


        table.insert(
            lista,
            item
         )
         )


     end
     end
    return table.concat(
        wynik,
        "<br>"
    )


end
end
Linia 352: Linia 304:


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