Lompat ke isi

Modul:MatchSystem: Perbedaan antara revisi

Dari Wikisporta, ensiklopedia olahraga
←Membuat halaman berisi 'local p = {} -- 1. FUNGSI UNTUK DAFTAR LAGA (HASIL & JADWAL MENDATANG) function p.row(frame) local args = frame:getParent().args local date = args.tanggal or args[1] or "" local comp = args.kompetisi or args[2] or "" local home = args.tuan_rumah or args[3] or "" local scoreOrTime = args.skor_atau_waktu or args[4] or "vs" local away = args.tamu or args[5] or "" local resultType = string.lower(args.hasil or args[6] or "") loca...'
Tanda: Suntingan perangkat seluler Suntingan peramban seluler
 
k Melindungi "Modul:MatchSystem" ([Sunting=Hanya untuk pengurus] (selamanya) [Pindahkan=Hanya untuk pengurus] (selamanya))
Tanda: Suntingan perangkat seluler Suntingan peramban seluler
 
(Tidak ada perbedaan)

Revisi terkini sejak 17 Oktober 2026 22.11

Dokumentasi untuk modul ini dapat dibuat di Modul:MatchSystem/doc

local p = {}

-- 1. FUNGSI UNTUK DAFTAR LAGA (HASIL & JADWAL MENDATANG)
function p.row(frame)
    local args = frame:getParent().args
    
    local date = args.tanggal or args[1] or ""
    local comp = args.kompetisi or args[2] or ""
    local home = args.tuan_rumah or args[3] or ""
    local scoreOrTime = args.skor_atau_waktu or args[4] or "vs"
    local away = args.tamu or args[5] or ""
    local resultType = string.lower(args.hasil or args[6] or "")

    local badgeStyle = "background: #3b82f6; color: #ffffff;"
    local badgeText = "VS"

    if resultType == "w" or resultType == "win" or resultType == "menang" or resultType == "m" then
        badgeStyle = "background: #22c55e; color: #ffffff;"
        badgeText = "M"
    elseif resultType == "l" or resultType == "loss" or resultType == "kalah" or resultType == "k" then
        badgeStyle = "background: #ef4444; color: #ffffff;"
        badgeText = "K"
    elseif resultType == "d" or resultType == "draw" or resultType == "seri" or resultType == "s" then
        badgeStyle = "background: #64748b; color: #ffffff;"
        badgeText = "S"
    end

    return string.format([[
<tr style="border-bottom: 1px solid #f1f5f9; font-size: 75%%; text-align: center;">
    <td style="padding: 4px 2px; color: #64748b; font-size: 90%%; width: 18%%;">%s</td>
    <td style="padding: 4px 2px; font-weight: 600; color: #1e293b; width: 30%%; text-align: right;">%s</td>
    <td style="padding: 4px 2px; width: 22%%;">
        <span style="font-weight: 800; color: #0f172a; display: inline-block; padding: 1px 4px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 4px;">%s</span>
    </td>
    <td style="padding: 4px 2px; font-weight: 600; color: #1e293b; width: 30%%; text-align: left;">%s</td>
    <td style="padding: 4px 2px; width: 10%%;">
        <span style="%s padding: 1px 4px; border-radius: 3px; font-weight: 800; font-size: 80%%;">%s</span>
    </td>
</tr>]], date, home, scoreOrTime, away, badgeStyle, badgeText)
end

function p.container(frame)
    local args = frame:getParent().args
    local title = args.judul or args.title or "Jadwal & Hasil Pertandingan"
    local content = args.content or args[1] or ""

    return string.format([[
<div style="border: 1px solid #cbd5e1; border-radius: 8px; background: #ffffff; overflow: hidden; margin: 6px 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;">
    <div style="background: #0f172a; color: #f8fafc; padding: 5px 8px; font-size: 80%%; font-weight: 700; text-align: center; letter-spacing: 0.5px;">
        %s
    </div>
    <table style="width: 100%%; border-collapse: collapse; background: transparent;">
        %s
    </table>
</div>]], title, content)
end

