Free allowance across the games (Marty 2026-11-02, "cap these so if they want to keep playing they spend a tiny amount"): an account with no Game Pass receives at most capFreeLifetime POL of game rewards ever, across every game (2 POL default, site setting). After that a free account's room for the day is zero: progress rewards defer until a pass is active, repeatable rewards drop, carry waits too. Grant answers and partner caps carry lifetimeHit / freeUsed / lifetime; chatbot facts; QA block for the allowance

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-02 17:01:27 -06:00
parent 7f3f057db0
commit c6b4a84abc
4 changed files with 34 additions and 6 deletions
+13 -2
View File
@@ -101,6 +101,10 @@ function cfg() {
sale: on('gamePassEnabled') && on('sovTiers') && !offExplicit('gamePass' + d.set + 'Enabled') }])),
tournamentTierSales: on('passTournamentTierSales'), // off: only weekly pass sales feed the Pass Tournament pool (exactly as before tiers)
free: { daily: Math.max(0, n('capFreeDaily', 0.30)), total: Math.max(0, n('capFreeTotal', 2.0)) },
// the free allowance (Marty 2026-11-02, "cap these so that if the user wants to keep playing they spend a tiny amount"):
// the most game POL an account EVER receives while it holds no pass, across every game. After that, progress rewards
// wait as deferred until a pass is active and repeatable rewards are dropped. 2 POL default; admin key capFreeLifetime.
freeLifetime: Math.max(0, n('capFreeLifetime', 2.0)),
pass: { daily: Math.max(0, n('capPassDaily', 1.50)), total: Math.max(0, n('capPassTotal', 5.0)) },
start: /^\d{4}-\d{2}-\d{2}$/.test(start) ? start : '',
pct: Math.max(0, n('passTournamentPct', 5)),
@@ -279,6 +283,7 @@ function capsFor(email, now, game) {
const lim = pass ? c.pass : c.free; const M = L.members[e]; const D = M && M.days[day];
const used = { daily: r6(D ? D.daily : 0), total: r6(D ? D.total : 0) };
const out = { daily: lim.daily, total: lim.total, used, day, enforced: enforcedOn(c, day), pass };
out.lifetime = { cap: c.freeLifetime, used: r6(M && M.freeTotal != null ? M.freeTotal : (M ? Object.values(M.days).reduce((n, d) => n + ((d.tier && d.tier.free && d.tier.free.allowed) || 0), 0) : 0)) }; // the free allowance, what has been used of it
if (game && M) out.pending = r6((M.deferred[game] || []).reduce((n, x) => n + x.left, 0));
return out;
}
@@ -294,6 +299,11 @@ function grant(o) {
const c = cfg(); const pass = flag(e, t).active; const lim = pass ? c.pass : c.free; const enforced = enforcedOn(c, day);
const M = member(e); const D = dayRow(M, day); const tier = D.tier[pass ? 'pass' : 'free'];
let totalRem = Math.max(0, r6(lim.total - D.total)), dailyRem = Math.max(0, r6(lim.daily - D.daily));
// the free allowance: a running total of what this account received while it held no pass (seeded once from the day rows
// still on file); once it reaches freeLifetime, a free account's room for today is zero, carry included
if (M.freeTotal == null) M.freeTotal = r6(Object.values(M.days).reduce((n, d) => n + ((d.tier && d.tier.free && d.tier.free.allowed) || 0), 0));
let lifetimeHit = false;
if (!pass && enforced) { const room = Math.max(0, r6(c.freeLifetime - M.freeTotal)); if (room < totalRem) totalRem = room; lifetimeHit = room < pol; } // hit = the allowance, not the day, is what trims this grant
// carry-forward: progress POL deferred on an EARLIER day for this game is paid first, inside today's total cap
let carried = 0; const q = M.deferred[game] || [];
for (const d of q) {
@@ -319,12 +329,13 @@ function grant(o) {
}
if (kind === 'daily') D.daily = r6(D.daily + allowed);
D.total = r6(D.total + allowed); tier.allowed = r6(tier.allowed + allowed); D.grants += 1;
if (!pass) M.freeTotal = r6((M.freeTotal || 0) + allowed + carried); // counts toward the free allowance only while no pass is held
// tournament activity: one point per reported grant (progress and daily weigh the same)
if (pol > 0) { const wk = weekKey(t); M.weeks[wk] = M.weeks[wk] || {}; M.weeks[wk][game] = (M.weeks[wk][game] || 0) + 1; }
if (capHit) { const p = passes.get(e) || { until: 0, bought: [] }; passes.set(e, Object.assign({}, p, { lastCapHit: { ts: t, day, game, kind: capHit, pass } })); }
const out = { allowed: r6(carried + allowed), deferred, pass, day, carried, capHit, enforced, kind, pol, email: e, ts: t, own: allowed };
const out = { allowed: r6(carried + allowed), deferred, pass, day, carried, capHit, enforced, kind, pol, email: e, ts: t, own: allowed, lifetimeHit };
L.refs[key] = out; touch();
return { allowed: out.allowed, deferred, pass, day, carried, capHit, enforced, repeat: false };
return { allowed: out.allowed, deferred, pass, day, carried, capHit, enforced, repeat: false, lifetimeHit, freeUsed: r6(M.freeTotal || 0), freeLifetime: c.freeLifetime };
}
// POST /api/partner/polgrant/void: the game decided not to pay after all. Reverses this ref's own share (the carry it triggered