From f002222b252e9170f621472ffefee5a01917a429 Mon Sep 17 00:00:00 2001 From: martbost Date: Tue, 3 Nov 2026 13:18:04 -0600 Subject: [PATCH] polgrant: say when the free game allowance is used up (Marty 2026-11-03). InstantAdPay's answer carries lifetimeHit, freeLifetime and waiting; the note reads 'You have used your free 2 POL in the games. Get the Game Pass to keep earning.' plus the POL held for a progress reward, instead of 'pays out over the next days' Co-Authored-By: Claude Opus 5.5 --- lib/polgrant.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/polgrant.js b/lib/polgrant.js index 67096dc..861c066 100644 --- a/lib/polgrant.js +++ b/lib/polgrant.js @@ -48,7 +48,7 @@ async function get(path, who, params) { return { status: r.status, json }; } -// the one call that matters -> { allowed, deferred, carried, pass, day, capHit, enforced, repeat, retry: false } +// the one call that matters -> { allowed, deferred, carried, pass, day, capHit, enforced, repeat, lifetimeHit, freeLifetime, waiting, retry: false } // or { allowed: 0, retry: true, error }. Never throws. async function grant({ memberId, email, game, kind, pol, ref }) { const body = { memberId: Number(memberId) || 0, email: String(email || '').trim().toLowerCase() || undefined, game: game || cfg.game, kind: kind === 'daily' ? 'daily' : 'progress', pol: r4(Math.max(0, Number(pol) || 0)), ref: String(ref || '') }; @@ -57,7 +57,7 @@ async function grant({ memberId, email, game, kind, pol, ref }) { try { const { status, json } = await post('/api/partner/polgrant', body); if (status !== 200 || !json || typeof json.allowed !== 'number') return { allowed: 0, deferred: 0, carried: 0, pass: false, retry: true, error: 'http ' + status + (json && json.error ? ': ' + json.error : '') }; - const out = { allowed: r4(Math.max(0, json.allowed)), deferred: r4(Math.max(0, Number(json.deferred) || 0)), carried: r4(Math.max(0, Number(json.carried) || 0)), pass: !!(json.pass && (json.pass === true || json.pass.active)), day: json.day || ctDay(), capHit: json.capHit || null, enforced: json.enforced !== false, repeat: !!json.repeat, suspended: !!json.suspended, retry: false }; + const out = { allowed: r4(Math.max(0, json.allowed)), deferred: r4(Math.max(0, Number(json.deferred) || 0)), carried: r4(Math.max(0, Number(json.carried) || 0)), pass: !!(json.pass && (json.pass === true || json.pass.active)), day: json.day || ctDay(), capHit: json.capHit || null, enforced: json.enforced !== false, repeat: !!json.repeat, suspended: !!json.suspended, lifetimeHit: !!json.lifetimeHit, freeLifetime: Number(json.freeLifetime) || 0, waiting: r4(Math.max(0, Number(json.waiting) || 0)), retry: false }; rememberPass(body.memberId, body.email, json.pass, json.passUntil || (json.pass && json.pass.until)); return out; } catch (e) { return { allowed: 0, deferred: 0, carried: 0, pass: false, retry: true, error: String(e && e.message || e).slice(0, 120) }; } @@ -103,6 +103,12 @@ function note(resp, kind, nominal) { nominal = r4(nominal); if (!resp) return null; if (resp.retry) return 'Your reward is recorded and pays as soon as InstantAdPay confirms it.'; + // the free allowance is used up (Marty 2026-11-03): only the Game Pass pays from here, so say so, and what is waiting for them + if (resp.lifetimeHit && !resp.pass) { + const cap = resp.freeLifetime ? r4(resp.freeLifetime) + ' POL' : 'POL'; + const wait = kind === 'progress' && resp.waiting > 0 ? ' Your ' + r4(resp.waiting) + ' POL earned since is saved and pays out with the Pass.' : ''; + return 'You have used your free ' + cap + ' in the games. Get the Game Pass to keep earning.' + wait; + } if (kind === 'progress' && resp.deferred > 0) return resp.deferred + ' POL is yours; it pays out over the next days (daily cap).'; if (kind === 'daily' && resp.allowed + 1e-9 < nominal) return resp.pass ? 'Daily cap reached for today.' : 'Daily cap reached for today. Get the Pass for a higher cap.'; return null;