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:
+3
-2
@@ -96,9 +96,9 @@ async function events(me, runId, t, list, wantGoal) { // async since the Game Pa
|
||||
if (out.chapDrips < out.goal) { res.cleared = null; res.short = out.goal - out.chapDrips; return res; }
|
||||
const ch = out.chapter; const p = player(me.memberId);
|
||||
const first = !(p.cleared || {})[ch];
|
||||
// a guest earns nothing (Marty 2026-11-02): the clear counts as progress and follows them when they sign in, the POL does not
|
||||
const grant = me.guest ? { pol: 0, reason: 'guest' } : await ledger.chapterDripGated(me, ch, first && !out.flagged);
|
||||
if (first && out.flagged) grant.reason = 'flagged';
|
||||
if (me.guest && first && !out.flagged) updPlayer(me.memberId, x => { x.pending = Array.from(new Set([...(x.pending || []), ch])); }); // paid when they sign in
|
||||
updPlayer(me.memberId, x => { x.cleared[ch] = true; if (x.chapter <= ch) x.chapter = ch + 1; });
|
||||
updRun(runId, x => { x.cleared.push(ch); x.chapter = ch + 1; x.chapDrips = 0; x.goal = spawn.goalFor(ch + 1); });
|
||||
res.cleared = { chapter: ch, first, pol: grant.pol, reason: grant.reason, note: grant.note || null, next: ch + 1, nextGoal: spawn.goalFor(ch + 1), playTime: Math.round(out.t) }; // note = the Game Pass truth
|
||||
@@ -138,7 +138,8 @@ function buy(me, item) {
|
||||
return { error: 'No such item.' };
|
||||
}
|
||||
// Move everything one id owns onto another (a guest who signs in, or a wallet-less member who links a wallet).
|
||||
// Returns the chapters the old id cleared as a guest that the new id has never cleared: the caller pays those.
|
||||
// Returns the chapters the old id cleared as a guest that the new id has never cleared. Since 2026-11-02 nobody pays those
|
||||
// (guests earn nothing; the progress carries, the POL does not); the list is informational.
|
||||
function adopt(fromId, toId) {
|
||||
fromId = Number(fromId); toId = Number(toId); if (!fromId || fromId === toId) return { moved: false, pending: [] };
|
||||
const all = store.read('players', {}); const a = all[String(fromId)]; if (!a) return { moved: false, pending: [] };
|
||||
|
||||
+33
-14
@@ -25,7 +25,11 @@ const DEFAULTS = {
|
||||
itemPol: { shield: 0.05, slow: 0.03 }, // hangar items paid from the POL balance (the sink)
|
||||
itemDrips: { magnet: 250, ship: 600 }, // hangar items paid in drips (never money)
|
||||
refSharePct: 10, // the referrer's slice of each refuel's pool income (their referrals' refuels), paid into the referrer's game balance
|
||||
testers: [], // emails or member ids allowed through the hand-off while signups = 'testers'
|
||||
// the free tier (Marty 2026-11-02, every game must fund itself): a free InstantAdPay account earns freeSharePct of the chapter
|
||||
// drip; Game Pass holders earn the full table (the Pass is the purchase that funds the game); guests earn nothing. With
|
||||
// GAMEPASS off there is no pass to buy, so everyone counts as a pass holder
|
||||
freeSharePct: 25,
|
||||
testers: [], // emails or member ids allowed through the hand-off while signups = 'testers'
|
||||
trial: true, // posts say 'coming soon, in testing' and 'would have earned' until Marty flips it
|
||||
signups: 'testers' // 'testers' | 'key' (tester list or the curtain pass) | 'open' | 'closed'
|
||||
};
|
||||
@@ -79,10 +83,12 @@ function refuelsToday() { const d = ctDay(); return store.read('refuels', []).fi
|
||||
function account(memberId) { return Object.assign({ memberId: Number(memberId), unpaid: 0, paidTotal: 0, spentTotal: 0, earnedTotal: 0 }, store.read('accounts', {})[String(memberId)] || {}); }
|
||||
function updAccount(memberId, fn) { return store.update('accounts', {}, all => { const a = Object.assign({ memberId: Number(memberId), unpaid: 0, paidTotal: 0, spentTotal: 0, earnedTotal: 0 }, all[String(memberId)] || {}); fn(a); a.unpaid = r4(a.unpaid); all[String(memberId)] = a; return all; })[String(memberId)]; }
|
||||
|
||||
// a first-time chapter clear. eligible=false means a replay or a flagged run: cleared, unpaid.
|
||||
// a first-time chapter clear. eligible=false means a replay or a flagged run: cleared, unpaid. A guest earns nothing (2026-11-02).
|
||||
function chapterDrip(me, chapter, eligible) {
|
||||
const s = settings(); const pol = r4(Number(s.dripPol));
|
||||
if (me && me.guest) return { pol: 0, reason: 'guest' };
|
||||
const full = fullTier(me), pol = dripFor(me);
|
||||
if (!eligible) return { pol: 0, reason: 'replay' };
|
||||
if (!(pol > 0)) return { pol: 0, reason: 'none' };
|
||||
const p = pool();
|
||||
if (p.capLeft < pol) return { pol: 0, reason: 'cap' };
|
||||
if (p.available < pol) return { pol: 0, reason: 'pool' };
|
||||
@@ -90,7 +96,7 @@ function chapterDrip(me, chapter, eligible) {
|
||||
store.update('drips', [], all => { all.push(row); return all; });
|
||||
poolAdd('out', pol);
|
||||
updAccount(me.memberId, a => { a.unpaid += pol; a.earnedTotal = r4((a.earnedTotal || 0) + pol); a.wallet = me.wallet || a.wallet || null; a.username = me.username || a.username || null; });
|
||||
return { pol, reason: 'paid', id: row.id };
|
||||
return freeNoted(full, { pol, reason: 'paid', id: row.id });
|
||||
}
|
||||
|
||||
// the sink: a hangar item paid from the member's unpaid POL balance goes back to the pool
|
||||
@@ -113,9 +119,20 @@ const gp = require('./polgrant');
|
||||
const kindOf = key => 'progress'; // refs: chapter:<n>
|
||||
const iapId = me => Number(me.memberId) > 0 ? Number(me.memberId) : 0;
|
||||
const passActive = me => !!(gp.on() && me && !me.guest && gp.passOf(iapId(me), me.email).active);
|
||||
// the tiers (Marty 2026-11-02): guests earn nothing; a free InstantAdPay account earns freeSharePct of the table; Game Pass
|
||||
// holders earn the full table. With GAMEPASS off there is no pass to buy, so every signed-in player is on the full tier.
|
||||
const fullTier = me => !gp.on() || passActive(me);
|
||||
const tierOf = me => (!me || me.guest) ? 'guest' : fullTier(me) ? 'full' : 'free';
|
||||
function freeShare() { const v = Number(settings().freeSharePct); return Number.isFinite(v) ? Math.max(0, Math.min(100, v)) : Number(DEFAULTS.freeSharePct); }
|
||||
// what one first clear pays this player: the table for the full tier, freeSharePct of it for a free account (4 decimals)
|
||||
function dripFor(me) { const full = r4(Number(settings().dripPol)); return fullTier(me) ? full : r4(full * freeShare() / 100); }
|
||||
const FREE_NOTE = 'Game Pass holders earn the full amount.';
|
||||
// a reward that was scaled to the free share carries the note the client already shows (deferred / recorded notes stay in front).
|
||||
// full = the tier at quote time: a grant answer re-records the pass flag, so the tier is read once, before IAP is asked
|
||||
function freeNoted(full, res) { if (res && !full && (res.pol > 0 || res.reason === 'deferred' || res.reason === 'iap')) res.note = (res.note ? res.note + ' ' : '') + FREE_NOTE; return res; }
|
||||
// the same checks as chapterDrip() up to (not including) the ledger write -> { pol, key, chapter } or { pol: 0, reason }
|
||||
function quote(me, chapter, eligible) {
|
||||
const s = settings(); const pol = r4(Number(s.dripPol));
|
||||
const pol = dripFor(me);
|
||||
if (!eligible) return { pol: 0, reason: 'replay' };
|
||||
if (!(pol > 0)) return { pol: 0, reason: 'none' };
|
||||
const p = pool(); if (p.capLeft < pol) return { pol: 0, reason: 'cap' }; if (p.available < pol) return { pol: 0, reason: 'pool' };
|
||||
@@ -131,17 +148,19 @@ function settleGrant(me, q, r, gkind) {
|
||||
updAccount(me.memberId, a => { a.unpaid += allowed; a.earnedTotal = r4((a.earnedTotal || 0) + allowed); a.wallet = me.wallet || a.wallet || null; a.username = me.username || a.username || null; a.email = me.email || a.email || null; a.gpOwed = r4(Math.max(0, (a.gpOwed || 0) + (Number(r.deferred) || 0) - extra)); });
|
||||
return { pol: allowed, reason: allowed > 0 ? 'paid' : (gkind === 'daily' ? 'capday' : 'deferred'), nominal: q.pol, deferred: r4(r.deferred || 0), pass: !!r.pass, note: gp.note(r, gkind, q.pol), id: row.id };
|
||||
}
|
||||
// chapterDrip() with IAP in front of it. Switch off, or a guest: the plain chapterDrip, unchanged. Fail closed: no answer from
|
||||
// IAP = nothing paid now, the ref queued and retried (polgrant.js), the player told it is recorded.
|
||||
// chapterDrip() with IAP in front of it. Switch off: the plain chapterDrip, unchanged. A guest earns nothing, on either path
|
||||
// (2026-11-02). Fail closed: no answer from IAP = nothing paid now, the ref queued and retried (polgrant.js), the player told
|
||||
// it is recorded. A free account's quote is already the scaled amount (dripFor), so IAP's caps see the taste, not the table.
|
||||
async function chapterDripGated(me, chapter, eligible) {
|
||||
if (!gp.on() || me.guest || !gp.whoOf(iapId(me), me.email)) return chapterDrip(me, chapter, eligible);
|
||||
const q = quote(me, chapter, eligible); if (q.reason) return q;
|
||||
if (gp.queued(iapId(me), me.email, q.key)) return { pol: 0, reason: 'iap', nominal: q.pol };
|
||||
if (me && me.guest) return { pol: 0, reason: 'guest' };
|
||||
if (!gp.on() || !gp.whoOf(iapId(me), me.email)) return chapterDrip(me, chapter, eligible);
|
||||
const full = fullTier(me), q = quote(me, chapter, eligible); if (q.reason) return q;
|
||||
if (gp.queued(iapId(me), me.email, q.key)) return freeNoted(full, { pol: 0, reason: 'iap', nominal: q.pol });
|
||||
const gkind = kindOf(q.key), r = await gp.grant({ memberId: iapId(me), email: me.email, kind: gkind, pol: q.pol, ref: q.key });
|
||||
if (r.retry) { gp.enqueue({ memberId: iapId(me), email: me.email, ref: q.key, kind: gkind, pol: q.pol, me: { memberId: Number(me.memberId), username: me.username || null, wallet: me.wallet || null, email: me.email || null }, q }); return { pol: 0, reason: 'iap', nominal: q.pol, note: gp.note(r, gkind, q.pol) }; }
|
||||
return settleGrant(me, q, r, gkind);
|
||||
if (r.retry) { gp.enqueue({ memberId: iapId(me), email: me.email, ref: q.key, kind: gkind, pol: q.pol, me: { memberId: Number(me.memberId), username: me.username || null, wallet: me.wallet || null, email: me.email || null }, q, full }); return freeNoted(full, { pol: 0, reason: 'iap', nominal: q.pol, note: gp.note(r, gkind, q.pol) }); }
|
||||
return freeNoted(full, settleGrant(me, q, r, gkind));
|
||||
}
|
||||
const payQueued = (item, r) => settleGrant(item.me, item.q, r, item.kind); // a queued ref finally answered
|
||||
const payQueued = (item, r) => freeNoted(item.full !== false, settleGrant(item.me, item.q, r, item.kind)); // a queued ref finally answered (full = the tier when it was quoted)
|
||||
// once a Central day per account IAP still owes: a zero-POL progress call collects the carry-forward (IAP folds it into `allowed`)
|
||||
async function carrySweep() {
|
||||
if (!gp.on()) return 0; const today = ctDay(), accts = store.read('accounts', {}); let got = 0;
|
||||
@@ -195,4 +214,4 @@ function balance(memberId) {
|
||||
return { unpaid: r4(a.unpaid), paidTotal: r4(a.paidTotal || 0), spentTotal: r4(a.spentTotal || 0), earnedTotal: r4(a.earnedTotal || 0), refTotal: r4(a.refTotal || 0), refSharePct: Number(s.refSharePct) || 0, threshold: Number(s.thresholdPol), history: hist, wallet: a.wallet || null };
|
||||
}
|
||||
|
||||
module.exports = { DEFAULTS, settings, setSettings, ctDay, pool, refuel, refuelsToday, account, chapterDrip, chapterDripGated, quote, settleGrant, kindOf, passActive, iapId, payQueued, carrySweep, gp, spend, sweep, payable, mark, balance, usdPerPol, r4 };
|
||||
module.exports = { DEFAULTS, settings, setSettings, ctDay, pool, refuel, refuelsToday, account, chapterDrip, chapterDripGated, quote, settleGrant, kindOf, passActive, fullTier, tierOf, freeShare, dripFor, FREE_NOTE, iapId, payQueued, carrySweep, gp, spend, sweep, payable, mark, balance, usdPerPol, r4 };
|
||||
|
||||
Reference in New Issue
Block a user