-- 2. FUNGSI UNTUK LAPORAN DETAIL MATCH (MATCH CENTER EKSLUSIF)
function p.detail(frame)
    local args = frame:getParent().args
    
    local derby = args.laga_spesial or args.derby or ""
    local comp = args.kompetisi or args.competition or ""
    local phase = args.fase or args.babak or ""
    local date = args.tanggal or args.date or ""
    
    local venue = args.stadion or args.venue or ""
    local referee = args.wasit or args.referee or ""
    local attendance = args.penonton or args.attendance or ""
    local weather = args.cuaca or args.weather or ""
    
    local homeTeam = args.tuan_rumah or args.home or "Tuan Rumah"
    local awayTeam = args.tamu or args.away or "Tamu"
    local homeScore = args.skor_home or args.home_score or "0"
    local awayScore = args.skor_away or args.away_score or "0"
    local status = args.status or "FT"
    local aggregate = args.agregat or args.aggregate or ""

    local homeGoals = args.gol_home or args.home_goals or ""
    local awayGoals = args.gol_away or args.away_goals or ""

    -- Statistik Komplit
    local homeXG = args.xg_home or ""
    local awayXG = args.xg_away or ""
    local homePoss = args.possession_home or ""
    local awayPoss = args.possession_away or ""
    local homeShotsTotal = args.shots_total_home or ""
    local awayShotsTotal = args.shots_total_away or ""
    local homeShotsOn = args.shots_on_home or ""
    local awayShotsOn = args.shots_on_away or ""
    local homeShotsOff = args.shots_off_home or ""
    local awayShotsOff = args.shots_off_away or ""
    local homeShotsBlocked = args.shots_blocked_home or ""
    local awayShotsBlocked = args.shots_blocked_away or ""
    local homePasses = args.passes_home or ""
    local awayPasses = args.passes_away or ""
    local homePassAcc = args.pass_acc_home or ""
    local awayPassAcc = args.pass_acc_away or ""
    local homeCorners = args.corners_home or ""
    local awayCorners = args.corners_away or ""
    local homeOffsides = args.offsides_home or ""
    local awayOffsides = args.offsides_away or ""
    local homeSaves = args.saves_home or ""
    local awaySaves = args.saves_away or ""
    local homeFouls = args.fouls_home or ""
    local awayFouls = args.fouls_away or ""
    local homeTackles = args.tackles_home or ""
    local awayTackles = args.tackles_away or ""
    local homeThrowIns = args.throwins_home or ""
    local awayThrowIns = args.throwins_away or ""
    
    local homeYellow = args.kartu_kuning_home or args.yellow_home or ""
    local awayYellow = args.kartu_kuning_away or args.yellow_away or ""
    local homeRed = args.kartu_merah_home or args.red_home or ""
    local awayRed = args.kartu_merah_away or args.red_away or ""

    local hScoreNum = tonumber(homeScore) or 0
    local aScoreNum = tonumber(awayScore) or 0
    local statusBg = "#6c757d"
    if hScoreNum > aScoreNum then
        statusBg = "#16a34a"
    elseif hScoreNum < aScoreNum then
        statusBg = "#dc2626"
    end

    local html = {}
    table.insert(html, '<div style="border: 1px solid #cbd5e1; border-radius: 10px; background: #ffffff; overflow: hidden; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, sans-serif; margin: 8px 0; box-shadow: 0 2px 6px rgba(0,0,0,0.08);">')
    
    if derby ~= "" then
        table.insert(html, string.format('<div style="background: linear-gradient(135deg, #0f172a 0%%, #1e1b4b 50%%, #312e81 100%%); color: #fbbf24; padding: 6px 8px; font-size: 85%%; text-align: center; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; border-bottom: 2px solid #fbbf24;">🏆 %s 🏆</div>', derby))
    end

    if comp ~= "" or date ~= "" or phase ~= "" then
        local headerText = comp
        if phase ~= "" then headerText = (headerText ~= "" and (headerText .. " • ") or "") .. phase end
        if date ~= "" then headerText = (headerText ~= "" and (headerText .. " • ") or "") .. date end
        table.insert(html, string.format('<div style="background: #1e293b; color: #cbd5e1; padding: 4px 8px; font-size: 78%%; text-align: center; font-weight: 600;">%s</div>', headerText))
    end

    table.insert(html, '<table style="width: 100%%; border-collapse: collapse; text-align: center; margin: 10px 0; background: transparent;">')
    table.insert(html, string.format([[
        <tr>
            <td style="width: 38%%; font-weight: 800; font-size: 92%%; color: #0f172a; padding: 2px 6px; vertical-align: middle;">%s</td>
            <td style="width: 24%%; padding: 2px; vertical-align: middle;">
                <span style="background: %s; color: #ffffff; padding: 4px 10px; border-radius: 6px; font-weight: 900; font-size: 125%%; display: inline-block; letter-spacing: 1.5px; box-shadow: 0 2px 4px rgba(0,0,0,0.15);">%s - %s</span>
                <div style="font-size: 70%%; color: #64748b; margin-top: 4px; font-weight: 800; text-transform: uppercase;">%s</div>
                %s
            </td>
            <td style="width: 38%%; font-weight: 800; font-size: 92%%; color: #0f172a; padding: 2px 6px; vertical-align: middle;">%s</td>
        </tr>
    ]], homeTeam, statusBg, homeScore, awayScore, status, (aggregate ~= "" and string.format('<div style="font-size: 68%%; color: #475569; margin-top: 2px;">(Agg: %s)</div>', aggregate) or ""), awayTeam))
    
    if homeGoals ~= "" or awayGoals ~= "" then
        table.insert(html, string.format([[
            <tr style="font-size: 75%%; color: #334155; vertical-align: top;">
                <td style="padding: 4px 6px; text-align: right; line-height: 1.4;">%s</td>
                <td style="padding: 4px 0; font-size: 85%%;">⚽</td>
                <td style="padding: 4px 6px; text-align: left; line-height: 1.4;">%s</td>
            </tr>
        ]], homeGoals, awayGoals))
    end
    table.insert(html, '</table>')

    local function makeStatRow(label, hVal, aVal, isBold)
        if hVal ~= "" or aVal ~= "" then
            local weight = isBold and "800" or "700"
            return string.format(
                '<div style="display: flex; justify-content: space-between; align-items: center; padding: 3px 0; border-bottom: 1px solid #f1f5f9;">' ..
                '<span style="font-weight: %s; width: 30%%; text-align: right; color: #0f172a;">%s</span>' ..
                '<span style="color: #64748b; width: 40%%; text-align: center; font-size: 88%%;">%s</span>' ..
                '<span style="font-weight: %s; width: 30%%; text-align: left; color: #0f172a;">%s</span>' ..
                '</div>', 
                weight, hVal ~= "" and hVal or "0", label, weight, aVal ~= "" and aVal or "0"
            )
        end
        return ""
    end

    local function formatCards(yellow, red)
        local parts = {}
        if yellow ~= "" and yellow ~= "0" then
            table.insert(parts, string.format('%s <span style="background: #eab308; color: #fff; padding: 1px 4px; border-radius: 3px; font-size: 75%%; font-weight: bold;">K</span>', yellow))
        end
        if red ~= "" and red ~= "0" then
            table.insert(parts, string.format('%s <span style="background: #ef4444; color: #fff; padding: 1px 4px; border-radius: 3px; font-size: 75%%; font-weight: bold;">M</span>', red))
        end
        if #parts == 0 then return "" end
        return table.concat(parts, " &nbsp;")
    end

    local homeCardsFormatted = formatCards(homeYellow, homeRed)
    local awayCardsFormatted = formatCards(awayYellow, awayRed)

    local hasStats = homePoss ~= "" or homeShotsOn ~= "" or homeXG ~= "" or homeCorners ~= "" or homeFouls ~= "" or homeCardsFormatted ~= "" or homePasses ~= ""
    
    if hasStats then
        table.insert(html, '<div style="border-top: 1px solid #e2e8f0; padding: 6px 10px; font-size: 75%%; background: #f8fafc;">')
        table.insert(html, '<div style="text-align: center; font-weight: 800; color: #334155; margin-bottom: 6px; font-size: 82%%; letter-spacing: 0.5px; text-transform: uppercase;">STATISTIK PERTANDINGAN</div>')
        
        table.insert(html, makeStatRow("Ekspektasi Gol (xG)", homeXG, awayXG, true))
        table.insert(html, makeStatRow("Penguasaan Bola", homePoss, awayPoss, true))
        table.insert(html, makeStatRow("Total Tembakan", homeShotsTotal, awayShotsTotal))
        table.insert(html, makeStatRow("Tembakan Akurat", homeShotsOn, awayShotsOn, true))
        table.insert(html, makeStatRow("Tembakan Meleset", homeShotsOff, awayShotsOff))
        table.insert(html, makeStatRow("Tembakan Diblok", homeShotsBlocked, awayShotsBlocked))
        table.insert(html, makeStatRow("Total Operan", homePasses, awayPasses))
        table.insert(html, makeStatRow("Akurasi Operan", homePassAcc, awayPassAcc))
        table.insert(html, makeStatRow("Tendangan Sudut", homeCorners, awayCorners))
        table.insert(html, makeStatRow("Offside", homeOffsides, awayOffsides))
        table.insert(html, makeStatRow("Penyelamatan Kiper", homeSaves, awaySaves))
        table.insert(html, makeStatRow("Tekel Berhasil", homeTackles, awayTackles))
        table.insert(html, makeStatRow("Lemparan Dalam", homeThrowIns, awayThrowIns))
        table.insert(html, makeStatRow("Pelanggaran", homeFouls, awayFouls))
        table.insert(html, makeStatRow("Kartu Disiplin", homeCardsFormatted, awayCardsFormatted, true))
        
        table.insert(html, '</div>')
    end

    if venue ~= "" or referee ~= "" or attendance ~= "" or weather ~= "" then
        table.insert(html, '<div style="border-top: 1px solid #e2e8f0; padding: 6px 8px; font-size: 70%%; color: #64748b; background: #ffffff; text-align: center; line-height: 1.5;">')
        local details = {}
        if venue ~= "" then table.insert(details, "<b>Stadion:</b> " .." " .. venue) end
        if referee ~= "" then table.insert(details, "<b>Wasit:</b> " .. referee) end
        if attendance ~= "" then table.insert(details, "<b>Penonton:</b> " .. attendance) end
        if weather ~= "" then table.insert(details, "<b>Cuaca:</b> " .. weather) end
        table.insert(html, table.concat(details, " | "))
        table.insert(html, '</div>')
    end

    table.insert(html, '</div>')
    return table.concat(html, "")
end

return p