function ProfilePage({ playerId, onBack }) { const player = byId(playerId); if (!player) return null; const total = player.wins + player.losses; const wr = winRate(player); const rank = [...DB.players].sort((a,b) => b.wins - a.wins).findIndex(p => p.id === player.id); // Real partner stats from computed data const ps = player.partnerStats || {}; const bestId = player.bestPartner; const worstId = player.worstPartner; const best = byId(bestId); const worst = byId(worstId); const bestWins = bestId && ps[bestId] ? ps[bestId].wins : 0; const worstL = worstId && ps[worstId] ? ps[worstId].losses : 0; const myBadges = badgesFor(player.id); const myMatches = DB.matches.filter(m => [...m.teamA, ...m.teamB].includes(player.id)); const tarneebTotal = player.tarneeb + (player.tarneebLosses || 0); const trixTotal = player.trix + (player.trixLosses || 0); return (
بروفايل اللاعب
{/* Hero */}
{rank + 1}
{player.name}
الترتيب رقم {rank + 1}
{/* Stat grid */}
{player.wins}
فوزات
{player.losses}
خسارات
{total}
مباريات
{wr}٪
نسبة الفوز
{/* Badges */} {myBadges.length > 0 && <>
الأوسمة
{myBadges.map(b => (
{b.icon}
{b.label}
{b.flavor}
))}
} {/* Game breakdown */}
تفصيل الألعاب
طرنيب
{player.tarneeb}/{tarneebTotal}
تركس
{player.trix}/{trixTotal}
{/* Partners */} {(best || worst) && <>
الشريك الذهبي والسمّ
{best && (
أفضل شريك
{best.name}
{bestWins} فوز سوا
)} {worst && (
شريك الكارثة
{worst.name}
{worstL} خسارة سوا
)}
} {/* Personal history */}
آخر مبارياتي
{myMatches.length === 0 && (
لا توجد مباريات بعد
)} {myMatches.slice(0, 8).map((m, i) => { const myTeam = m.teamA.includes(player.id) ? "A" : "B"; const won = m.winner === myTeam; const partnerId = myTeam === "A" ? m.teamA.find(x => x !== player.id) : m.teamB.find(x => x !== player.id); const partner = byId(partnerId); return (
{arabicDateLabel(m.date)} {m.game}
{won ? "فوز ✓" : "خسارة ✗"} {partner && مع {partner.name}}
); })}
); } Object.assign(window, { ProfilePage });