Network Tour (Marty 2026-11-17): mission rotation per hunter + free-tier tour stops

- lib/rotation.js: a round = every active house mission; the board offers only missions not found this
  round, never-visited first, then least recently found; mid-round additions join as not found, paused
  missions are skipped; the start gate refuses a mission found earlier this round. State per member in
  rotation.json (start, rounds); everyone starts at 0 so round 1 = their whole history. Paid missions
  keep their rules; daily limits, draws, pool and tiers unchanged. Setting rotationOn (default 1).
- Board: "Network tour: X of Y sites this round" with a progress bar and the sites left; New to you tag.
- Badge sweep renamed Full Network Tour (art unchanged), earned by the old rule or a closed round;
  celebrated on the board every round, round count on the card, Telegram posts it once.
- Free tier: POL only for discovery (first find of a mission). A repeat find is a tour stop: counts as
  the day's hunt and for the tour, 0 POL, ad credits through a signed call to InstantAdPay
  (polgrant.credits -> POST /api/partner/credits, idempotent on ref tour:<row id>); settings
  tourStopCredits 10 / tourStopCreditsDailyMax 10; unconfirmed stops stay owed and retry every 2 min.
  Game Pass holders unchanged. Toured free members see the Game Pass line on the board.
- Admin: Network Tour section (settings, rounds per hunter, credits sent/owed), GET /api/admin/rotation.
- Board daily line now passes the tier (a Pass holder saw 3, not 5).
- fridaybank: http for a local stub IAP (tests). Tests: test/rotation.js (27 checks), run.js waits for
  /health instead of a fixed 1.2 s. Guides: how-a-hunt-works, faq, free-account explain the tour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-17 09:20:42 -06:00
