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 2 pośrednich wersji utworzonych przez tego samego użytkownika)
Linia 21: Linia 21:
--  |dyscyplina=koszykówka
--  |dyscyplina=koszykówka
-- }}
-- }}
--
-- =========================================================
-- =========================================================


Linia 47: Linia 48:




-- =========================================================
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 =
        mw.ustring.match(
            value,
            "^(%d+):(%d+)$"
        )
    if minuty and sekundy then
        return
            tonumber(minuty) * 60 +
            tonumber(sekundy)
    end
    local liczbaMinut =
        tonumber(value)
    if liczbaMinut then
        return liczbaMinut * 60
    end
    return 0


end
end
Linia 100: Linia 62:


-- =========================================================
-- =========================================================
-- FORMAT MINUT
-- ROZPOZNANIE MIEJSCA MECZU
-- =========================================================
-- =========================================================


local function formatMinut(sekundy)
local function miejsceMeczu(row, druzyna)


    sekundy = tonumber(sekundy) or 0
     local d1 =
 
    local minuty =
        math.floor(
            sekundy / 60
        )
 
    local sek =
        sekundy % 60
 
    if sek == 0 then
        return tostring(minuty) .. " min"
    end
 
    return
        tostring(minuty) ..
        ":" ..
        string.format(
            "%02d",
            sek
        ) ..
        " min"
 
end
 
 
local function escapeSQL(value)
 
    value = tostring(value or "")
 
    return mw.ustring.gsub(
        value,
        "'",
        "''"
    )
 
end
 
 
-- =========================================================
-- ROZPOZNANIE MIEJSCA MECZU
-- =========================================================
 
local function miejsceMeczu(row, druzyna)
 
     local d1 =
         tostring(row.druzyna1 or "")
         tostring(row.druzyna1 or "")


Linia 281: Linia 198:


-- =========================================================
-- =========================================================
-- DODAWANIE REKORDU
-- FUNKCJA DODAWANIA REKORDU
--
-- UŻYWANA PRZEZ PIŁKĘ NOŻNĄ
-- KLUCZOWA POPRAWKA:
--
-- zapisujemy wartość rekordu bezpośrednio w item.wartosc.
--
-- Dzięki temu nie ma już:
-- attempt to compare nil with number
-- =========================================================
-- =========================================================


Linia 302: Linia 213:
     end
     end


    wartosc =
     local lista =
        tonumber(wartosc)
 
    if wartosc == nil then
        return
    end
 
    item.wartosc =
        wartosc
 
     local lista =
         tabela[miejsce]
         tabela[miejsce]


Linia 328: Linia 229:


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




Linia 366: Linia 265:


         local roznica =
         local roznica =
             tonumber(
             item.roznica or 0
                item.roznica or 0
            ) or 0


         local roznicaTekst
         local roznicaTekst
Linia 426: Linia 323:


     for _, item in ipairs(lista) do
     for _, item in ipairs(lista) do
        local zawodnik =
            tostring(
                item.zawodnik or ""
            )


         local zawodnikLink =
         local zawodnikLink =
             "[[" ..
             "[[" ..
             zawodnik ..
             tostring(item.zawodnik or "") ..
             "]]"
             "]]"


Linia 444: Linia 336:


             wartosc =
             wartosc =
                 tostring(
                 tostring(item.punkty) ..
                    item.punkty or 0
                ) ..
                 " pkt"
                 " pkt"


Linia 452: Linia 342:
         elseif typ == "minuty" then
         elseif typ == "minuty" then


             if item.minuty_format
             wartosc =
                 and item.minuty_format ~= "" then
                tostring(
                    item.minuty_format or ""
                 )
 
            if wartosc == "" then


                 wartosc =
                 wartosc =
                     tostring(
                     tostring(
                         item.minuty_format
                         item.minuty or 0
                    )
 
            else
 
                wartosc =
                    formatMinut(
                        item.minuty_sekundy or 0
                     )
                     )


Linia 472: Linia 359:
                 wartosc ..
                 wartosc ..
                 " min"
                 " min"


         elseif typ == "asysty" then
         elseif typ == "asysty" then


             wartosc =
             wartosc =
                 tostring(
                 tostring(item.asysty) ..
                    item.asysty or 0
                ) ..
                 " as."
                 " as."


Linia 485: Linia 371:


             wartosc =
             wartosc =
                 tostring(
                 tostring(item.zbiorki) ..
                    item.zbiorki or 0
                ) ..
                 " zb."
                 " zb."


Linia 494: Linia 378:


             wartosc =
             wartosc =
                 tostring(
                 tostring(item.eval) ..
                    item.eval or 0
                ) ..
                 " EVAL"
                 " EVAL"


