Tiers (Marty 2026-11-02, every game must fund itself): guests earn nothing (a guest's chapters, drips and best follow them at sign-in, the POL does not; no more collected= payout on /auth), a free InstantAdPay account earns freeSharePct (25, admin) of the chapter drip with the note "Game Pass holders earn the full amount.", Game Pass holders earn the full drip plus the shield perk, GAMEPASS off = everyone full. /api/me carries tier, freeSharePct and yourDrip; landing, lobby, clear card, tester briefing and share preview say play free, sign in to earn a taste, Game Pass for the full table. Tests: guest 0 at sign-in, free 25%, pass 100%, gp off full, settings key.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-02 17:01:10 -06:00
parent 4d8dde2ad2
commit b69086aaac
11 changed files with 92 additions and 55 deletions
+9 -8
View File
@@ -104,7 +104,7 @@ async function notify(kind, p) {
if (kind === 'low') return telegram('⚠️ <b>Drip Runner wallet is low</b>: ' + fmt(p.balance) + ' POL in ' + p.address + ' (needs ' + fmt(p.threshold) + ').');
if (kind === 'gpstuck') return telegram('⚠️ <b>Drip Runner</b> Game Pass grant stuck 48 h: member #' + p.memberId + ' ' + (p.email || '') + ' ref ' + p.ref + ' (' + fmt(p.pol) + ' POL, ' + p.kind + '). InstantAdPay /api/partner/polgrant unreachable: ' + (p.error || '?'));
if (kind === 'refused') return telegram('\u{1F6AB} <b>Drip Runner</b> \u00b7 ' + who + ' (' + p.email + ') tried to sign in but is not on the tester list. Add them under Admin > Settings > Testers: ' + SITE + '/admin');
if (kind === 'signin') return telegram('\u{1F44B} <b>Drip Runner</b> · first sign-in: ' + who + ' (' + (p.wallet ? 'wallet on file' : 'NO wallet yet') + ')');
if (kind === 'signin') return telegram('\u{1F44B} <b>Drip Runner</b> · first sign-in: ' + who + ' (' + (p.wallet ? 'wallet on file' : 'NO wallet yet') + ')' + (p.via ? ' · came in through ' + p.via + ', played as a guest first (guest runs earn nothing)' : ''));
if (kind === 'refuel') return telegram('⛽ <b>Drip Runner</b> · ' + who + ' refuelled on campaign #' + p.campaignId + ': +' + fmt(p.pol) + ' POL to the pool (' + p.credits + ' credits, $' + p.share + ' share)');
return false;
}
@@ -248,7 +248,8 @@ const server = http.createServer(async (req, res) => {
const adopted = [];
const guest = sso.guestFrom(req);
if (Number(r.claims.memberId) > 0) { const ad = game.adopt(sso.emailId(r.claims.email), r.claims.memberId); if (ad.moved) adopted.push('wallet-less history'); }
const pendingClears = guest ? game.adopt(guest.memberId, r.claims.memberId).pending : [];
// a guest's progress (chapters, drips, best) follows them; guest rewards never turn into POL (Marty 2026-11-02: guests earn nothing)
const carried = guest ? !!game.adopt(guest.memberId, r.claims.memberId).moved : false;
if (guest) sso.endGuest(guest.gid);
const first = !existedBefore;
game.updPlayer(r.claims.memberId, x => { x.email = String(r.claims.email).toLowerCase(); x.username = r.claims.username || x.username || null; x.wallet = r.claims.wallet ? String(r.claims.wallet).toLowerCase() : x.wallet || null; x.lastSeen = Date.now(); });
@@ -258,13 +259,11 @@ const server = http.createServer(async (req, res) => {
game.updPlayer(r.claims.memberId, x => { if (!x.sponsorRef && r.claims.sponsorRef) x.sponsorRef = String(r.claims.sponsorRef).toLowerCase(); if (r.claims.joinedRef && !x.joinedRef) x.joinedRef = r.claims.joinedRef; });
starter.grantPerk(r.claims.memberId); // a member (memberId > 0) gets one free hangar upgrade, once per account (2026-10-05)
if (r.claims.gamePass != null) ledger.gp.rememberPass(ledger.iapId(r.claims), r.claims.email, r.claims.gamePass); // the Game Pass flag rides on the hand-off as gamePass:{active,until} (GAME-PASS.md 3a item 7)
const meNow = { memberId: Number(r.claims.memberId), email: String(r.claims.email || '').toLowerCase(), username: r.claims.username || null, wallet: r.claims.wallet ? String(r.claims.wallet).toLowerCase() : null };
for (const ch of pendingClears) { const g = await ledger.chapterDripGated(meNow, ch, true); if (g.pol) announceChapter(meNow, ch, g.pol); } // clears made as a guest pay now
{ const t = srctrack.fromRequest(req); if (t) {
srctrack.bump(t.src, 'signins', r.claims.memberId); game.updPlayer(r.claims.memberId, x => { if (!x.src) x.src = t.src; });
if (r.claims.joinedAt && Date.now() - Number(r.claims.joinedAt) < 30 * 60000) { srctrack.bump(t.src, 'signups', r.claims.memberId); srctrack.postback(t, r.claims.memberId).catch(() => {}); } } }
if (first) notify('signin', { memberId: r.claims.memberId, username: r.claims.username, wallet: r.claims.wallet, via: guest ? 'a share link' : null }).catch(() => {});
res.writeHead(302, { Location: '/play' + (pendingClears.length ? '?collected=' + pendingClears.length : ''), 'Set-Cookie': [sso.cookie(sid)].concat(guest ? [sso.clearGuestCookie()] : []), 'Cache-Control': 'no-store' }); return res.end();
res.writeHead(302, { Location: '/play' + (carried ? '?carried=1' : ''), 'Set-Cookie': [sso.cookie(sid)].concat(guest ? [sso.clearGuestCookie()] : []), 'Cache-Control': 'no-store' }); return res.end();
}
// a member's share card (2026-10-04, Neville/cryptoassets: his link previewed as the blank First Chapter badge): the badge with
// the sharer's name on the plate, rendered once and cached by lib/badge.js
@@ -279,7 +278,7 @@ const server = http.createServer(async (req, res) => {
if (mr && /TelegramBot|facebookexternalhit|Facebot|Twitterbot|WhatsApp|Slackbot|Discordbot|LinkedInBot|SkypeUriPreview|redditbot|Iframely|Embedly|vkShare|Pinterest|Googlebot|bingbot/i.test(String(req.headers['user-agent'] || ''))) {
const sh = game.byUsername(mr[1]); const nm = sh ? sh.username : null; const card = SITE + '/r/' + encodeURIComponent(mr[1]) + '/card.jpg';
const t = nm ? '@' + nm + ' invited you to Drip Runner' : 'Drip Runner: hop the network, get paid in POL';
const d = 'A fast little runner game in the InstantAdPay network, part of the Crypto Team Build Network. Play free, clear chapters and collect POL rewards.';
const d = 'A fast little runner game in the InstantAdPay network, part of the Crypto Team Build Network. Play free; sign in with a free InstantAdPay account to earn POL on every chapter you clear, and the Game Pass pays the full reward.';
res.writeHead(200, Object.assign({ 'Content-Type': 'text/html; charset=utf-8', 'Cache-Control': 'no-store' }, SEC));
return res.end('<!doctype html><html><head><meta charset="utf-8"><title>' + esc(t) + '</title><meta name="description" content="' + esc(d) + '"><meta property="og:type" content="website"><meta property="og:site_name" content="Drip Runner"><meta property="og:url" content="' + esc(SITE + '/r/' + mr[1]) + '"><meta property="og:title" content="' + esc(t) + '"><meta property="og:description" content="' + esc(d) + '"><meta property="og:image" content="' + esc(nm ? card : SITE + '/og-driprunner.jpg') + '"><meta property="og:image:width" content="' + (nm ? 1080 : 1200) + '"><meta property="og:image:height" content="' + (nm ? 1080 : 630) + '"><meta name="twitter:card" content="summary_large_image"><meta name="twitter:title" content="' + esc(t) + '"><meta name="twitter:image" content="' + esc(nm ? card : SITE + '/og-driprunner.jpg') + '"></head><body><a href="/play">Play Drip Runner</a></body></html>');
}
@@ -361,7 +360,8 @@ const server = http.createServer(async (req, res) => {
}
if (p === '/api/admin/settings' && req.method === 'POST') {
const { body } = await readBody(req); const patch = {};
for (const k of ['refSharePct', 'usdPerCredit', 'creditsPerVisit', 'poolSharePct', 'usdPerPolFallback', 'dripPol', 'dailyCapPol', 'thresholdPol', 'seedPol', 'lowBalancePol']) if (body[k] != null && body[k] !== '') patch[k] = Number(body[k]);
for (const k of ['refSharePct', 'usdPerCredit', 'creditsPerVisit', 'poolSharePct', 'usdPerPolFallback', 'dripPol', 'dailyCapPol', 'thresholdPol', 'seedPol', 'lowBalancePol', 'freeSharePct']) if (body[k] != null && body[k] !== '' && Number.isFinite(Number(body[k])) && Number(body[k]) >= 0) patch[k] = Number(body[k]);
if (patch.freeSharePct != null) patch.freeSharePct = Math.min(100, patch.freeSharePct); // the free tier's share of the table (2026-11-02)
if (body.signups && ['testers', 'key', 'open', 'closed'].includes(body.signups)) patch.signups = body.signups;
if (body.trial === 'on' || body.trial === 'off') patch.trial = body.trial === 'on';
if (Array.isArray(body.testers)) patch.testers = body.testers.map(x => String(x).trim().toLowerCase()).filter(Boolean).slice(0, 500);
@@ -414,7 +414,8 @@ async function memberApi(req, res, u, p, me) {
const pl = ledger.pool();
if (!me.guest && ledger.gp.on()) ledger.gp.fetchPass(ledger.iapId(me), me.email).catch(() => {}); // keep the Game Pass flag fresh (display + the shield perk; grant answers carry the truth)
const refs = me.guest ? [] : game.referralsOf(me);
return json(res, 200, { me: { memberId: me.memberId, username: me.username, wallet: me.wallet, guest: !!me.guest, hasWallet: !me.guest && !!(me.wallet || ledger.account(me.memberId).wallet || (game.player(me.memberId) || {}).wallet) }, player: game.view(me), balance: ledger.balance(me.memberId), pool: { available: pl.available, capLeft: pl.capLeft, dripPol: Number(ledger.settings().dripPol) }, iap: IAP, site: SITE, tips: await tips.list(ledger.settings()),
// tier (2026-11-02): guest = earns nothing, free = freeSharePct of the table (yourDrip), full = the table (Game Pass, or GAMEPASS off)
return json(res, 200, { me: { memberId: me.memberId, username: me.username, wallet: me.wallet, guest: !!me.guest, hasWallet: !me.guest && !!(me.wallet || ledger.account(me.memberId).wallet || (game.player(me.memberId) || {}).wallet) }, player: game.view(me), balance: ledger.balance(me.memberId), pool: { available: pl.available, capLeft: pl.capLeft, dripPol: Number(ledger.settings().dripPol), tier: ledger.tierOf(me), freeSharePct: ledger.freeShare(), yourDrip: me.guest ? 0 : ledger.dripFor(me) }, iap: IAP, site: SITE, tips: await tips.list(ledger.settings()),
signin: me.guest ? signinUrl(req) : null, share: (!me.guest && me.username) ? SITE + '/r/' + encodeURIComponent(me.username) : null, referrals: { count: refs.length, clicks: (store.read('share-hits', {})[String(me.username || '').toLowerCase()] || 0), earned: ledger.balance(me.memberId).refTotal, pct: Number(ledger.settings().refSharePct) || 0 },
perk: me.guest ? null : starter.takeNotice(me.memberId), // the member perk's one-time message (2026-10-05)
gamepass: me.guest ? null : ledger.gp.view(ledger.iapId(me), me.email) }); // Game Pass: active until <date>, or the link to get it