diff --git a/index.html b/index.html index 4078bf7..cb4e611 100644 --- a/index.html +++ b/index.html @@ -74,6 +74,7 @@ Player ITC Points LMC Points + LMC Rank W–L–T Win % ITC Rank diff --git a/src/main.js b/src/main.js index 510cf90..1136683 100644 --- a/src/main.js +++ b/src/main.js @@ -157,7 +157,8 @@ const sortCols = { wlt: { key: r => (+r.wins||0) * 10000 - (+r.losses||0) * 100 - (+r.ties||0), defaultDir: 'desc' }, wpct: { key: r => { const g=(+r.wins||0)+(+r.losses||0)+(+r.ties||0); return g?(+r.wins||0)/g:-1; }, defaultDir: 'desc' }, rank: { key: r => +(r.placing || Infinity), defaultDir: 'asc' }, - lmc: { key: r => { const uid = r.userId || r.user?.id; return uid && lmcPoints[uid] != null ? lmcPoints[uid] : -Infinity; }, defaultDir: 'desc' }, + lmc: { key: r => { const uid = r.userId || r.user?.id; return uid && lmcPoints[uid] != null ? lmcPoints[uid] : -Infinity; }, defaultDir: 'desc' }, + lmcrank: { key: r => { const uid = r.userId || r.user?.id; return uid && lmcRanks[uid] != null ? lmcRanks[uid] : Infinity; }, defaultDir: 'asc' }, elo: { key: r => { const e = findElo(fullName(r.user || {}), r.userId || r.user?.id); return e?.elo ?? -Infinity; }, defaultDir: 'desc' }, }; @@ -222,6 +223,7 @@ async function getMemberIds(force) { /* ---- LMC Points data ---- */ const lmcPoints = {}; // userId → number +const lmcRanks = {}; // userId → number let lmcLoaded = false; async function loadLmcData(ids) { @@ -230,7 +232,10 @@ async function loadLmcData(ids) { for await (const page of streamPlacings(CONFIG.lmcLeagueId)) { for (const rec of page) { const uid = rec.userId || rec.user?.id; - if (uid && ids.has(uid)) lmcPoints[uid] = +(rec.ITCPoints || 0); + if (uid && ids.has(uid)) { + lmcPoints[uid] = +(rec.ITCPoints || 0); + if (rec.placing != null) lmcRanks[uid] = rec.placing; + } } } } catch (e) { @@ -348,15 +353,25 @@ function render(state) { : `${fmtWpct(d.w, d.l, d.t)} career`; const mobilePct = `${fmtWpct(r.wins, r.losses, r.ties)} win rate`; const mobileElo = eloMatch ? `ELO ${Math.round(eloMatch.elo)}` : ''; - const mobileLmc = (uid && lmcLoaded && lmcPoints[uid] != null) ? `LMC ${fmtPts(lmcPoints[uid])}` : ''; + const mobileLmc = (() => { + if (!uid || !lmcLoaded || lmcPoints[uid] == null) return ''; + const rankStr = lmcRanks[uid] != null ? ` · LMC #${lmcRanks[uid]}` : ''; + return `LMC ${fmtPts(lmcPoints[uid])}${rankStr}`; + })(); const lmcCell = (() => { if (!lmcLoaded) return ``; const pts = uid ? lmcPoints[uid] : undefined; return `${pts != null ? fmtPts(pts) : ''}`; })(); + const lmcRankCell = (() => { + if (!lmcLoaded) return ``; + const rank = uid ? lmcRanks[uid] : undefined; + return `${rank != null ? '#' + rank : '—'}`; + })(); return `${fmtPts(r.ITCPoints)}` + mobilePct + mobileLmc + mobileElo + `` + lmcCell + + lmcRankCell + `` + `${r.wins || 0}${r.losses || 0}–${r.ties || 0}` + careerSub + `` + @@ -408,6 +423,7 @@ async function load(force) { // Reset and kick off LMC fetch non-blocking Object.keys(lmcPoints).forEach(k => delete lmcPoints[k]); + Object.keys(lmcRanks).forEach(k => delete lmcRanks[k]); loadLmcData(ids); for await (const page of streamPlacings(CONFIG.leagueId, CONFIG.regionId)) { @@ -438,6 +454,7 @@ function showSkeleton() { `
` + `
` + `
` + + `
` + `
` + `
` + `
` +