Stack POL Pro: ANY $10+ package unlocks it automatically (Marty 2026-11-09: "Any $10 package or higher unlocks it"). No Get Pro order step; the member's own on-chain package of $10+ switches Pro on for good, rides along with a Game Pass or hero order the same package fulfils (never takes it from them), only packages from the Pro launch (21:30 UTC) count, credits never. Promo tools shows Buy a $10+ package; chatbot updated; my.js ?v=20261109pro4; qa/stackpro rewritten (11 pass).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-09 16:40:48 -06:00
parent 1da37f05ab
commit 87ea24b8f0
5 changed files with 35 additions and 33 deletions
+19 -5
View File
@@ -287,6 +287,18 @@ function grantStackProForPackage(email, tx, cents, buyerId, note) {
console.log('stack pro granted for package', e, tx, cents, 'cents');
return { ok: true, pro: true };
}
// Marty 2026-11-09 (evening): "Any $10 package or higher unlocks it". No Get Pro step: the member's own package purchase of $10 or more,
// on chain, switches Pro on for good. Still new money only (credits never reach onEvent). Only packages from the Pro launch on count
// (a reindex of older history never hands it out). A Pro order left waiting from the first version is closed as paid by the same tx.
const PRO_START = Date.parse('2026-11-09T21:30:00Z');
function proFromPackage(e, ev, cents) {
if (cents < STACK_PRO_CENTS || stackpro.get(e)) return false;
const t = (ev.devNow && !R.isProd) ? Number(ev.devNow) : (ev.ts || Date.now()); if (t < PRO_START) return false;
stackpro.set(e, { ts: t, via: 'package', tx: ev.tx, cents, buyerId: Number(ev.buyerId) || 0 });
for (const o of stackOrders(e)) orders.set(o.order, Object.assign({}, orders.get(o.order), { status: 'paid', tx: ev.tx, cents, paidAt: Date.now(), buyerId: Number(ev.buyerId) || 0 }));
console.log('stack pro unlocked by package', e, 'tx', String(ev.tx).slice(0, 12), cents, 'cents');
return true;
}
function stackProOwners() { return [...stackpro.keys()]; }
// A package purchase landing on chain fulfils one of this account's waiting orders: the highest-priced one the package covers.
@@ -320,13 +332,15 @@ async function onEvent(ev) {
const c = cfg(); const cents = ev.priceCents || 0;
if (!TIERS.some(k => cents >= c.tiers[k].price) && !heroOrderPrices(c).some(x => cents >= x) && cents < STACK_PRO_CENTS) return null;
const e = await ownerOf(ev); if (!e) return null;
if (!waitingOrders(e).length && !heroOrders(e).length && !stackOrders(e).length) return null;
if (txUsed(ev.tx)) return null; // each purchase counts once, everywhere
const pro = proFromPackage(e, ev, cents); // any $10+ package unlocks Stack POL Pro; it rides along, never takes the package from an order
const withPro = r => pro ? Object.assign(r || {}, { stackPro: true, email: e }) : r;
if (!waitingOrders(e).length && !heroOrders(e).length) return withPro(null);
if (txUsed(ev.tx)) return withPro(null); // each purchase counts once, everywhere
const at = await minedAt(ev);
// one package fulfils ONE order, pass or bonus hero (2026-11-05): the highest-priced one it covers, then the oldest
const all = waitingOrders(e).map(o => Object.assign({ price: c.tiers[o.tier].price }, o)).concat(heroOrders(e).filter(o => heroOrderOpen(e, o.hero)).map(o => Object.assign({ price: heroOrderPrice(c, o.hero) }, o))).concat(stackpro.get(e) ? [] : stackOrders(e).map(o => Object.assign({ price: STACK_PRO_CENTS }, o)));
const w = all.filter(o => cents >= o.price && at + ORDER_SKEW_MS >= o.ts).sort((x, y) => y.price - x.price || x.ts - y.ts)[0];
if (!w) { console.log('gamepass: package', String(ev.tx).slice(0, 12), 'by', e, 'fulfils no order (bought before the order or too small)'); return null; }
if (!w) { console.log('gamepass: package', String(ev.tx).slice(0, 12), 'by', e, 'fulfils no order (bought before the order or too small)'); return withPro(null); }
if (w.kind === 'stackpro') {
orders.set(w.order, Object.assign({}, orders.get(w.order), { status: 'paid', tx: ev.tx, cents, paidAt: Date.now(), minedAt: at, buyerId: Number(ev.buyerId) || 0 }));
stackpro.set(e, { ts: (ev.devNow && !R.isProd) ? Number(ev.devNow) : (ev.ts || Date.now()), via: 'package', tx: ev.tx, cents, order: w.order, buyerId: Number(ev.buyerId) || 0 });
@@ -337,12 +351,12 @@ async function onEvent(ev) {
orders.set(w.order, Object.assign({}, orders.get(w.order), { status: 'paid', tx: ev.tx, cents, paidAt: Date.now(), minedAt: at, buyerId: Number(ev.buyerId) || 0 }));
const g = grantHeroes(e, w.hero, 'package', { tx: ev.tx, cents, order: w.order, buyerId: Number(ev.buyerId) || 0, usd: heroOrderPrice(c, w.hero) / 100, packageUsd: cents / 100 }, (ev.devNow && !R.isProd) ? Number(ev.devNow) : (ev.ts || Date.now()));
console.log('bonus heroes fulfilled by package', w.hero, e, 'tx', String(ev.tx).slice(0, 12), cents, 'cents:', g.heroes.join(','));
return { order: w.order, hero: w.hero, heroes: g.heroes };
return withPro({ order: w.order, hero: w.hero, heroes: g.heroes });
}
orders.set(w.order, Object.assign({}, orders.get(w.order), { status: 'paid', tx: ev.tx, cents, paidAt: Date.now(), minedAt: at, buyerId: Number(ev.buyerId) || 0 }));
const x = extend(e, 'package', { tx: ev.tx, cents, order: w.order, buyerId: Number(ev.buyerId) || 0, usd: c.tiers[w.tier].price / 100, packageUsd: cents / 100 }, (ev.devNow && !R.isProd) ? Number(ev.devNow) : (ev.ts || Date.now()), w.tier);
console.log('gamepass fulfilled by package', w.tier, e, 'tx', String(ev.tx).slice(0, 12), cents, 'cents, until', new Date(x.until).toISOString());
return { order: w.order, until: x.until, tier: w.tier };
return withPro({ order: w.order, until: x.until, tier: w.tier });
}
// ---- bonus heroes (2026-11-05) ----