5xYourTeam The Draft v1 (phase 1, local only): weekly earned-order draft of holding-tank people, picks as adoptions (stub tank), coaching tools, cards, boards, trust pack
$10 one-time DraftPosition purchases (sponsor 25%, L2-5 5%, 10% Best Coach pot, 45% company) with keeper-signed hub-line vouchers; pure draft engine with a mocked clock; no contact data anywhere; Telegram to an outbox unless TG_LIVE=1. Unit 60/60, smoke 156/156 (Playwright 1280/390). Not deployed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
// The Draft Board (front page): who is on the clock, this week's pool as scouting cards, the draft tracker, Best Coach standings,
|
||||
// Rookie of the Week and the Best Coach pot. Every figure comes from /api/board; a missing stat says "not tracked yet".
|
||||
(async function () {
|
||||
FX.renderNav('/'); FX.renderFooter();
|
||||
const $ = FX.$, esc = FX.esc;
|
||||
const c = await FX.getConfig().catch(() => ({}));
|
||||
const me = await FX.getJSON('/api/me').catch(() => ({}));
|
||||
let B = null, busy = false, showAll = false;
|
||||
const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
||||
const hourLabel = h => (h % 12 || 12) + ' ' + (h < 12 ? 'AM' : 'PM');
|
||||
const pol = w => w == null ? 'not tracked yet' : FX.polOf(w) + ' POL';
|
||||
function hero(b) {
|
||||
const d = b.draft; const cur = d && d.onClock;
|
||||
const when = days[(c.draft || {}).dow == null ? 1 : c.draft.dow] + ' ' + hourLabel(b.draftHour) + ' Central';
|
||||
if (d && d.status === 'live' && cur) {
|
||||
$('heroKick').textContent = cur.me ? 'YOU\'RE ON THE CLOCK' : 'THE DRAFT IS LIVE';
|
||||
$('heroTitle').textContent = cur.me ? 'Pick ' + cur.n + ' of Round ' + cur.round + '. Make it count.' : 'Pick ' + cur.n + ' of Round ' + cur.round + ': @' + cur.coach + ' is on the clock.';
|
||||
$('heroClock').hidden = false; $('heroClock').dataset.until = cur.until;
|
||||
} else if (d && d.status === 'done' && b.now < b.nextDraftAt) {
|
||||
$('heroKick').textContent = 'NEXT DRAFT: ' + when.toUpperCase();
|
||||
$('heroTitle').textContent = d.made ? d.made + ' players drafted this week. Get your picks started.' : 'Next draft ' + FX.when(b.nextDraftAt) + '.';
|
||||
$('heroClock').hidden = false; $('heroClock').dataset.until = b.nextDraftAt;
|
||||
} else {
|
||||
$('heroKick').textContent = 'DRAFT DAY: ' + when.toUpperCase();
|
||||
$('heroTitle').textContent = b.rounds + ' rounds. Draft order is earned.';
|
||||
$('heroClock').hidden = false; $('heroClock').dataset.until = b.now < b.draftAt ? b.draftAt : b.nextDraftAt;
|
||||
}
|
||||
}
|
||||
function clock() { const el = $('heroClock'); if (!el || el.hidden) return; const u = Number(el.dataset.until || 0); const live = B && B.draft && B.draft.status === 'live';
|
||||
el.textContent = live ? 'Clock: ' + FX.left(u - Date.now() - (B.now - B.fetched)) : 'Starts in ' + FX.left(u - Date.now() - (B.now - B.fetched)); }
|
||||
function scout(p, b) {
|
||||
const coach = b.me && b.me.coach; const live = b.draft && b.draft.status === 'live'; const onClock = live && b.draft.onClock && b.draft.onClock.me;
|
||||
const queued = b.me && (b.me.queue || []).includes(p.id);
|
||||
let act = '';
|
||||
if (onClock) act = '<button type="button" class="btn" data-draft="' + esc(p.id) + '">DRAFT</button>';
|
||||
else if (coach && !live && b.me.credits > 0) act = '<button type="button" class="btn" data-instant="' + esc(p.id) + '">DRAFT NOW</button>';
|
||||
else if (coach) act = '<button type="button" class="btn" data-queue="' + esc(p.id) + '">' + (queued ? 'ON MY QUEUE' : 'ADD TO QUEUE') + '</button>';
|
||||
else act = '<a class="btn" href="/join">GET A POSITION</a>';
|
||||
const rows = [['Game plays', p.plays == null ? 'not tracked yet' : FX.n(p.plays)], ['Plays', p.game || (p.plays === 0 ? 'none yet' : p.plays == null ? 'not tracked yet' : 'none yet')]];
|
||||
if (coach) rows.push(['Earned in games', pol(p.gameWei)], ['Earned surfing', pol(p.surfWei)]);
|
||||
rows.push(['Last seen', FX.ago(p.lastSeen, b.now)], ['Came from', p.door || 'not tracked yet'], ['Wallet', p.wallet ? 'linked' : 'not yet']);
|
||||
return '<article class="scout"><div class="hd"><b>@' + esc(p.username || 'player') + '</b>' + (p.hot ? '<span class="tag">HOT</span>' : '') + '</div><div class="bd">'
|
||||
+ rows.map(r => '<div class="kvr"><span>' + r[0] + '</span><b>' + esc(r[1]) + '</b></div>').join('') + '</div><div class="ft">' + act + '</div></article>';
|
||||
}
|
||||
function paint(b) {
|
||||
B = b; B.fetched = Date.now(); FX.setWeek(b.week); hero(b);
|
||||
$('potWei').textContent = FX.polOf(b.pot.wei) + ' POL';
|
||||
$('potRank').innerHTML = b.me && b.me.coach ? '<span>Your draft spot next Monday</span><b>#' + esc(b.me.nextSpot || '?') + '</b>' : '<span>Coaches this week</span><b>' + FX.n(b.coaches) + '</b>';
|
||||
const coach = b.me && b.me.coach;
|
||||
$('poolNote').textContent = (b.poolSize ? FX.n(b.poolSize) + ' people waiting for a sponsor. ' : '') + (coach ? (b.me.credits > 0 && !(b.draft && b.draft.status === 'live') ? 'You have ' + b.me.credits + ' instant pick' + (b.me.credits === 1 ? '' : 's') + ': draft now, or queue players for Monday.' : 'Queue the players you want; an away coach is auto-picked from their queue.') : 'Usernames only, never contact details. Coaches see earnings where they are tracked.');
|
||||
const shown = showAll ? b.pool : b.pool.slice(0, 8);
|
||||
$('poolMore').hidden = showAll || b.pool.length <= 8; $('poolMore').textContent = 'Show all ' + b.pool.length + ' players';
|
||||
$('pool').innerHTML = b.pool.length ? shown.map(p => scout(p, b)).join('') : '<p class="muted">The pool is empty right now. People who join the network without a sponsor show up here after their first 24 hours.</p>';
|
||||
// tracker
|
||||
const d = b.draft;
|
||||
if (d && d.status === 'live') {
|
||||
$('trackTitle').textContent = 'DRAFT TRACKER: ROUND ' + (d.onClock ? d.onClock.round : '');
|
||||
const rows = d.rows.slice(0, 6).reverse().map(x => '<tr' + (x.me ? ' class="me"' : '') + '><td>' + esc(x.slot) + '</td><td>@' + esc(x.coach) + '</td><td>' + (x.person ? '@' + esc(x.person) : '<span class="muted">' + esc(x.skipped === 'team full' ? 'skipped: team full' : 'skipped') + '</span>') + '</td><td>' + esc(x.tierName || '') + '</td></tr>')
|
||||
.concat(d.room.map((r, i) => '<tr' + (r.me ? ' class="me"' : '') + '><td>' + esc(r.slot) + '</td><td class="c">' + (i === 0 ? (r.me ? 'You are on the clock' : '@' + esc(r.coach) + ' is on the clock') : '@' + esc(r.coach)) + '</td><td>' + (i === 0 ? '...' : '') + '</td><td></td></tr>'));
|
||||
$('track').innerHTML = rows.join('');
|
||||
} else if (d && d.rows.length) {
|
||||
$('trackTitle').textContent = 'DRAFT RESULTS: WEEK OF ' + b.week;
|
||||
$('track').innerHTML = d.rows.filter(x => x.person).slice(0, 15).map(x => '<tr' + (x.me ? ' class="me"' : '') + '><td>' + esc(x.slot) + '</td><td>@' + esc(x.coach) + '</td><td>@' + esc(x.person) + '</td><td>' + esc(x.tierName || '') + '</td></tr>').join('');
|
||||
} else { $('trackTitle').textContent = 'DRAFT TRACKER'; $('track').innerHTML = '<tr><td colspan="4" class="muted">The draft starts ' + esc(FX.when(b.now < b.draftAt ? b.draftAt : b.nextDraftAt)) + '. Every coach gets a spot every week.</td></tr>'; }
|
||||
$('best').innerHTML = b.best.length ? b.best.map(x => '<div class="r' + (x.me ? ' me' : '') + '"><span>' + x.rank + '. @' + esc(x.coach) + '</span><b>' + x.started + ' started</b></div>').join('')
|
||||
: '<p class="muted small">No picks started yet this week. The first coach to get one going leads the board.</p>';
|
||||
$('potRule').textContent = '"Started" = a pick switched on payouts or made a first purchase. The pot is 10% of every position sold this week' + (b.pot.split && b.pot.split.length ? ', shared ' + b.pot.split.join('/') + ' by the top ' + b.pot.split.length + ' coaches after the week.' : '.');
|
||||
$('rookie').innerHTML = b.rookie ? FX.card(b.rookie) : '<p class="muted small">The first pick this week to link a wallet takes it.</p>';
|
||||
$('lastBest').innerHTML = b.lastWeekBest.length ? b.lastWeekBest.map(x => '<div class="r"><span>' + x.rank + '. @' + esc(x.coach) + '</span><b>' + x.started + ' started</b></div>').join('') : '<p class="muted small">No results from last week yet.</p>';
|
||||
wire();
|
||||
}
|
||||
function wire() {
|
||||
document.querySelectorAll('[data-draft]').forEach(el => el.onclick = () => act('/api/draft/pick', { person: el.dataset.draft }, 'Drafted. They show on My Team now.'));
|
||||
document.querySelectorAll('[data-instant]').forEach(el => el.onclick = () => act('/api/my/instant', { person: el.dataset.instant }, 'Drafted. They show on My Team now.'));
|
||||
document.querySelectorAll('[data-queue]').forEach(el => el.onclick = async () => {
|
||||
const q = (B.me.queue || []).slice(); const id = el.dataset.queue; const i = q.indexOf(id); if (i >= 0) q.splice(i, 1); else q.push(id);
|
||||
const r = await FX.post('/api/my/queue', { ids: q }); if (r.error) return FX.status(r.error, 'err'); B.me.queue = r.queue; paint(B);
|
||||
});
|
||||
}
|
||||
async function act(url, body, okMsg) {
|
||||
if (busy) return; busy = true;
|
||||
try { const r = await FX.post(url, body); if (r.error) FX.status(r.error, 'err'); else FX.status(okMsg, 'ok'); await load(); } finally { busy = false; }
|
||||
}
|
||||
async function load() { const b = await FX.getJSON('/api/board'); if (!b.error) paint(b); return b; }
|
||||
$('poolMore').onclick = () => { showAll = true; paint(B); };
|
||||
await load();
|
||||
setInterval(clock, 1000); clock();
|
||||
setInterval(() => { load().catch(() => {}); }, 6000);
|
||||
if (me.signedIn) { const ping = () => FX.post('/api/presence', {}).catch(() => {}); ping(); setInterval(ping, 30000); }
|
||||
})();
|
||||
Reference in New Issue
Block a user