Modul:PlayerStats
Tampilan
Dokumentasi untuk modul ini dapat dibuat di Modul:PlayerStats/doc
local p = {}
-- ============================================================================
-- 1. FUNGSI HIGHLIGHT PERFORMA LAGA TERAKHIR PEMAIN (Match Performance)
-- ============================================================================
function p.match(frame)
local args = frame:getParent().args
local playerName = args.pemain or args.player or "Pemain"
local matchName = args.pertandingan or args.match or ""
local date = args.tanggal or args.date or ""
local rating = args.rating or ""
local minutes = args.menit or args.minutes or "90'"
-- Serang & Kreativitas
local goals = args.gol or args.goals or "0"
local assists = args.assist or "0"
local shotsOn = args.shots_on or ""
local xG = args.xg or ""
local xA = args.xa or ""
local keyPasses = args.operan_kunci or args.key_passes or ""
local dribbles = args.dribel or args.dribbles or "" -- contoh: 4/5
local touchesBox = args.sentuhan_kotak or ""
-- Pertahanan & Disiplin
local tackles = args.tekel or args.tackles or ""
local duels = args.duel or "" -- contoh: 8/10
local fouls = args.pelanggaran or args.fouls or ""
local yellow = args.kartu_kuning or args.yellow or ""
local red = args.kartu_merah or args.red or ""
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);">')
-- Header Match
local headerText = "PERFORMA LAGA TERAKHIR"
if matchName ~= "" then
headerText = headerText .. " • " .. matchName
end
if date ~= "" then
headerText = headerText .. " (" .. date .. ")"
end
table.insert(html, string.format('<div style="background: #0f172a; color: #fbbf24; padding: 6px 10px; font-size: 80%%; font-weight: 800; text-align: center; letter-spacing: 0.5px; text-transform: uppercase;">%s</div>', headerText))
-- Main Stats Bar (Rating, Menit, Gol, Assist)
local ratingBg = "#22c55e" -- Green default
local rNum = tonumber(rating) or 0
if rNum < 6.5 and rNum > 0 then
ratingBg = "#ef4444"
elseif rNum < 7.5 and rNum >= 6.5 then
ratingBg = "#3b82f6"
elseif rNum >= 8.5 then
ratingBg = "#8b5cf6" -- Purple / Exceptional
end
table.insert(html, '<div style="display: flex; justify-content: space-around; align-items: center; padding: 8px 4px; background: #f8fafc; border-bottom: 1px solid #e2e8f0; text-align: center;">')
if rating ~= "" then
table.insert(html, string.format('<div><div style="font-size: 68%%; color: #64748b; font-weight: 700;">RATING</div><span style="background: %s; color: #fff; padding: 2px 6px; border-radius: 4px; font-weight: 900; font-size: 110%%;">%s</span></div>', ratingBg, rating))
end
table.insert(html, string.format('<div><div style="font-size: 68%%; color: #64748b; font-weight: 700;">MENIT</div><span style="font-weight: 800; color: #0f172a; font-size: 100%%;">%s</span></div>', minutes))
table.insert(html, string.format('<div><div style="font-size: 68%%; color: #64748b; font-weight: 700;">GOL</div><span style="font-weight: 900; color: #16a34a; font-size: 110%%;">⚽ %s</span></div>', goals))
table.insert(html, string.format('<div><div style="font-size: 68%%; color: #64748b; font-weight: 700;">ASSIST</div><span style="font-weight: 900; color: #2563eb; font-size: 110%%;">🅰️ %s</span></div>', assists))
table.insert(html, '</div>')
-- Helper Baris Statistik
local function makeStatRow(label, val)
if val ~= "" then
return string.format(
'<div style="display: flex; justify-content: space-between; align-items: center; padding: 3px 6px; border-bottom: 1px solid #f1f5f9;">' ..
'<span style="color: #64748b; font-size: 85%%;">%s</span>' ..
'<span style="font-weight: 800; color: #0f172a; font-size: 88%%;">%s</span>' ..
'</div>', label, val
)
end
return ""
end
-- Detail Rincian
table.insert(html, '<div style="padding: 4px 8px; font-size: 78%%;">')
table.insert(html, makeStatRow("Ekspektasi Gol (xG)", xG))
table.insert(html, makeStatRow("Ekspektasi Assist (xA)", xA))
table.insert(html, makeStatRow("Tembakan Akurat", shotsOn))
table.insert(html, makeStatRow("Operan Kunci", keyPasses))
table.insert(html, makeStatRow("Dribel Sukses", dribbles))
table.insert(html, makeStatRow("Sentuhan di Kotak Penalti", touchesBox))
table.insert(html, makeStatRow("Tekel Berhasil", tackles))
table.insert(html, makeStatRow("Duel Menang", duels))
if yellow ~= "" or red ~= "" then
local cardsText = ""
if yellow ~= "" and yellow ~= "0" then cardsText = cardsText .. yellow .. " 🟨 " end
if red ~= "" and red ~= "0" then cardsText = cardsText .. red .. " 🟥" end
table.insert(html, makeStatRow("Kartu Disiplin", cardsText))
end
table.insert(html, '</div>')
table.insert(html, '</div>')
return table.concat(html, "")
end
-- ============================================================================
-- 2. FUNGSI REKAP STATISTIK MUSIM BERJALAN PEMAIN (Season Stats)
-- ============================================================================
function p.season(frame)
local args = frame:getParent().args
local season = args.musim or args.season or "2025/2026"
local club = args.klub or args.club or ""
local comp = args.kompetisi or args.competition or "Semua Kompetisi"
local apps = args.tampil or args.apps or "0"
local goals = args.gol or args.goals or "0"
local assists = args.assist or "0"
local motm = args.motm or ""
local xG = args.xg or ""
local xA = args.xa or ""
local avgRating = args.rata_rating or args.avg_rating or ""
local passAcc = args.akurasi_operan or args.pass_acc or ""
local yellow = args.kartu_kuning or args.yellow or ""
local red = args.kartu_merah or args.red or ""
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);">')
local titleText = "STATISTIK MUSIM " .. season
if club ~= "" then titleText = titleText .. " • " .. club end
table.insert(html, string.format('<div style="background: #1e293b; color: #cbd5e1; padding: 6px 10px; font-size: 80%%; font-weight: 800; text-align: center; letter-spacing: 0.5px; text-transform: uppercase;">%s</div>', titleText))
-- Main Grid
table.insert(html, '<div style="display: flex; justify-content: space-around; align-items: center; padding: 8px 4px; background: #f8fafc; border-bottom: 1px solid #e2e8f0; text-align: center;">')
table.insert(html, string.format('<div><div style="font-size: 68%%; color: #64748b; font-weight: 700;">TAMPIL</div><span style="font-weight: 900; color: #0f172a; font-size: 110%%;">%s</span></div>', apps))
table.insert(html, string.format('<div><div style="font-size: 68%%; color: #64748b; font-weight: 700;">GOL</div><span style="font-weight: 900; color: #16a34a; font-size: 110%%;">⚽ %s</span></div>', goals))
table.insert(html, string.format('<div><div style="font-size: 68%%; color: #64748b; font-weight: 700;">ASSIST</div><span style="font-weight: 900; color: #2563eb; font-size: 110%%;">🅰️ %s</span></div>', assists))
if avgRating ~= "" then
table.insert(html, string.format('<div><div style="font-size: 68%%; color: #64748b; font-weight: 700;">RATA2 RATING</div><span style="background: #3b82f6; color: #fff; padding: 2px 5px; border-radius: 4px; font-weight: 800; font-size: 95%%;">%s</span></div>', avgRating))
end
table.insert(html, '</div>')
-- Detail Rincian Musim
local function makeStatRow(label, val)
if val ~= "" then
return string.format(
'<div style="display: flex; justify-content: space-between; align-items: center; padding: 3px 6px; border-bottom: 1px solid #f1f5f9;">' ..
'<span style="color: #64748b; font-size: 85%%;">%s</span>' ..
'<span style="font-weight: 800; color: #0f172a; font-size: 88%%;">%s</span>' ..
'</div>', label, val
)
end
return ""
end
table.insert(html, '<div style="padding: 4px 8px; font-size: 78%%;">')
table.insert(html, makeStatRow("Kompetisi", comp))
table.insert(html, makeStatRow("Man of the Match (MOTM)", motm))
table.insert(html, makeStatRow("Akurasi Operan", passAcc))
table.insert(html, makeStatRow("Total xG", xG))
table.insert(html, makeStatRow("Total xA", xA))
if yellow ~= "" or red ~= "" then
local cardsText = ""
if yellow ~= "" then cardsText = cardsText .. yellow .. " 🟨 " end
if red ~= "" then cardsText = cardsText .. red .. " 🟥" end
table.insert(html, makeStatRow("Kartu Disiplin", cardsText))
end
table.insert(html, '</div>')
table.insert(html, '</div>')
return table.concat(html, "")
end
return p