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
+14 -1
View File
@@ -31,6 +31,11 @@
<div style="margin-top:12px"><button class="btn sm" id="saveMission">Save mission</button> <span id="missionMsg" style="font-size:13px;color:var(--muted)"></span></div></div>
<table id="missions" style="margin-top:14px"></table>
</section>
<section class="section"><h2>Network Tour</h2>
<div class="sub" id="tourLine"></div>
<div class="card"><div class="two"><div><label>Rotation (1 = on, 0 = off)</label><input id="rotationOn"></div><div><label>Tour stop ad credits (free tier repeat)</label><input id="tourStopCredits"></div><div><label>Tour stop credits, daily max per member</label><input id="tourStopCreditsDailyMax"></div></div><div style="margin-top:12px"><button class="btn sm" id="saveTour">Save tour settings</button></div></div>
<table id="tourRows" style="margin-top:10px"></table>
</section>
<section class="section"><h2>Ad Detective</h2>
<div class="sub" id="detLine"></div>
<table id="detQs" style="margin-top:10px"></table>
@@ -63,7 +68,15 @@
$('detQs').innerHTML = '<tr><th>site</th><th>question</th><th>right answer</th><th>asked</th><th>right</th><th></th></tr>' + d.questions.map(q => '<tr style="' + (q.active === false ? 'opacity:.45' : '') + '"><td class="num">' + esc(q.missionId) + '</td><td>' + esc(q.q) + '</td><td>' + esc(q.options[0]) + '</td><td class="num">' + q.asked + '</td><td class="num">' + (q.asked ? Math.round(100 * q.correct / q.asked) + '%' : '—') + '</td><td><button class="btn ghost sm" data-qa="' + esc(q.id) + '" data-on="' + (q.active === false ? '1' : '0') + '">' + (q.active === false ? 'restore' : 'retire') + '</button></td></tr>').join('');
document.querySelectorAll('[data-qa]').forEach(b => b.addEventListener('click', async () => { await api('/api/admin/detective/question', { method: 'POST', body: JSON.stringify({ id: b.dataset.qa, active: b.dataset.on === '1' }) }); loadDetective(); }));
}
$('go').addEventListener('click', () => { KEY = $('key').value.trim(); load(); loadDetective(); });
// the Network Tour (2026-11-17): rounds per hunter, where each one stands this round, tour-stop credits sent and owed
async function loadTour() {
const t = await api('/api/admin/rotation'); if (!t || !t.hunters) return;
for (const k of ['rotationOn', 'tourStopCredits', 'tourStopCreditsDailyMax']) $(k).value = k === 'rotationOn' ? (t.settings.on ? 1 : 0) : (k === 'tourStopCredits' ? t.settings.credits : t.settings.dailyMax);
const ts = t.tourStops; $('tourLine').textContent = 'Rotation ' + (t.settings.on ? 'ON' : 'OFF') + ' · ' + t.hunters.length + ' hunters · ' + t.hunters.filter(h => h.rounds > 0).length + ' finished a round · tour stops ' + ts.total + ' (' + ts.creditsSent + ' credits sent, ' + ts.creditsOwed + ' owed)';
$('tourRows').innerHTML = '<tr><th>hunter</th><th>rounds done</th><th>this round</th><th>toured all</th><th>left this round</th><th>last find</th></tr>' + t.hunters.map(h => '<tr><td>' + esc(h.who) + '</td><td class="num">' + h.rounds + '</td><td class="num">' + h.done + ' / ' + h.total + '</td><td>' + (h.toured ? 'yes' : '') + '</td><td style="font-size:12px">' + esc(h.left.join(', ')) + '</td><td>' + (h.lastFind ? new Date(h.lastFind).toLocaleString('en-US', { timeZone: 'America/Chicago' }) : '') + '</td></tr>').join('');
}
$('saveTour').addEventListener('click', async () => { const b = {}; for (const k of ['rotationOn', 'tourStopCredits', 'tourStopCreditsDailyMax']) b[k] = Number($(k).value); const r = await api('/api/admin/settings', { method: 'POST', body: JSON.stringify(b) }); if (r.error) alert(r.error); loadTour(); });
$('go').addEventListener('click', () => { KEY = $('key').value.trim(); load(); loadDetective(); loadTour(); });
$('key').addEventListener('keydown', e => { if (e.key === 'Enter') $('go').click(); });
$('saveSettings').addEventListener('click', async () => { const b = {}; for (const k of ['minPol', 'maxPol', 'dailyCapPol', 'lowBalancePol']) b[k] = Number($(k).value); const r = await api('/api/admin/settings', { method: 'POST', body: JSON.stringify(b) }); if (r.error) alert(r.error); load(); });
$('tickFaucet').addEventListener('click', async () => { $('faucetLine').textContent = 'running…'; const r = await api('/api/admin/faucet/tick', { method: 'POST' }); $('faucetLine').textContent = r.error ? r.error : 'paid ' + r.paid + ' · balance ' + (r.balance == null ? '—' : Number(r.balance).toFixed(4) + ' POL'); load(); });