Linia 503: Linia 385:


             local pm =
             local pm =
                 tonumber(
                 item.plusminus or 0
                    item.plusminus or 0
                ) or 0


             if pm >= 0 then
             if pm >= 0 then
Linia 534: Linia 414:
             wartosc ..
             wartosc ..
             "<br>" ..
             "<br>" ..
             tostring(
             tostring(item.tekst or "") ..
                item.tekst or ""
            ) ..
             " (" ..
             " (" ..
             tostring(
             tostring(item.wynik or "") ..
                item.wynik or ""
            ) ..
             ")"
             ")"


Linia 695: Linia 571:


                 roznica =
                 roznica =
                    roznica,
                wartosc =
                     roznica,
                     roznica,


Linia 701: Linia 580:


                 wynik =
                 wynik =
                     tostring(
                     tostring(zdobyte) ..
                        zdobyte
                    ) ..
                     ":" ..
                     ":" ..
                     tostring(
                     tostring(stracone)
                        stracone
                    )


             }
             }


            -- ZWYCIĘSTWO


             if roznica > 0 then
             if roznica > 0 then
Linia 723: Linia 600:
             end
             end


            -- PORAŻKA


             if roznica < 0 then
             if roznica < 0 then
                item.wartosc =
                    math.abs(roznica)


                 item.przegrana =
                 item.przegrana =
                     math.abs(
                     math.abs(roznica)
                         roznica
 
 
                local lista =
                    najwyzszaPorazka[miejsce]
 
 
                if #lista == 0 then
 
                    table.insert(
                        lista,
                         item
                     )
                     )


                else
                    local obecna =
                        lista[1].przegrana


                dodajRekord(
 
                     najwyzszaPorazka,
                     if item.przegrana > obecna then
                    miejsce,
 
                     item.przegrana,
                        najwyzszaPorazka[miejsce] = {
                     item
                            item
                 )
                        }
 
                     elseif item.przegrana == obecna then
 
                        table.insert(
                            lista,
                            item
                        )
 
                     end
 
                 end


             end
             end
Linia 805: Linia 712:


     -- =====================================================
     -- =====================================================
     -- STRUKTURA REKORDÓW
     -- REKORDY INDYWIDUALNE
    -- KAŻDA STATYSTYKA MA WŁASNY REKORD
     -- =====================================================
     -- =====================================================


Linia 844: Linia 752:


     -- =====================================================
     -- =====================================================
     -- PRZETWARZANIE ZAWODNIKÓW
     -- DODAWANIE REKORDU KOSZYKARSKIEGO
     -- =====================================================
     -- =====================================================


     if zawodnicy then
     local function dodajRekordKoszykarski(
        tabela,
        miejsce,
        wartosc,
        item
    )


         for _, row in ipairs(zawodnicy) do
         if wartosc == nil then
            return
        end


            local miejsce =
                miejsceMeczu(
                    row,
                    druzyna
                )


        local lista =
            tabela[miejsce]


            if miejsce then


                -- -----------------------------------------
        if not lista then
                -- MINUTY
            return
                -- -----------------------------------------
        end


                local minutySekundy =
                    minutyNaSekundy(
                        row.minuty_format
                    )


                if minutySekundy == 0 then
        if #lista == 0 then


                     minutySekundy =
            table.insert(
                        minutyNaSekundy(
                lista,
                            row.minuty
                {
                        )
                     zawodnik = item.zawodnik,
                    mecz = item.mecz,
                    data = item.data,
                    miejsce = item.miejsce,
                    tekst = item.tekst,
                    wynik = item.wynik,
                    wartosc = wartosc,
                    minuty_format = item.minuty_format,
                    punkty = item.punkty,
                    minuty = item.minuty,
                    asysty = item.asysty,
                    zbiorki = item.zbiorki,
                    eval = item.eval,
                    plusminus = item.plusminus
                }
            )


                end
            return


        end


                -- -----------------------------------------
                -- POZOSTAŁE STATYSTYKI
                -- -----------------------------------------


                local punkty =
        local obecna =
                    liczba(row.gol)
            lista[1].wartosc


                local asysty =
                    liczba(row.asysta)


                local zbiorki =
        if wartosc > obecna then
                    liczba(row.zbiorka)


                local eval =
            tabela[miejsce] = {
                    liczba(row.eval)


                 local plusminus =
                 {
                     liczba(row.plusminus)
                    zawodnik = item.zawodnik,
                    mecz = item.mecz,
                    data = item.data,
                    miejsce = item.miejsce,