parent 408a30cf31
commit 654cd7b408
15 changed files with 352 additions and 26 deletions
+20 -7
View File
@@ -35,9 +35,9 @@
const isOpen = open && open.missionId === m.id;
const r = m.reward || {};
return '<div class="card' + (isOpen ? ' mission-open' : '') + '" data-id="' + esc(m.id) + '">'
+ '<span class="tag' + (m.done ? ' done' : '') + '">' + (m.done ? 'Done today' : esc(m.site)) + '</span>'
+ '<span class="tag' + (m.done ? ' done' : '') + '">' + (m.done ? 'Done today' : esc(m.site)) + '</span>' + (!m.done && m.fresh ? ' <span class="tag gold">New to you</span>' : '')
+ '<h3>' + esc(m.name) + '</h3><p>' + esc(m.brief) + '</p>'
+ '<p style="margin-top:10px"><span class="range">' + r.minPol + ' to ' + r.maxPol + ' POL</span> <span style="color:var(--dim);font-size:12px">· ' + m.dwell + 's on the site</span></p>'
+ '<p style="margin-top:10px"><span class="range">' + (m.tourStop ? 'Tour stop: +' + m.tourStop.credits + ' ad credits' : r.minPol + ' to ' + r.maxPol + ' POL') + '</span> <span style="color:var(--dim);font-size:12px">· ' + m.dwell + 's on the site</span></p>'
+ (m.done ? '' : (board.pool && board.pool.spent && !isOpen) ? '<div class="cardact"><span class="tag gold">Closed until midnight Central</span></div>' : (board.daily && !board.daily.left && !isOpen) ? '<div class="cardact"><span class="tag">Back tomorrow</span></div>' : isOpen
? '<div class="timer" id="timer">Your code appears on the site after <b>' + m.dwell + 's</b>. Keep that tab open.</div>'
+ '<div class="codebox"><input id="code" maxlength="6" placeholder="6 CHARACTERS" autocomplete="off" spellcheck="false" inputmode="text" autocapitalize="characters"><button class="btn pol" id="submit">Claim</button></div><div class="site" style="font-size:12px;margin-top:6px">Six characters. On the site, tap the code to copy it, then paste it here.</div>'
@@ -97,7 +97,7 @@
// badge cards: art, lock state, share
function badgeStrip() {
const el = $('badgeStrip'); if (!el || !board.badgeCards) return;
el.innerHTML = board.badgeCards.map(b => '<div class="badge-a' + (b.earned ? '' : ' locked') + '"><img src="' + b.art + '" alt="' + esc(b.name) + '" loading="lazy"><div class="bl">' + b.icon + ' ' + esc(b.name) + '</div><div class="bs">' + esc(b.why) + '</div>' + (b.earned ? '<button class="btn pol sm" data-share="' + b.id + '">Share</button>' : '<div class="bs">\u{1F512} locked</div>') + '</div>').join('');
el.innerHTML = board.badgeCards.map(b => '<div class="badge-a' + (b.earned ? '' : ' locked') + '"><img src="' + b.art + '" alt="' + esc(b.name) + '" loading="lazy"><div class="bl">' + b.icon + ' ' + esc(b.name) + (b.count ? ' \u00d7' + b.count : '') + '</div><div class="bs">' + esc(b.why) + '</div>' + (b.earned ? '<button class="btn pol sm" data-share="' + b.id + '">Share</button>' : '<div class="bs">\u{1F512} locked</div>') + '</div>').join('');
el.querySelectorAll('[data-share]').forEach(x => x.addEventListener('click', () => shareBadge(x.dataset.share, false)));
}
function shareBadge(id, unlocked) {
@@ -112,16 +112,27 @@
$('shareCopy').onclick = async () => { try { await navigator.clipboard.writeText(b.page); } catch (e) {} $('shareCopy').textContent = 'Copied'; setTimeout(() => { $('shareCopy').textContent = 'Copy link'; }, 1200); };
}
document.addEventListener('click', e => { if (e.target.id === 'shareClose' || e.target.id === 'shareModal') $('shareModal').hidden = true; });
// the Network Tour (2026-11-17): how far through this round, which sites are left; a free member who has toured
// everything is told what a repeat pays now (ad credits) and how POL comes back (new sites, or the Game Pass)
function tourPanel() {
const t = board.tour; if (!t || !t.on || !t.total) return '';
const pct = Math.round(100 * t.done / t.total);
const free = t.free && t.toured ? '<p class="tour-free">You\u2019ve toured the whole network. New sites pay POL when they launch. Want POL on every hunt? ' + (board.gamepass && board.gamepass.url ? '<a href="' + esc(board.gamepass.url) + '" target="_blank" rel="noopener">Get the Game Pass</a>.' : 'Get the Game Pass.') + ' Until then each hunt is a tour stop worth +' + t.tourStopCredits + ' InstantAdPay ad credits.</p>' : '';
return '<div class="tour" style="grid-column:1/-1"><div class="tour-hd"><b>\u{1F5FA}\uFE0F Network tour:</b> ' + t.done + ' of ' + t.total + ' sites this round' + (t.rounds ? ' <span class="tour-r">\u00b7 ' + t.rounds + ' round' + (t.rounds === 1 ? '' : 's') + ' done</span>' : '') + '</div>'
+ '<div class="tour-bar" role="progressbar" aria-valuemin="0" aria-valuemax="' + t.total + '" aria-valuenow="' + t.done + '"><i style="width:' + pct + '%"></i></div>'
+ (t.left.length ? '<div class="tour-left">Left this round: ' + t.left.map(esc).join(' \u00b7 ') + '</div>' : '')
+ free + '</div>';
}
function render() {
badgeStrip();
$('who').innerHTML = '<i></i> ' + esc(board.me.username ? '@' + board.me.username : '#' + board.me.memberId) + (board.me.wallet ? '' : ' · no wallet linked')
// Game Pass (InstantAdPay, all nine games): active until <date>, or the link to get it; opens a new tab (the game may be framed)
+ (board.gamepass && board.gamepass.on ? ' · ' + (board.gamepass.active ? '\u{1F3AB} Game Pass active' + (board.gamepass.untilText ? ' until ' + esc(board.gamepass.untilText) : '') + ' (5 missions a day, 2 Ad Detective cases)' : '\u{1F3AB} <a href="' + esc(board.gamepass.url) + '" target="_blank" rel="noopener">Get the Game Pass</a>: higher daily POL caps, 5 missions a day, 2 cases') : '');
const r = board.missions[0] && board.missions[0].reward;
if (r) $('rangeLine').textContent = 'Each find pays a random drip between ' + r.minPol + ' and ' + r.maxPol + ' POL. Your codes are yours alone.';
if (r) $('rangeLine').textContent = (board.tour && board.tour.free && board.tour.toured) ? 'A site new to you pays a random drip of POL; a repeat is a tour stop worth ' + board.tour.tourStopCredits + ' ad credits. Your codes are yours alone.' : 'Each find pays a random drip between ' + r.minPol + ' and ' + r.maxPol + ' POL. Your codes are yours alone.';
const pool = board.pool || {};
if (!board.me.wallet) $('missions').innerHTML = onboarding();
else $('missions').innerHTML = (pool.spent ? '<div class="notice" style="grid-column:1/-1"><b>Today\u2019s POL pool is spent.</b> No more claims today. Claims reopen at midnight Central' + (pool.resetsAt ? ', in ' + until(pool.resetsAt) : '') + '.</div>' : '')
else $('missions').innerHTML = tourPanel() + (pool.spent ? '<div class="notice" style="grid-column:1/-1"><b>Today\u2019s POL pool is spent.</b> No more claims today. Claims reopen at midnight Central' + (pool.resetsAt ? ', in ' + until(pool.resetsAt) : '') + '.</div>' : '')
+ (board.missions.length ? board.missions.map(card).join('') : '<div class="card"><p>No missions are open right now. Check back soon.</p></div>');
if ($('refSlot')) $('refSlot').innerHTML = board.me.wallet ? referralCard() : '';
wireRefVideo();
@@ -156,7 +167,7 @@
fridayCard(board.fridayBank);
boxCard(board.box);
const dl = board.daily; if (dl && $('rangeLine')) $('rangeLine').innerHTML = ($('rangeLine').textContent.replace(/\s*·\s*You have.*$/, '')) + ' \u00b7 ' + (dl.left ? 'You have <b>' + dl.left + ' of ' + dl.limit + '</b> missions left today.' : '<b>That is your ' + dl.limit + ' for today.</b> Fresh missions at midnight Central.');
$('mine').innerHTML = board.drips.length ? board.drips.map(d => '<div class="row"><span>' + (String(d.missionId || '').startsWith('detective:') ? '\u{1F50E} ' : '') + esc(d.site) + '</span><span class="site">' + ({ paid: 'paid', sent: 'sending', due: 'paying next', queued: 'queued for the next pool', failed: 'held, being looked at' }[d.status] || d.status) + '</span><span class="pol">+' + d.pol + ' POL</span>' + (d.tx ? '<a class="when" target="_blank" rel="noopener" href="' + explorer + '/tx/' + d.tx + '">verify ↗</a>' : '<span class="when"></span>') + '</div>').join('')
$('mine').innerHTML = board.drips.length ? board.drips.map(d => '<div class="row"><span>' + (String(d.missionId || '').startsWith('detective:') ? '\u{1F50E} ' : '') + esc(d.site) + '</span><span class="site">' + ({ paid: 'paid', sent: 'sending', due: 'paying next', queued: 'queued for the next pool', failed: 'held, being looked at', tour: 'tour stop' + (d.tourStop && d.tourStop.credits ? ': +' + d.tourStop.credits + ' ad credits' + (d.tourStop.state === 'sent' ? '' : ' (sending)') : '') }[d.status] || d.status) + '</span><span class="pol">' + (d.status === 'tour' ? '0' : '+' + d.pol) + ' POL</span>' + (d.tx ? '<a class="when" target="_blank" rel="noopener" href="' + explorer + '/tx/' + d.tx + '">verify ↗</a>' : '<span class="when"></span>') + '</div>').join('')
: '<div class="row"><span class="site">Nothing yet. Your first find goes here.</span></div>';
document.querySelectorAll('[data-start]').forEach(b => b.addEventListener('click', () => start(b.dataset.start)));
const s = $('submit'); if (s) { s.addEventListener('click', submit); $('code').addEventListener('keydown', e => { if (e.key === 'Enter') submit(); }); tick(); }
@@ -268,7 +279,9 @@
const m = $('msg'); m.className = 'msg ' + (r.error ? 'bad' : 'ok'); m.textContent = r.error || r.message;
if (!r.error && r.gamepass) board.gamepass = r.gamepass; // the Game Pass flag refreshes with every grant answer
if (!r.error && /Get the Pass/.test(r.message || '') && board.gamepass && board.gamepass.on && !board.gamepass.active) m.innerHTML = esc(r.message) + ' <a href="' + esc(board.gamepass.url) + '" target="_blank" rel="noopener">Get the Game Pass</a>'; // the cap-hit nudge, in a new tab (the page may be framed)
if (r.error) toast(esc(r.error), 'bad'); else toast('\u{1F389} <b>Found it!</b> ' + r.pol + ' POL is on its way to your wallet.', 'big');
if (r.error) toast(esc(r.error), 'bad'); else if (r.tourStop) toast('\u{1F5FA}\uFE0F <b>Tour stop!</b> ' + (r.tourStop.credits ? '+' + r.tourStop.credits + ' ad credits to your InstantAdPay account.' : 'Logged for your network tour.'), 'big'); else toast('\u{1F389} <b>Found it!</b> ' + r.pol + ' POL is on its way to your wallet.', 'big');
if (!r.error && r.tourStop && board.gamepass && board.gamepass.on && !board.gamepass.active) m.innerHTML = esc(r.message) + ' <a href="' + esc(board.gamepass.url) + '" target="_blank" rel="noopener">Get the Game Pass</a>';
if (!r.error && r.round) toast('\u{1F5FA}\uFE0F <b>Full Network Tour!</b> Round ' + r.round + ' done. A new round starts now.', 'big');
if (!r.error) { const a = document.createElement('a'); a.href = '#share'; a.textContent = ' Share this find \u2197'; a.style.marginLeft = '6px'; m.appendChild(a); delete $('sharetext').dataset.touched; }
// an achievement unlocked by this find: celebrate it once the board has reloaded
if (!r.error && r.unlocked && r.unlocked.length) { const id = r.unlocked[0]; toast('\u{1F3C6} <b>Achievement unlocked!</b>', 'big'); setTimeout(async () => { await load(); shareBadge(id, true); }, 1200); }