Pass tiers restructure (Dallas, Marty approved 2026-10-22): Explorer $19.99 (1999 credits) and Champion $39.99 (3999) for 30 days, new Sovereign $99.99 (9999, 30 days) and Legend $249.99 (24999, 365 days, the yearly pass). One table (gamepass.js TIER_DEFS: rank, names, settings stem, defaults, member-card perks); settings gamePassSovereign*/gamePassLegend* with kill switches; flag()/partner player/hand-off token carry sovereign/legend; buy, waiting orders ($100/$250 package copy), extend from max(now, until), comp/revoke, admin By pass tier table and comp options; chatbot tier fact says coming soon while sovTiers is off. All behind sovTiers (still 0): weekly Game Pass price, length and caps unchanged. Tests: sov-passes store + local extended (all pass), member QA 0 bugs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-22 10:26:58 -05:00
parent 32eefae473
commit 839c867595
11 changed files with 259 additions and 77 deletions
+35 -16
View File
@@ -20,6 +20,9 @@
// `until` as the weekly tier). flag().tier = the highest active tier. Explorer/Champion sales sit behind the site switch
// `sovTiers` (default off; only ADMIN_EMAIL can see and buy them while it is off). No proration, no auto-renew: buying again
// extends that tier from max(now, until).
// 2026-10-22 (Dallas's structure, Marty approved): Explorer $19.99 and Champion $39.99 (30 days), plus Sovereign $99.99 (30 days)
// and Legend $249.99 (365 days, the yearly pass), all in TIER_DEFS below and all behind the same sovTiers switch. The weekly
// pass is unchanged ($5 / 7 days / the same caps). Rank weekly < explorer < champion < sovereign < legend.
'use strict';
const fs = require('fs');
const path = require('path');
@@ -29,8 +32,26 @@ const GAMES = ['polhunter', 'gemkingdom', 'spellwheel', 'spookydoors', 'polywarr
const NAMES = { polhunter: 'PolHunter', gemkingdom: 'Gem Kingdom', spellwheel: 'SpellWheel', spookydoors: 'Spooky Doors', polywarriors: 'PolyWarriors', clutterhunt: 'ClutterHunt', polybreak: 'PolyBreak', driprunner: 'Drip Runner', roadagent: 'Road Agent', shardsofvalor: 'Shards of Valor' };
const SHARES = [0.5, 0.3, 0.2]; // tournament prize split, places 1-3
const KEEP_DAYS = 90; // answered refs and day rows are kept this long (idempotency window)
const TIERS = ['weekly', 'explorer', 'champion']; // lowest to highest
const TIER_NAMES = { weekly: 'Game Pass', explorer: 'Explorer', champion: 'Champion' };
// THE pass table (2026-10-22, Dallas's structure, Marty approved): lowest to highest, a higher tier includes everything below.
// Rename a tier here (name) and nowhere else: the member card, the admin pane, the charge label and the chatbot read it from here.
// key = the wire value the games read (flag().tier / tiers); set = the Admin > Settings stem (gamePass<set>Enabled /
// PriceCredits / Days; weekly keeps its original gamePassPriceCredits / gamePassDays); price = purchased-grade credits (100 = $1);
// perks = what the member card lists. Every tier is a Game Pass holder everywhere with the SAME caps (no extra POL).
const TIER_DEFS = [
{ key: 'weekly', name: 'Game Pass', set: '', price: 500, days: 7,
perks: ['Higher daily POL caps in every game', 'A seat in the weekly Pass Tournament', 'Extra plays and a perk in each game', 'Shards of Valor: the Sunless Vault and weapons unlocked'] },
{ key: 'explorer', name: 'Explorer', set: 'Explorer', price: 1999, days: 30,
perks: ['Everything in the Game Pass, in every game', 'Shards of Valor: weapons and gear unlocked', 'Shards of Valor: 2 bonus islands'] },
{ key: 'champion', name: 'Champion', set: 'Champion', price: 3999, days: 30,
perks: ['Everything in Explorer', 'Shards of Valor: 4 bonus islands of your choice', 'Shards of Valor: the Druid hero', 'Shards of Valor: level cap 30'] },
{ key: 'sovereign', name: 'Sovereign', set: 'Sovereign', price: 9999, days: 30,
perks: ['Everything in Champion', 'Shards of Valor: every bonus island', 'Shards of Valor: the Necromancer hero', 'Shards of Valor: level cap 40'] },
{ key: 'legend', name: 'Legend', set: 'Legend', price: 24999, days: 365,
perks: ['Everything in Sovereign, for a full year', 'Shards of Valor: every bonus island', 'Shards of Valor: every hero, the Archer included', 'Shards of Valor: level cap 40'] },
];
const TIERS = TIER_DEFS.map(d => d.key); // lowest to highest
const TIER_NAMES = Object.fromEntries(TIER_DEFS.map(d => [d.key, d.name]));
const TIER_DEF = Object.fromEntries(TIER_DEFS.map(d => [d.key, d]));
const tierOk = t => TIERS.includes(t);
const rowTier = b => (b && tierOk(b.tier)) ? b.tier : 'weekly'; // bought rows before 2026-10-18 have no tier: weekly
const r6 = x => Math.round((Number(x) || 0) * 1e6) / 1e6;
@@ -63,14 +84,12 @@ function cfg() {
return {
enabled: on('gamePassEnabled'),
price, days,
// per tier: price in purchased-grade credits (100 = $1), length, and whether it is on sale. Explorer/Champion need the master
// switch sovTiers AND the weekly pass switched on; their own gamePass<Tier>Enabled is a kill switch (missing = on).
// per tier: price in purchased-grade credits (100 = $1), length, and whether it is on sale. Every tier above weekly needs the
// master switch sovTiers AND the weekly pass switched on; its own gamePass<Set>Enabled is a kill switch (missing = on).
tierSales: on('sovTiers'),
tiers: {
weekly: { price, days, sale: on('gamePassEnabled') },
explorer: { price: Math.max(1, Math.round(n('gamePassExplorerPriceCredits', 2000))), days: Math.max(1, Math.round(n('gamePassExplorerDays', 30))), sale: on('gamePassEnabled') && on('sovTiers') && !offExplicit('gamePassExplorerEnabled') },
champion: { price: Math.max(1, Math.round(n('gamePassChampionPriceCredits', 4000))), days: Math.max(1, Math.round(n('gamePassChampionDays', 30))), sale: on('gamePassEnabled') && on('sovTiers') && !offExplicit('gamePassChampionEnabled') },
},
tiers: Object.fromEntries(TIER_DEFS.map(d => [d.key, d.key === 'weekly' ? { price, days, sale: on('gamePassEnabled') }
: { price: Math.max(1, Math.round(n('gamePass' + d.set + 'PriceCredits', d.price))), days: Math.max(1, Math.round(n('gamePass' + d.set + 'Days', d.days))),
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)) },
pass: { daily: Math.max(0, n('capPassDaily', 1.50)), total: Math.max(0, n('capPassTotal', 5.0)) },
@@ -150,20 +169,20 @@ function revoke(email, tier, why, now) {
passes.set(e, writeTiers(p, T, { revokes: [{ ts: t, tier, why: String(why || 'support').slice(0, 80), was }].concat(p.revokes || []).slice(0, 50) }));
return { ok: true, tier, was, until: t };
}
// on sale for this viewer: the tier's own switch, or the admin account testing Explorer/Champion while sovTiers is off
// on sale for this viewer: the tier's own switch, or the admin account testing the tiers above weekly while sovTiers is off
const tierOpen = (c, tier, admin) => !!(c.tiers[tier].sale || (admin && tier !== 'weekly'));
const PACKAGE_USD = [5, 10, 20, 50, 100, 250, 500]; // copy only: the package that covers a price
const packageFor = usd => PACKAGE_USD.find(x => x >= usd) || usd;
// GET /api/my/gamepass. opts.admin = the ADMIN_EMAIL account (sees Explorer/Champion while sovTiers is off).
// GET /api/my/gamepass. opts.admin = the ADMIN_EMAIL account (sees every tier while sovTiers is off).
function view(email, now, opts) {
const e = String(email || '').toLowerCase(); const c = cfg(); const t = now || Date.now(); const f = flag(e, t); const p = rec(e); const w = waitingOrder(e, 'weekly');
const admin = !!(opts && opts.admin); const T = tiersOf(p);
const caps = capsFor(e, t);
// the tier rows this member sees: weekly always; Explorer/Champion while on sale, to the admin, or to a current holder (holders
// the tier rows this member sees: weekly always; a higher tier while on sale, to the admin, or to a current holder (holders
// keep their pass when a sale is switched off, they just cannot buy more)
const passRows = TIERS.filter(k => k === 'weekly' || c.tiers[k].sale || admin || T[k] > t).map(k => {
const tc = c.tiers[k]; return { tier: k, name: TIER_NAMES[k], price: tc.price, usd: tc.price / 100, days: tc.days, package: packageFor(tc.price / 100),
const tc = c.tiers[k]; return { tier: k, name: TIER_NAMES[k], perks: TIER_DEF[k].perks, price: tc.price, usd: tc.price / 100, days: tc.days, package: packageFor(tc.price / 100),
active: T[k] > t, until: T[k] > t ? T[k] : null, waiting: !!waitingOrder(e, k), open: k === 'weekly' ? c.enabled : tierOpen(c, k, admin) };
});
const tiered = passRows.some(r => r.tier !== 'weekly');
@@ -290,13 +309,13 @@ function voidGrant(o) {
// ---- the weekly Pass Tournament (Monday 9 AM Central, the week that just closed) ----
function nextTournamentAt(now) { const t = now || Date.now(); const ws = weekStart(t); const thisMon = ws + 9 * 3600000; return t < thisMon ? thisMon : ws + 7 * 86400000 + 9 * 3600000; }
function holdersIn(start, end) { // any tier holds a Pass Tournament seat (Explorer and Champion include everything Weekly gives)
function holdersIn(start, end) { // any tier holds a Pass Tournament seat (every tier above weekly includes everything Weekly gives)
const out = [];
for (const [e, p] of passes) { if (!p || !(Math.max(...TIERS.map(k => tiersOf(p)[k])) > start)) continue; if ((p.bought || []).some(b => b.ts < end)) out.push(e); }
return out;
}
const isSale = b => b && b.via !== 'admin'; // comps are passes, not sales
// the pool counts weekly pass sales only, unless passTournamentTierSales adds Explorer/Champion sales (default off: the pool exactly as before tiers)
// the pool counts weekly pass sales only, unless passTournamentTierSales adds the sales of every tier above weekly (default off: the pool exactly as before tiers)
function salesIn(start, end, withTiers) { let n = 0, usd = 0; for (const [, p] of passes) for (const b of (p && p.bought) || []) if (isSale(b) && b.ts >= start && b.ts < end && (withTiers || rowTier(b) === 'weekly')) { n += 1; usd += Number(b.usd) || 0; } return { n, usd: Math.round(usd * 100) / 100 }; }
function scoresFor(wk, emails) {
return emails.map(e => { const M = L.members[e]; const g = (M && M.weeks[wk]) || {}; const score = Object.values(g).reduce((n, x) => n + x, 0); const first = ((passes.get(e) || {}).bought || []).reduce((m, b) => Math.min(m, b.ts), Infinity);
@@ -422,5 +441,5 @@ function prune(now) {
return n;
}
module.exports = { init, cfg, GAMES, NAMES, TIERS, TIER_NAMES, flag, view, buy, comp, revoke, onEvent, capsFor, grant, voidGrant, tournamentTick, runTournament, pending, markPaid, adminStats, prune, weekStart, dayKey,
module.exports = { init, cfg, GAMES, NAMES, TIERS, TIER_NAMES, TIER_DEFS, flag, view, buy, comp, revoke, onEvent, capsFor, grant, voidGrant, tournamentTick, runTournament, pending, markPaid, adminStats, prune, weekStart, dayKey,
_ledger: () => L };