Pass tiers: Explorer ($20/30 days) and Champion ($40/30 days) beside the weekly Game Pass, behind sovTiers (default off, admin-only preview)
Islands and looks in Shards of Valor, never power and never more POL: every tier gets exactly the weekly pass caps and polgrant
still answers pass: true. Per-tier expiry side by side (record.tiers, legacy until mirrors weekly, lazy migration); flag() adds
tier (highest active) and tiers; hand-off token gamePass { active, until, tier }; /api/partner/player pass { active, until, tier,
tiers }. Buy { tier } with purchased credits or a waiting order per tier that a big-enough package fulfils (highest price first,
each tx once). No auto-renew, no proration. Admin: per-tier stats (Central week/month), comp per tier, end-a-tier (refund).
Tournament pool keeps weekly sales only unless passTournamentTierSales. Member card shows three tiers; /my#passes opens it.
Tests: qa/sov-passes-store.cjs, qa/sov-passes-local.mjs (bash qa/run.sh sov-passes). Cache tags my.js/admin.js 20261018tiers.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+8
-4
@@ -520,10 +520,14 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-head"><h3>Comp a pass</h3><span class="sub">support: one pass week, recorded as no sale</span></div>
|
||||
<p style="display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin:0"><input id="gpCompEmail" placeholder="member email" style="max-width:260px"><input id="gpCompWhy" placeholder="why" style="max-width:220px"><button class="btn small" id="gpComp" type="button">Give one pass week</button></p>
|
||||
<div class="card-head"><h3>By pass tier</h3><span class="sub" id="gpTiersSub"></span></div>
|
||||
<div id="gpTiers" class="small">…</div>
|
||||
</div>
|
||||
<p class="small muted">Settings live in Settings › Site settings: gamePassEnabled (1/0), gamePassPriceCredits, gamePassDays, capFreeDaily, capFreeTotal, capPassDaily, capPassTotal, capsStartDate (Central YYYY-MM-DD; empty = caps recorded, not enforced), passTournamentPct, telegramGamesTopicId. Prize POL is paid by the games from their faucets (GET /api/partner/tournament/pending), not from here.</p>
|
||||
<div class="card">
|
||||
<div class="card-head"><h3>Comp a pass</h3><span class="sub">support: one pass period, recorded as no sale</span></div>
|
||||
<p style="display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin:0"><input id="gpCompEmail" placeholder="member email" style="max-width:260px"><select id="gpCompTier"><option value="weekly">Game Pass (weekly)</option><option value="explorer">Explorer (monthly)</option><option value="champion">Champion (monthly)</option></select><input id="gpCompWhy" placeholder="why" style="max-width:220px"><button class="btn small" id="gpComp" type="button">Give one pass period</button><button class="btn small sec" id="gpRevoke" type="button">End this tier now (refund)</button></p>
|
||||
</div>
|
||||
<p class="small muted">Settings live in Settings › Site settings: gamePassEnabled (1/0), gamePassPriceCredits, gamePassDays, capFreeDaily, capFreeTotal, capPassDaily, capPassTotal, capsStartDate (Central YYYY-MM-DD; empty = caps recorded, not enforced), passTournamentPct, telegramGamesTopicId. Monthly tiers: sovTiers (1/0, the Explorer + Champion sale switch; off = only the admin account sees them), gamePassExplorerEnabled / gamePassChampionEnabled (0 stops one tier), gamePassExplorerPriceCredits (2000), gamePassChampionPriceCredits (4000), gamePassExplorerDays / gamePassChampionDays (30), passTournamentTierSales (1 = their sales feed the tournament pool; default 0). Prize POL is paid by the games from their faucets (GET /api/partner/tournament/pending), not from here.</p>
|
||||
</div>
|
||||
|
||||
<div class="pane" id="pane-settings" hidden>
|
||||
@@ -568,6 +572,6 @@
|
||||
</div>
|
||||
|
||||
<script src="/assets/common.js?v=20261016n"></script><script src="/assets/welcome.js?v=20260923b"></script>
|
||||
<script src="/assets/admin.js?v=20261018gp"></script>
|
||||
<script src="/assets/admin.js?v=20261018tiers"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+12
-1
@@ -1159,6 +1159,12 @@
|
||||
+ '<tr><td>Caps: free ' + S.free.daily + ' / ' + S.free.total + ' · pass ' + S.pass.daily + ' / ' + S.pass.total + ' POL (daily play / everything, per day)</td><td class="num">' + S.price + ' credits · ' + S.days + ' days</td></tr>'
|
||||
+ '</table>'
|
||||
+ (Q.byGame && Object.keys(Q.byGame).length ? '<p class="muted" style="margin:8px 0 0">By game: ' + Object.entries(Q.byGame).filter(([k]) => !k.startsWith('plays:')).map(([k, v]) => esc(k) + ' ' + pol(v) + ' POL queued').concat(Object.entries(Q.byGame).filter(([k]) => k.startsWith('plays:')).map(([k, v]) => esc(k.slice(6)) + ' ' + v + ' plays')).join(' · ') + '</p>' : '');
|
||||
// per tier (2026-10-18): active counts each account once, at its highest tier; Central week / month
|
||||
const TS = r.tiers || {}, TC = S.tiers || {};
|
||||
$('gpTiersSub').textContent = 'Explorer + Champion sale: ' + (r.tierSales ? 'ON' : 'OFF (admin preview only)') + ' · ' + (r.week ? r.week.label : '') + ' · month ' + (r.month ? r.month.label : '') + ' · tournament pool ' + (S.tournamentTierSales ? 'includes' : 'excludes') + ' monthly sales';
|
||||
$('gpTiers').innerHTML = '<table class="adm-table"><tr><th>Tier</th><th>Price</th><th class="num">Active</th><th class="num">Sold week</th><th class="num">Sold month</th><th class="num">All time</th><th class="num">Renewals 30d</th><th class="num">Ending in 7 days</th><th class="num">Comped</th><th class="num">Waiting</th></tr>'
|
||||
+ ['weekly', 'explorer', 'champion'].map(k => { const x = TS[k] || {}, c = TC[k] || {}; return '<tr><td style="white-space:nowrap">' + esc(x.name || k) + (c.sale ? '' : '<br><span class="chip flat">not on sale</span>') + '</td><td style="white-space:nowrap">' + (c.price || 0) + ' cr · ' + (c.days || 0) + ' d</td><td class="num">' + (x.active || 0) + '</td><td class="num">' + (x.soldWeek || 0) + ' · ' + usd(x.usdWeek) + '</td><td class="num">' + (x.soldMonth || 0) + ' · ' + usd(x.usdMonth) + '</td><td class="num">' + (x.soldTotal || 0) + ' · ' + usd(x.usdTotal) + '</td><td class="num">' + (x.renewals30d || 0) + '</td><td class="num">' + (x.expiring7d || 0) + '</td><td class="num">' + (x.comped || 0) + '</td><td class="num">' + (x.waitingOrders || 0) + '</td></tr>'; }).join('')
|
||||
+ '</table><p class="muted" style="margin:8px 0 0">Every tier gets the same pass caps (no extra POL). Monthly tiers add Shards of Valor islands and looks only.</p>';
|
||||
$('gpTourSub').textContent = (T.lastRun ? 'last settled ' + when(T.lastRun) : 'never run') + ' · next Monday 9 AM Central (' + when(T.next) + ') · ' + (T.pending || 0) + ' prize' + (T.pending === 1 ? '' : 's') + ' unpaid';
|
||||
const L = T.last;
|
||||
$('gpTour').innerHTML = !L ? '<p class="muted">No week settled yet. The job runs hourly and settles the closed week once Monday 9 AM Central has passed; ' + S.pct + '% of that week\u2019s pass sales becomes the POL prize pool (50 / 30 / 20).</p>'
|
||||
@@ -1167,7 +1173,12 @@
|
||||
+ ((T.history || []).length > 1 ? '<p class="muted" style="margin:8px 0 0">Earlier: ' + T.history.slice(1).map(h => esc(h.label) + ' (' + (h.sales || 0) + ' sold, ' + pol(h.poolPol) + ' POL)').join(' · ') + '</p>' : '');
|
||||
}
|
||||
$('gpTourRun').addEventListener('click', busy($('gpTourRun'), async () => { const r = await api('/api/admin/gamepass/tournament/run', {}); IAP.status('Settled ' + r.label + ': ' + (r.winners || []).length + ' winner(s), pool ' + Number(r.poolPol || 0).toFixed(2) + ' POL.', 'ok'); await loadGamePass(); }));
|
||||
$('gpComp').addEventListener('click', busy($('gpComp'), async () => { const r = await api('/api/admin/gamepass/comp', { email: $('gpCompEmail').value, why: $('gpCompWhy').value }); IAP.status('Pass on ' + r.email + ' until ' + when(r.until) + '.', 'ok'); $('gpCompEmail').value = ''; await loadGamePass(); }));
|
||||
$('gpComp').addEventListener('click', busy($('gpComp'), async () => { const r = await api('/api/admin/gamepass/comp', { email: $('gpCompEmail').value, why: $('gpCompWhy').value, tier: $('gpCompTier').value }); IAP.status((r.tier || 'weekly') + ' pass on ' + r.email + ' until ' + when(r.until) + '.', 'ok'); $('gpCompEmail').value = ''; await loadGamePass(); }));
|
||||
$('gpRevoke').addEventListener('click', busy($('gpRevoke'), async () => {
|
||||
const email = $('gpCompEmail').value.trim(), tier = $('gpCompTier').value; if (!email) { IAP.status('Enter the member email first.', 'bad'); return; }
|
||||
if (!(await IAP.confirmBox('End the ' + tier + ' pass on ' + email + ' now? Use this only for a support refund; it does not return any credits by itself.', { title: 'End a pass tier', ok: 'End it now', cancel: 'Keep it' }))) return;
|
||||
const r = await api('/api/admin/gamepass/revoke', { email, tier, why: $('gpCompWhy').value }); IAP.status(r.tier + ' pass on ' + r.email + ' ended (was until ' + when(r.was) + ').', 'ok'); await loadGamePass();
|
||||
}));
|
||||
|
||||
async function loadSettings() {
|
||||
const [r, s, d] = await Promise.all([api('/api/admin/rates'), api('/api/admin/site'), api('/api/admin/drip')]);
|
||||
|
||||
+52
-3
@@ -651,7 +651,7 @@
|
||||
box.innerHTML = v.eligible
|
||||
? '<b>Welcome from ' + esc(v.game) + '!</b><br><span class="small">Your first package, $5 or more, comes with <b>+' + v.bonus + ' bonus ad credits</b>, and ' + esc(v.perk) + ' waiting for you in ' + esc(v.game) + '.</span>'
|
||||
: '<b>You are a member.</b> <span class="small">' + (v.granted ? 'Your +' + v.bonus + ' welcome credits are in your balance. ' : '') + 'Your ' + esc(v.perk) + ' is waiting in ' + esc(v.game) + '.</span><br><a class="btn small" style="margin-top:8px;display:inline-block" href="' + esc(v.back) + '">Back to ' + esc(v.game) + ' to collect it</a>';
|
||||
if (from) setPane('buy');
|
||||
if (from && !/^#(passes|games)/.test(location.hash)) setPane('buy'); // a game's Buy-a-pass link (#passes) stays on the pass card
|
||||
}
|
||||
function jumpTo(pane, id) {
|
||||
setPane(pane);
|
||||
@@ -788,7 +788,8 @@
|
||||
earn: 'Earn credits', earnings: 'Earnings', promo: 'Promo tools', training: 'Training', help: 'Help and support', games: 'Games',
|
||||
wallet: 'Wallet & account', profile: 'Profile' };
|
||||
function setPane(name) {
|
||||
const paneQ = String(name || '').split('?')[1] || ''; name = String(name || '').split('?')[0]; // /my#games?pass=1 opens the Game Pass card (deep link from the games)
|
||||
let paneQ = String(name || '').split('?')[1] || ''; name = String(name || '').split('?')[0]; // /my#games?pass=1 opens the Game Pass card (deep link from the games)
|
||||
if (name === 'passes') { name = 'games'; paneQ = 'pass=1'; } // /my#passes: the Shards of Valor Buy button (2026-10-18), same card
|
||||
if (!PANES.includes(name)) name = 'overview';
|
||||
for (const p of PANES) {
|
||||
const el = $('pane-' + p);
|
||||
@@ -1691,10 +1692,58 @@
|
||||
// ---- Game Pass (2026-10-16, docs/GAME-PASS.md): $5 for 7 days across all nine games. More game, never "earn more". ----
|
||||
const gpDate = ms => new Date(Number(ms)).toLocaleDateString([], { weekday: 'short', month: 'short', day: 'numeric' });
|
||||
const gpPol = n => Number(n || 0).toFixed(2).replace(/\.?0+$/, '');
|
||||
// Pass tiers (2026-10-18, Marty approved the safe form): weekly Game Pass, monthly Explorer and Champion side by side. Paid tiers add
|
||||
// islands and looks in Shards of Valor, never power and never more POL; the main story is free. End dates in Central time.
|
||||
const gpCT = ms => new Date(Number(ms)).toLocaleDateString('en-US', { timeZone: 'America/Chicago', weekday: 'short', month: 'short', day: 'numeric' }) + ' (Central)';
|
||||
const GP_TIER_PERKS = {
|
||||
weekly: ['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 the Weekly look'],
|
||||
explorer: ['Everything in the Game Pass, in every game', 'Shards of Valor: up to 4 bonus islands you pick (1 swap a month)', 'Explorer outfits and gear styles for your character'],
|
||||
champion: ['Everything in Explorer', 'Shards of Valor: every bonus island, now and future', 'Champion outfits and gear styles for your character'],
|
||||
};
|
||||
function renderPassTiers(card, gp, highlight) {
|
||||
const rows = gp.passes || []; const top = rows.find(r => r.tier === gp.tier);
|
||||
const state = top ? '<span class="badge" style="background:var(--gold,#e2b04a);color:#111">' + esc(top.name) + ' active · until ' + esc(gpCT(top.until)) + '</span>'
|
||||
: '<span class="badge">No pass active</span>';
|
||||
const caps = gp.caps || {};
|
||||
const capsLine = caps.enforced ? 'Today: <b>' + gpPol(caps.used && caps.used.total) + '</b> of ' + gpPol(caps.total) + ' POL used across the games (' + gpPol(caps.used && caps.used.daily) + ' of ' + gpPol(caps.daily) + ' on daily play).' : '';
|
||||
const box = r => {
|
||||
const btn = r.waiting ? '<button class="btn small" type="button" data-gp-go="1">Buy a $' + r.package + ' package</button>'
|
||||
: r.open ? '<button class="btn small" type="button" data-gp-tier="' + esc(r.tier) + '">' + (r.active ? 'Extend ' + r.days + ' more days' : 'Get ' + esc(r.name)) + ' · ' + r.price + ' credits</button>'
|
||||
: '<span class="small muted">Not on sale right now. Your pass keeps running.</span>';
|
||||
return '<div class="gp-tier' + (r.tier === gp.tier ? ' on' : '') + '"><h4>' + esc(r.name) + '</h4>'
|
||||
+ '<p class="gp-price">$' + r.usd + ' <span class="small muted">for ' + r.days + ' days</span></p>'
|
||||
+ '<ul>' + (GP_TIER_PERKS[r.tier] || []).map(x => '<li>' + esc(x) + '</li>').join('') + '</ul>'
|
||||
+ '<p class="small" style="margin:6px 0">' + (r.active ? '<b>Active until ' + esc(gpCT(r.until)) + '</b>' : r.waiting ? 'Waiting for a $' + r.package + ' package' : 'Not active') + '</p>'
|
||||
+ btn + '</div>';
|
||||
};
|
||||
card.hidden = false; card.classList.toggle('gp-hl', !!highlight);
|
||||
card.innerHTML = '<div class="card-head"><h3>\u{1F39F}️ Game Passes</h3><span class="sub">weekly or monthly · every game</span></div>'
|
||||
+ (gp.tierPreview ? '<p class="small" style="margin:0 0 8px;padding:6px 10px;border-radius:8px;background:#fde68a;color:#7c2d12"><b>Admin preview.</b> Explorer and Champion are hidden from members until sovTiers is switched on in Settings.</p>' : '')
|
||||
+ '<p style="margin:0 0 8px">' + state + '</p>'
|
||||
+ '<p>Free play pays real POL every day, and the main story of Shards of Valor is free for everyone. Every pass gives the same higher POL caps in every game. The monthly passes add islands to explore and looks in Shards of Valor. <b>Paid passes never make you stronger than players who earn their gear</b>, and they never pay more POL.</p>'
|
||||
+ '<div class="gp-tiers">' + rows.map(box).join('') + '</div>'
|
||||
+ (capsLine ? '<p class="small muted" style="margin-top:10px">' + capsLine + '</p>' : '')
|
||||
+ '<p class="small muted" style="margin:10px 0 0">Paid with purchased credits from your packages (earned credits never buy a pass). Passes run side by side: a higher pass shows first, and the one underneath keeps its own end date. No auto-renew: buy again any time and that pass extends from its end date. When a pass ends, nothing you earned in a game is taken away.</p>';
|
||||
card.querySelectorAll('[data-gp-tier]').forEach(b => b.addEventListener('click', async () => {
|
||||
const r = rows.find(x => x.tier === b.dataset.gpTier); if (!r) return;
|
||||
const yes = await IAP.confirmBox((r.active ? 'Extend your ' + r.name + ' by ' + r.days + ' days' : 'Get ' + r.name + ' for ' + r.days + ' days') + ' for ' + r.price + ' purchased credits ($' + r.usd + ')? It starts at once. Islands and looks only: no extra power, no extra POL.', { title: r.name, ok: r.active ? 'Extend' : 'Get ' + r.name, cancel: 'Not now' });
|
||||
if (!yes) return;
|
||||
b.disabled = true;
|
||||
try {
|
||||
const x = await api('/api/my/gamepass/buy', { tier: r.tier });
|
||||
if (x.needPay) { IAP.status(x.message || 'Buy a package and the pass starts when it settles.', 'bad'); await loadGamePassCard(true); return; }
|
||||
IAP.status(r.name + ' active until ' + gpCT(x.until) + '. Have fun out there.', 'ok');
|
||||
await loadGamePassCard(true);
|
||||
} catch (e) { IAP.status(e.message, 'bad'); b.disabled = false; }
|
||||
}));
|
||||
card.querySelectorAll('[data-gp-go]').forEach(b => b.addEventListener('click', () => setPane('buy')));
|
||||
if (highlight) { try { card.scrollIntoView({ behavior: 'smooth', block: 'start' }); } catch (e) {} }
|
||||
}
|
||||
async function loadGamePassCard(highlight) {
|
||||
const card = $('gpCard'); if (!card) return;
|
||||
let gp = null; try { gp = await (await fetch('/api/my/gamepass')).json(); } catch (e) {}
|
||||
if (!gp || !gp.enabled) { card.hidden = true; return; }
|
||||
if (!gp || !(gp.enabled || gp.show)) { card.hidden = true; return; }
|
||||
if ((gp.passes || []).some(r => r.tier !== 'weekly')) return renderPassTiers(card, gp, highlight); // Explorer / Champion on sale (or admin preview, or a holder)
|
||||
const caps = gp.caps || {}; const price = gp.price || 500;
|
||||
const state = gp.active ? '<span class="badge" style="background:var(--gold,#e2b04a);color:#111">Pass active \u00b7 until ' + esc(gpDate(gp.until)) + '</span>'
|
||||
: gp.waiting ? '<span class="badge amber">Waiting for a $' + (gp.usd || 5) + ' package</span>' : '<span class="badge">Not active</span>';
|
||||
|
||||
+8
-1
@@ -1093,6 +1093,13 @@
|
||||
.game-card .btn{margin-top:auto;text-align:center}
|
||||
.game-card{position:relative}
|
||||
#gpCard.gp-hl{outline:2px solid var(--gold,#e2b04a);outline-offset:2px}
|
||||
.gp-tiers{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:12px;margin-top:10px}
|
||||
.gp-tier{border:1px solid var(--line-strong);border-radius:12px;padding:12px 14px;display:flex;flex-direction:column;gap:4px}
|
||||
.gp-tier.on{border-color:var(--gold,#e2b04a);box-shadow:0 0 0 1px var(--gold,#e2b04a) inset}
|
||||
.gp-tier h4{margin:0;font-size:16px;color:var(--ink);font-family:var(--disp)}
|
||||
.gp-tier .gp-price{margin:0;font-size:20px;font-weight:700}
|
||||
.gp-tier ul{margin:4px 0;padding-left:18px;font-size:13px}
|
||||
.gp-tier .btn{margin-top:auto;align-self:flex-start}
|
||||
.game-card .gc-ribbon{position:absolute;top:10px;right:10px;display:inline-flex;align-items:center;gap:6px;background:#FF5FA2;color:#2b0418;font-weight:700;font-size:11px;letter-spacing:.1em;text-transform:uppercase;padding:5px 10px;border-radius:6px;box-shadow:0 3px 0 #9c2a5d}
|
||||
.game-card .gc-ribbon i{width:7px;height:7px;border-radius:50%;background:#2b0418;display:inline-block;animation:gcPulse 1.4s ease-in-out infinite}
|
||||
@keyframes gcPulse{50%{opacity:.25}}
|
||||
@@ -1179,7 +1186,7 @@
|
||||
<script src="/assets/wallet.js?v=20260911a"></script>
|
||||
<script src="/assets/promo.js?v=20261016p"></script>
|
||||
<script src="/assets/support.js?v=20261016a"></script>
|
||||
<script src="/assets/my.js?v=20261018s"></script>
|
||||
<script src="/assets/my.js?v=20261018tiers"></script>
|
||||
<script src="/assets/chat.js?v=20261016n"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user