Shards of Valor bonus heroes sold one time (Marty approved 2026-11-05): Kestrel, Valda, Morag, Roland $20 each, $50 bundle (Valda + Morag + Roland), behind heroSales (OFF)

Paid exactly like a pass: no credits, no POL. POST /api/my/heroes/buy opens a waiting order (kind hero); a fresh package of at least the
price from one of the member's own positions fulfils it in gamepass.onEvent (one package, one order: the highest-priced it covers, pass
or hero; each tx once). Ownership is permanent on the passes record (heroes, heroBundle), never in bought, so hero sales never feed the
Pass Tournament pool. No double charge: an owned hero is refused, a bundle is refused once any of its heroes is owned, and waiting orders
made pointless by a purchase are cancelled.
Settings (Admin > Settings): heroSales '0', heroPrice<Kestrel|Valda|Morag|Roland>Cents 2000 (0 = free for every account),
heroBundlePriceCents 5000, heroBundleHeroes 'valda,morag,roland', heroBundleCap '' (unset: the bundle is heroes only, no cap change).
Hand-off: sovMint (and GET /api/partner/player for shardsofvalor) carries heroes, heroBundle, heroSale { free, bundle, each, bundlePrice },
and heroBundleCap only when set. TIER_DEFS perks: Champion no longer lists the Druid, Sovereign no longer the Necromancer (dropped),
Legend every bonus hero while active. Member Game Pass card: a Bonus heroes block (shown while heroSales is on or to an owner);
Admin > Game Pass: hero test on the admin's own account (test buy / cancel / give / remove) and /api/admin/heroes/stats.
Chatbot: canned sov-bonus-heroes answer + heroesFact following heroSales; KNOWLEDGE_DATE 2026-11-05. my.js?v=20261105hr, admin.js?v=20261105hr.
QA: qa/sov-heroes-store.cjs (39 checks, in member and sov-passes); sov-passes-local expects the hero test panel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-05 14:04:37 -06:00
parent e61475f89b
commit abfb3e3199
11 changed files with 362 additions and 28 deletions
+17 -3
View File
@@ -19,13 +19,14 @@ const kbSeed = require('./kb-seed');
let DATA_DIR = null;
let chain = null;
let HERO_SALE = null; // () => gamepass.cfg().heroes + names (server.js): the bonus-hero fact follows heroSales (2026-11-05)
let PASS_TIERS = null; // () => the live pass tiers (server.js, from gamepass.cfg): the tier fact follows the sovTiers switch
const MODEL = process.env.OPENROUTER_MODEL || 'deepseek/deepseek-v4-flash:nitro';
function init(opts) {
if (opts && typeof opts.gameLive === 'function') GAME_LIVE = opts.gameLive;
if (opts && typeof opts.refuelOn === 'function') REFUEL_ON = opts.refuelOn;
if (opts && typeof opts.bixLive === 'function') BIX_LIVE = opts.bixLive; DATA_DIR = opts.dataDir; chain = opts.chain; PASS_TIERS = typeof opts.passTiers === 'function' ? opts.passTiers : null; return kb.init({ dataDir: DATA_DIR, seeds: seeds() }); }
if (opts && typeof opts.bixLive === 'function') BIX_LIVE = opts.bixLive; DATA_DIR = opts.dataDir; chain = opts.chain; PASS_TIERS = typeof opts.passTiers === 'function' ? opts.passTiers : null; HERO_SALE = typeof opts.heroSale === 'function' ? opts.heroSale : null; return kb.init({ dataDir: DATA_DIR, seeds: seeds() }); }
function key() {
if (process.env.OPENROUTER_API_KEY) return process.env.OPENROUTER_API_KEY.trim();
try { return fs.readFileSync(path.join(DATA_DIR, 'openrouter.key'), 'utf8').trim(); } catch (e) { return ''; }
@@ -33,9 +34,14 @@ function key() {
function enabled() { return !!key(); }
// ---- canned answers: instant, free, always in voice ----
const KNOWLEDGE_DATE = '2026-11-04'; // bump whenever the canned answers / prompt are brought up to date
const KNOWLEDGE_DATE = '2026-11-05'; // bump whenever the canned answers / prompt are brought up to date
const SUPPORT_RE = /(contact|reach|email|e-mail|message|talk to|speak (to|with)|get hold of) (the )?(support|admin|administrator|owner|marty|staff|team at instantadpay|someone|a (human|person|real person))|support (email|address|ticket|team|desk)|help ?desk|(open|send|file|submit|raise) (a )?(support )?ticket|\b(human|real person|live (agent|person|chat|support))\b|customer (service|support)|support@|how (do|can) i get (help|support)/i;
const CANNED = [
// Shards of Valor bonus heroes (2026-11-05, Marty approved): sold one time. The prices and whether they are on sale live in settings, so
// this answer names neither; heroesFact() gives the AI the live state.
{ id: 'sov-bonus-heroes', title: 'Shards of Valor bonus heroes', q: ['What are the bonus heroes in Shards of Valor?', 'How do I get Kestrel, Valda, Morag or Roland?', 'Is the hero a subscription?'], tags: ['shards of valor', 'heroes', 'bonus heroes', 'kestrel', 'valda', 'morag', 'roland', 'party'],
re: /\b(bonus heroe?s?|kestrel|valda|morag|roland|paladin|barbarian|druid hero|archer hero|hero bundle)\b/i,
a: 'Shards of Valor has four bonus heroes: Kestrel the Archer, Valda the Barbarian, Morag the Druid and Roland the Paladin. Each is a one-time purchase, yours for good, with no subscription, and there is a bundle of three. Like a Game Pass, a hero is paid by a new package purchase of at least its price (your sponsor and team are paid as usual and you keep the package credits for your ads); credits you already hold never buy one. When they are on sale they show on the Game Pass card in Members > Games (https://instantadpay.com/my#games) with each price; if you do not see them there, they are not on sale yet. In the game three heroes fight at a time and you pick which three at an inn, a rest spot or a dungeon camp; heroes waiting in the roster keep their gear and level and earn half experience. A bonus hero joins at your party level (at most 20) and is never stronger than the free heroes. The whole story stays free with Aldric, Sylwen and Borin.' },
{ id: 'support', title: 'Contact support or open a ticket', q: ['How do I contact support?', 'How do I talk to a real person?', 'How do I open a support ticket?'], tags: ['support', 'help', 'ticket', 'contact', 'help desk'],
re: SUPPORT_RE, handoff: true,
a: 'Open Help in your member dashboard (https://instantadpay.com/my#help) to send Marty a ticket, and his replies land right there and in your email. Not signed in or locked out? Use https://instantadpay.com/support, or email support@instantadpay.com. You can also tap "Send this to support" below and I will pass this chat along.' },
@@ -253,6 +259,14 @@ function seeds() {
// ---- facts for the AI fallback ----
// PASS TIERS (2026-10-22): the passes above the weekly Game Pass (Explorer, Champion, Sovereign, Legend; names from gamepass.js
// TIER_DEFS). While sovTiers is off the assistant only says they are coming soon; once on, it quotes the live prices and contents.
// BONUS HEROES (2026-11-05): sold one time; while heroSales is off the assistant says they are coming soon, once on it quotes the live prices
function heroesFact() {
let h = null; try { h = HERO_SALE ? HERO_SALE() : null; } catch (e) { h = null; }
const base = 'Shards of Valor bonus heroes: Kestrel the Archer, Valda the Barbarian, Morag the Druid, Roland the Paladin. Sold ONE TIME, owned for good, never a subscription; paid by a NEW package purchase of at least the price (sponsor and team paid as usual, the member keeps the package credits); credits already held never buy one. Three heroes fight at a time, picked at an inn, rest spot or dungeon camp; the roster keeps gear and level and earns half experience. A bonus hero joins at the party level (at most 20) and is never stronger than the free heroes. The Champion and Sovereign passes no longer include a hero (the Necromancer was dropped); the Legend pass opens every bonus hero while it is active.';
if (!h || !h.sale) return '- BONUS HEROES (COMING SOON, not on sale yet): ' + base + ' Never quote their prices or a launch date while they are not on sale.\n';
const each = (h.rows || []).map(r => r.name + (r.free ? ' free for everyone' : ' $' + r.usd)).join(', ');
return '- BONUS HEROES (ON SALE, Members > Games > Game Pass card at https://instantadpay.com/my#games): ' + each + (h.bundle && h.bundle.names.length ? '; the bundle ' + h.bundle.names.join(', ') + ' $' + h.bundle.usd : '') + '. ' + base + ' The bundle is heroes only (no level cap change).\n';
}
function passTiersFact() {
let t = null; try { t = PASS_TIERS ? PASS_TIERS() : null; } catch (e) { t = null; }
const soon = '- MORE GAME PASSES: monthly and yearly passes for Shards of Valor are COMING SOON and are not on sale yet. If someone asks about them (or about an Explorer, Champion, Sovereign or Legend pass, or a monthly or yearly pass), say they are coming soon and that the $5 weekly Game Pass is the pass on sale today. Never quote their prices, contents or a launch date.\n';
@@ -310,7 +324,7 @@ function systemPrompt(kbBlock) {
FACTS:
- LEVEL 4 OVERRIDE (LIVE 2026-10-26, first payout Monday 2026-11-02): company-paid, off-chain decision, on-chain payment. 3% of every package purchase (the POL actually paid) goes to the buyer's 4th upline on the contract sponsor chain if that member's contract buyerCount is 5 or more (qualifying buyer = direct referral with a $20+ purchase, same bar as level 3); otherwise it hunts up to the next qualified upline, max 25 hops; the company account (#1) or no qualified upline = company keeps it; exactly one recipient per purchase. Paid weekly in POL every Monday after 9 AM Central for the previous Monday to Sunday Central week, from a company payer wallet via the contract's award(memberId), shown in Earnings as 'Level 4 override' with a Polygon link and announced by email and an on-site notice. Under 0.01 POL carries to the next week. Purchases from the start date only, no back pay. Funded from the platform's 20%; the contract split 50/20/10 is unchanged. Never promise amounts.
${passTiersFact()}${refuelFact()}${synFact()}${polminerFact()}${warpwaresFact()}${bixFact()}${turkeydropFact()}- ROAD AGENT (LIVE 2026-10-15, https://roadagent.app): a night-highway shooter open to every member. Open the Games tab and tap Play on the Road Agent card, or go to roadagent.app and sign in with the InstantAdPay email. Drive the four-lane highway, shoot the hostiles (thug sedans, switchblades, gunner vans), spare the civilians, pull into the weapons truck for oil slicks, smoke and missiles. Clearing a sector for the first time pays POL to the wallet on the member's InstantAdPay account, plus a daily patrol reward; scrap buys garage upgrades. Fuel = a sponsor visit: before a run the player visits an advertiser's page (a FUEL STOP), which is a normal verified visit with the dwell timer and human check, charged to the advertiser like any visit; advertisers' existing visits campaigns are already in the rotation, nothing to set up; to get more traffic from the game, top up the visits campaign. Clickable Pause, Sound and Music buttons sit under the game (P / M / N keys also work), and the Run tab has an Invite a friend card with the member's roadagent.app/?ref=<username> link.
${passTiersFact()}${heroesFact()}${refuelFact()}${synFact()}${polminerFact()}${warpwaresFact()}${bixFact()}${turkeydropFact()}- ROAD AGENT (LIVE 2026-10-15, https://roadagent.app): a night-highway shooter open to every member. Open the Games tab and tap Play on the Road Agent card, or go to roadagent.app and sign in with the InstantAdPay email. Drive the four-lane highway, shoot the hostiles (thug sedans, switchblades, gunner vans), spare the civilians, pull into the weapons truck for oil slicks, smoke and missiles. Clearing a sector for the first time pays POL to the wallet on the member's InstantAdPay account, plus a daily patrol reward; scrap buys garage upgrades. Fuel = a sponsor visit: before a run the player visits an advertiser's page (a FUEL STOP), which is a normal verified visit with the dwell timer and human check, charged to the advertiser like any visit; advertisers' existing visits campaigns are already in the rotation, nothing to set up; to get more traffic from the game, top up the visits campaign. Clickable Pause, Sound and Music buttons sit under the game (P / M / N keys also work), and the Run tab has an Invite a friend card with the member's roadagent.app/?ref=<username> link.
- HELP DESK (LIVE 2026-10-16): members open Help in the dashboard (/my#help) to send Marty a support ticket (pick a category, a subject, the message, up to 2 screenshots), see each ticket's status (Open, Waiting on you, Closed) and read and answer his replies; a badge shows when he has replied, and replies also arrive by email. Anyone signed out or locked out uses the public form at https://instantadpay.com/support (name, email, category, subject, message) and gets an email with the ticket number (like IAP-1042) and a private link to view and reply, no sign-in needed. support@instantadpay.com also reaches Marty. Replying to a closed ticket opens it again. In this chat, "Send this to support" turns the conversation into a ticket. Only Marty answers, so replies are not instant; never promise a response time.
- PRESENTATION (2026-10-15): instantadpay.com/presentation is a public page (no sign-in) with the narrated InstantAdPay presentation, about six minutes, Marty's voice, captions in 6 languages (English, Italiano, Français, Español, Deutsch, Português) chosen with pills under the player. Sixteen parts: the platform, ad reach, the nine games that pay POL, the $20 split ($10 / $4 / $2 / $4 platform, same transaction), three rules, packages, the 2-then-5 unlock, pass-up, wide versus narrow ($800 vs $36, an illustration), Qualified Start, the Pipeline, LinkSpin (pre-launch Nov 1), one wallet across the network, the first week, and 'the target is five'. Share link: Members > Promo tools > 'Share the presentation' copies instantadpay.com/presentation?ref=<username>; ?ref sets the same 30-day sponsor cookie as the invite link, the page shows 'Shared with you by @name' with avatar and a Join button to /join/<username>. It is in the site menu as 'Presentation'. BUILD WIDE VIDEO: first card in Promo tools > Videos ('Build wide: watch the payments flow'), matched link ?v=wide.
- WIRED WEDNESDAY: every Wednesday, Central time (midnight to midnight), any ad package of $20 or more (Activation and up; no $10 pack exists) earns +25% bonus credits wired into the buyer's balance the moment the purchase settles, purchased-grade (usable on every format incl. login ads), credit log label "Wired Wednesday". First one: Wednesday 2026-09-30. Page: instantadpay.com/wednesday. Credits buy ad delivery, never money.
+12 -3
View File
@@ -230,10 +230,19 @@ switched off for members (`sovTiers` 0) until Marty flips it.
|---|---|---|---|---|
| `weekly` | Game Pass | 500 credits ($5) | 7 days | the Game Pass in all nine games, the Sunless Vault, weapons unlocked |
| `explorer` | Explorer | 2000 ($20, the Activation package) | 30 days | weapons, gear, 2 DLC islands |
| `champion` | Champion | 5000 ($50, the Builder package) | 30 days | weapons, gear, 4 DLC islands of your choice, the Druid hero, level cap 30 |
| `sovereign` | Sovereign | 10000 ($100, the Growth package) | 30 days | weapons, gear, all DLC islands, the Necromancer hero, level cap 40 |
| `legend` | Legend | 25000 ($250, the Leader package) | 365 days | weapons, gear, all DLC islands, every hero including the Archer, level cap 40 |
| `champion` | Champion | 5000 ($50, the Builder package) | 30 days | weapons, gear, 4 DLC islands of your choice, level cap 30 |
| `sovereign` | Sovereign | 10000 ($100, the Growth package) | 30 days | weapons, gear, all DLC islands, level cap 40 |
| `legend` | Legend | 25000 ($250, the Leader package) | 365 days | weapons, gear, all DLC islands, every bonus hero while active, level cap 40 |
**Bonus heroes (2026-11-05, Marty approved).** Kestrel the Archer, Valda the Barbarian, Morag the Druid and Roland the Paladin are
SOLD ONE TIME (no subscription, no expiry), not by a tier: $20 each (2000 cents, the Activation package) and a $50 bundle (5000, the
Builder package) of Valda, Morag and Roland by default. Paid like a pass: POST /api/my/heroes/buy { hero } opens a waiting order (kind
hero); a fresh package of at least the price from one of the member's own positions fulfils it in `onEvent` (one package, one order, the
highest-priced it covers). Owned heroes live on the passes record (`heroes`, `heroBundle`) and never in `bought`, so they never feed the
Pass Tournament pool. Settings: `heroSales` (sale switch, OFF), `heroPrice<Name>Cents` (0 = free for every account), `heroBundlePriceCents`,
`heroBundleHeroes`, `heroBundleCap` (empty: no cap change; not approved). Shards of Valor reads `heroes`, `heroBundle`, `heroSale` (and
`heroBundleCap` only when set) on the sign-in hand-off. Admin > Game Pass has a hero test on the admin's own account. QA: qa/sov-heroes-store.cjs.
- **One table**: `gamepass.js` `TIER_DEFS` holds the rank, wire key, display name, settings stem, default price/length and the
member-card list for every tier. Rename a tier there (the card, admin pane, charge label and chatbot all read it).
- **Rank**: weekly < explorer < champion < sovereign < legend. Every tier is a Game Pass holder everywhere with exactly the pass
+133 -12
View File
@@ -52,11 +52,11 @@ const TIER_DEFS = [
{ key: 'explorer', name: 'Explorer', set: 'Explorer', price: 2000, 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: 5000, 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'] },
perks: ['Everything in Explorer', 'Shards of Valor: 4 bonus islands of your choice', 'Shards of Valor: level cap 30'] }, // 2026-11-05: the Druid moved to the one-time bonus heroes
{ key: 'sovereign', name: 'Sovereign', set: 'Sovereign', price: 10000, days: 30,
perks: ['Everything in Champion', 'Shards of Valor: every bonus island', 'Shards of Valor: the Necromancer hero', 'Shards of Valor: level cap 40'] },
perks: ['Everything in Champion', 'Shards of Valor: every bonus island', 'Shards of Valor: level cap 40'] }, // 2026-11-05: the Necromancer was dropped
{ key: 'legend', name: 'Legend', set: 'Legend', price: 25000, days: 365,
perks: ['Everything in Sovereign, for a full year', 'Shards of Valor: every bonus island', 'Shards of Valor: every hero, the Archer included, and every new hero as it ships', 'Shards of Valor: level cap 40'] }, // new heroes as a Legend perk: Marty 2026-10-30 (Dallas's $100/year idea folded in here)
perks: ['Everything in Sovereign, for a full year', 'Shards of Valor: every bonus island', 'Shards of Valor: every bonus hero while Legend is active (Kestrel, Valda, Morag, Roland), and every new hero as it ships', 'Shards of Valor: level cap 40'] }, // new heroes as a Legend perk: Marty 2026-10-30 (Dallas's $100/year idea folded in here)
];
const TIERS = TIER_DEFS.map(d => d.key); // lowest to highest
const TIER_NAMES = Object.fromEntries(TIER_DEFS.map(d => [d.key, d.name]));
@@ -64,6 +64,22 @@ 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;
// Bonus heroes for Shards of Valor (Marty approved 2026-11-05, Dallas's request): SOLD ONE TIME, no subscription, owned for good. Paid
// exactly like a pass: no credits, no direct POL; buying opens a waiting order, fulfilled by a FRESH package of at least the price
// bought by one of the member's own positions, so the sponsor line is paid as usual (onEvent). $20 each = the Activation package; the
// $50 bundle (the Builder package) is a settings list, default Valda + Morag + Roland (Dallas 13:26; Marty approved a $50 bundle of
// three). Settings (Admin > Settings, no deploy): heroSales (sale switch, default OFF), heroPrice<Set>Cents per hero (0 = free for
// every account, granted like a base hero), heroBundlePriceCents, heroBundleHeroes, heroBundleCap (a level the bundle would raise the
// cap to; UNSET = no cap change, Marty has not approved one). key = the wire value Shards of Valor reads (classes.json paid buy).
const HERO_DEFS = [
{ key: 'kestrel', set: 'Kestrel', name: 'Kestrel the Archer', price: 2000, blurb: 'Quick and sharp-eyed: arrows on every foe.' },
{ key: 'valda', set: 'Valda', name: 'Valda the Barbarian', price: 2000, blurb: 'A berserker: hits harder the more she is hurt, light on armour.' },
{ key: 'morag', set: 'Morag', name: 'Morag the Druid', price: 2000, blurb: 'A healer of the wild: heals the whole party.' },
{ key: 'roland', set: 'Roland', name: 'Roland the Paladin', price: 2000, blurb: 'A holy knight: sword and shield, heals one hero at a time.' },
];
const HERO_KEYS = HERO_DEFS.map(d => d.key);
const HERO_DEF = Object.fromEntries(HERO_DEFS.map(d => [d.key, d]));
const HERO_BUNDLE_DEFAULT = 'valda,morag,roland';
let R = null; // deps from server.js
let passes, orders, prizes; // durable persisted maps (server.js open-tokens store, DURABLE set)
@@ -110,6 +126,14 @@ function cfg() {
pct: Math.max(0, n('passTournamentPct', 5)),
gamesChat: String(sc.telegramGamesChatId || sc.telegramEchoChatId || '').trim(),
gamesTopic: String(sc.telegramGamesTopicId || '').trim(),
heroes: (() => {
const price = Object.fromEntries(HERO_DEFS.map(d => [d.key, Math.max(0, Math.round(n('heroPrice' + d.set + 'Cents', d.price)))]));
const raw = sc.heroBundleHeroes == null || String(sc.heroBundleHeroes).trim() === '' ? HERO_BUNDLE_DEFAULT : String(sc.heroBundleHeroes);
const list = [...new Set(raw.split(',').map(x => x.trim().toLowerCase()).filter(k => HERO_KEYS.includes(k) && price[k] > 0))];
const capRaw = String(sc.heroBundleCap == null ? '' : sc.heroBundleCap).trim(), cap = capRaw === '' ? NaN : Number(capRaw);
return { sale: on('heroSales'), price, free: HERO_KEYS.filter(k => price[k] === 0), bundle: { heroes: list.length >= 2 ? list : [], price: Math.max(1, Math.round(n('heroBundlePriceCents', 5000))) },
cap: Number.isInteger(cap) && cap > 0 ? cap : null };
})(),
};
}
const enforcedOn = (c, day) => !!(c.start && day >= c.start);
@@ -167,7 +191,7 @@ function extend(e, via, extra, now, tier) {
passes.set(e, writeTiers(cur, T, { bought, ts: t }));
return { until, days: tc.days, tier };
}
function waitingOrders(e) { const out = []; for (const [k, o] of orders) if (o.status === 'waiting' && o.email === e) out.push(Object.assign({ order: k }, o, { tier: tierOk(o.tier) ? o.tier : 'weekly' })); return out; }
function waitingOrders(e) { const out = []; for (const [k, o] of orders) if (o.status === 'waiting' && o.email === e && o.kind !== 'hero') out.push(Object.assign({ order: k }, o, { tier: tierOk(o.tier) ? o.tier : 'weekly' })); return out; }
function waitingOrder(e, tier) { return waitingOrders(e).find(o => o.tier === (tier || 'weekly')) || null; }
// the admin's tier test: drop a waiting order that was opened for testing, so a later real package never fulfils it by surprise
function cancelOrder(email, tier) {
@@ -210,7 +234,8 @@ function view(email, now, opts) {
waiting: !!w, waitingSince: w ? w.ts : null, bought: p ? (p.bought || []).length : 0,
caps, capsStart: c.start || null, lastCapHit: p && p.lastCapHit && (t - p.lastCapHit.ts) < 2 * 86400000 ? p.lastCapHit : null,
tournament: { pct: c.pct, shares: SHARES, next: nextTournamentAt(t) },
show: c.enabled || tiered, passes: passRows, tierPreview: tiered && admin && !c.tierSales };
show: c.enabled || tiered, passes: passRows, tierPreview: tiered && admin && !c.tierSales,
heroes: heroView(e, t, opts) }; // bonus heroes (2026-11-05): sold one time, shown while heroSales is on, to an owner, or in the admin test
}
// POST /api/my/gamepass/buy { tier }. tier missing = weekly (exactly the pass as it was before tiers). opts.preview = the admin
@@ -263,20 +288,116 @@ async function minedAt(ev) { // block time in ms; the indexed-at time only when
async function onEvent(ev) {
if (!ev || ev.type !== 'Purchase' || (ev.priceCents || 0) < 500) return null;
const c = cfg(); const cents = ev.priceCents || 0;
if (!TIERS.some(k => cents >= c.tiers[k].price)) return null;
if (!TIERS.some(k => cents >= c.tiers[k].price) && !heroOrderPrices(c).some(x => cents >= x)) return null;
const e = await ownerOf(ev); if (!e) return null;
if (!waitingOrders(e).length) return null;
if (!waitingOrders(e).length && !heroOrders(e).length) return null;
if (txUsed(ev.tx)) return null; // each purchase counts once, everywhere
const at = await minedAt(ev);
const w = waitingOrders(e).filter(o => cents >= c.tiers[o.tier].price && at + ORDER_SKEW_MS >= o.ts)
.sort((x, y) => c.tiers[y.tier].price - c.tiers[x.tier].price || x.ts - y.ts)[0];
// 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)));
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.kind === 'hero') {
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 };
}
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 };
}
// ---- bonus heroes (2026-11-05) ----
// owned for good: record.heroes = { kestrel: { ts, via, tx, order, cents, usd, bundle? } }, record.heroBundle = { ts, via, heroes, tx, order }
// (in the passes map, the same durable record as the passes). A hero is never in `bought`, so hero sales never feed the Pass Tournament pool.
function heroOrders(e) { const out = []; for (const [k, o] of orders) if (o.status === 'waiting' && o.email === e && o.kind === 'hero') out.push(Object.assign({ order: k }, o)); return out; }
function heroOrder(e, key) { return heroOrders(e).find(o => o.hero === key) || null; }
const heroOrderPrice = (c, key) => key === 'bundle' ? c.heroes.bundle.price : (c.heroes.price[key] || 0);
const heroOrderPrices = c => [c.heroes.bundle.price].concat(Object.values(c.heroes.price).filter(x => x > 0));
// a waiting hero order still worth fulfilling: nothing in it is owned yet (a bundle also needs its list set)
function heroOrderOpen(e, key) { const c = cfg(), own = new Set(heroesOwned(e).owned); if (key === 'bundle') return c.heroes.bundle.heroes.length > 0 && !c.heroes.bundle.heroes.some(k => own.has(k)); return HERO_KEYS.includes(key) && !own.has(key); }
// -> { owned: bought, comped and free heroes; bought: on the record; bundle: bought as the bundle }
function heroesOwned(email) {
const p = rec(String(email || '').toLowerCase()), c = cfg(), H = (p && p.heroes) || {};
return { owned: HERO_KEYS.filter(k => H[k] || c.heroes.free.includes(k)), bought: HERO_KEYS.filter(k => H[k]), bundle: !!(p && p.heroBundle) };
}
// the hand-off claim for Shards of Valor (server.js sovMint): what this member owns, and the current sale (the game keeps it, so a free
// hero opens for guests too)
function heroClaim(email) {
const c = cfg(), h = heroesOwned(email), out = { heroes: h.owned, heroBundle: h.bundle, heroSale: { free: c.heroes.free, bundle: c.heroes.bundle.heroes, each: (c.heroes.price.valda || 2000) / 100, bundlePrice: c.heroes.bundle.price / 100 } };
if (h.bundle && c.heroes.cap) out.heroBundleCap = c.heroes.cap; // only once Marty sets heroBundleCap (unset today: heroes only)
return out;
}
function grantHeroes(e, key, via, extra, now) {
const t = now || Date.now(), c = cfg(), cur = passes.get(e) || { until: 0, bought: [] }, H = Object.assign({}, cur.heroes || {});
const list = key === 'bundle' ? c.heroes.bundle.heroes.slice() : [key], got = [];
for (const k of list) if (!H[k]) { H[k] = Object.assign({ ts: t, via }, extra || {}, key === 'bundle' ? { bundle: true } : {}); got.push(k); }
const upd = { heroes: H }; if (key === 'bundle') upd.heroBundle = Object.assign({ ts: t, via, heroes: list }, extra || {});
passes.set(e, Object.assign({}, cur, upd));
// never a second charge for a hero you have: drop waiting orders that are now owned (in full or in part)
for (const o of heroOrders(e)) if (!heroOrderOpen(e, o.hero)) orders.set(o.order, Object.assign({}, orders.get(o.order), { status: 'cancelled', cancelledAt: t, why: 'already owned' }));
return { heroes: got, owned: heroesOwned(e).owned };
}
// the member card part: every hero, its price and state, and the bundle. open = on sale (heroSales) or the admin portal's test (opts.preview)
function heroView(email, now, opts) {
const e = String(email || '').toLowerCase(), c = cfg(), h = heroesOwned(e), own = new Set(h.owned), preview = !!(opts && opts.preview), open = c.heroes.sale || preview;
const items = HERO_DEFS.map(d => { const price = c.heroes.price[d.key]; return { key: d.key, name: d.name, blurb: d.blurb, price, usd: price / 100, package: packageFor(price / 100), free: price === 0, owned: own.has(d.key), waiting: !!heroOrder(e, d.key), open: open && price > 0 && !own.has(d.key) }; });
const B = c.heroes.bundle, bOwn = B.heroes.filter(k => own.has(k));
const bundle = B.heroes.length ? { key: 'bundle', names: B.heroes.map(k => HERO_DEF[k].name), heroes: B.heroes, price: B.price, usd: B.price / 100, package: packageFor(B.price / 100), owned: bOwn.length === B.heroes.length, some: bOwn.length > 0, waiting: !!heroOrder(e, 'bundle'), open: open && !bOwn.length } : null;
return { sale: c.heroes.sale, preview: preview && !c.heroes.sale, show: c.heroes.sale || preview || h.bought.length > 0, items, bundle, owned: h.owned, bundleOwned: h.bundle };
}
// POST /api/my/heroes/buy { hero: kestrel | valda | morag | roland | bundle }: opens (or reuses) a waiting order; a fresh package of at
// least the price fulfils it (onEvent). Never spends credits. Refuses a hero already owned, a free one, and a bundle when any of its
// heroes is already owned (the rest one at a time costs less).
function buyHero(email, now, key, opts) {
const e = String(email || '').toLowerCase(), c = cfg(), t = now || Date.now(); key = String(key || '').toLowerCase();
if (key !== 'bundle' && !HERO_KEYS.includes(key)) return { error: 'There is no such hero.' };
if (!(c.heroes.sale || (opts && opts.preview))) return { error: 'Bonus heroes are not on sale yet.' };
const own = new Set(heroesOwned(e).owned);
if (key === 'bundle') {
const B = c.heroes.bundle; if (!B.heroes.length) return { error: 'There is no hero bundle right now.' };
const have = B.heroes.filter(k => own.has(k)); if (have.length) return { error: 'You already have ' + have.map(k => HERO_DEF[k].name).join(' and ') + ', so the bundle is not for you: get the others one at a time.' };
} else {
if (c.heroes.price[key] === 0) return { error: HERO_DEF[key].name + ' is free for everyone.' };
if (own.has(key)) return { error: 'You already have ' + HERO_DEF[key].name + '. Heroes are yours for good.' };
}
let w = heroOrder(e, key); const reused = !!w;
if (!w) { const k = 'hero-' + t.toString(36) + '-' + Math.random().toString(36).slice(2, 8); orders.set(k, { status: 'waiting', kind: 'hero', hero: key, email: e, ts: t }); w = Object.assign({ order: k }, orders.get(k)); }
const price = heroOrderPrice(c, key), pkg = packageFor(price / 100);
const name = key === 'bundle' ? 'The hero bundle (' + c.heroes.bundle.heroes.map(k => HERO_DEF[k].name).join(', ') + ')' : HERO_DEF[key].name;
if (!reused) console.log('bonus hero order opened', key, e, w.order, 'needs a package of', price, 'cents');
return { ok: false, needPay: true, hero: key, payUrl: '/my?from=heroes&hero=' + key + '#buy', order: w.order, orderTs: w.ts, reused, price, usd: price / 100, package: pkg,
message: name + ' joins you in Shards of Valor the moment your next package of $' + pkg + ' or more settles on chain. One time, yours for good. Your sponsor and team are paid from it as usual, and you keep every credit of the package for your ads.' };
}
function cancelHeroOrder(email, key) {
const e = String(email || '').toLowerCase(), w = heroOrder(e, String(key || '').toLowerCase()); if (!w) return { ok: true, none: true };
orders.set(w.order, Object.assign({}, orders.get(w.order), { status: 'cancelled', cancelledAt: Date.now() })); return { ok: true, order: w.order, hero: w.hero };
}
function compHero(email, key, why) { // support or the admin test: counts as no sale
const e = String(email || '').toLowerCase(); key = String(key || '').toLowerCase(); if (key !== 'bundle' && !HERO_KEYS.includes(key)) return { error: 'There is no such hero.' };
return Object.assign({ ok: true }, grantHeroes(e, key, 'admin', { note: String(why || 'support').slice(0, 80), usd: 0 }));
}
function revokeHero(email, key, why) { // support only (an admin test, a mistaken comp); never automatic
const e = String(email || '').toLowerCase(); key = String(key || '').toLowerCase(); const p = passes.get(e); const H = Object.assign({}, (p && p.heroes) || {});
const keys = key === 'all' ? Object.keys(H) : [key]; if (!p || !keys.some(k => H[k])) return { error: 'This account does not own that hero.' };
const gone = []; for (const k of keys) if (H[k]) { gone.push(Object.assign({}, H[k], { hero: k, revokedAt: Date.now(), why: String(why || 'support').slice(0, 80) })); delete H[k]; }
const upd = { heroes: H, heroRevokes: gone.concat(p.heroRevokes || []).slice(0, 50) };
if (p.heroBundle && !(p.heroBundle.heroes || []).every(k => H[k])) upd.heroBundle = null;
passes.set(e, Object.assign({}, p, upd)); return { ok: true, revoked: gone.map(g => g.hero) };
}
function heroStats() {
const c = cfg(); const out = { sale: c.heroes.sale, sold: Object.fromEntries(HERO_KEYS.map(k => [k, 0])), bundles: 0, comped: 0, usd: 0, waiting: 0 };
for (const [, p] of passes) {
if (!p) continue;
for (const [k, h] of Object.entries(p.heroes || {})) { if (!(k in out.sold)) continue; if (h.via === 'admin') { out.comped += 1; continue; } out.sold[k] += 1; if (!h.bundle) out.usd += Number(h.usd) || 0; }
if (p.heroBundle && p.heroBundle.via !== 'admin') { out.bundles += 1; out.usd += Number(p.heroBundle.usd) || 0; }
}
for (const [, o] of orders) if (o.status === 'waiting' && o.kind === 'hero') out.waiting += 1;
out.usd = Math.round(out.usd * 100) / 100; return out;
}
// ---- the caps ----
function capsFor(email, now, game) {
const e = String(email || '').toLowerCase(); const c = cfg(); const t = now || Date.now(); const day = dayKey(t); const pass = flag(e, t).active;
@@ -448,7 +569,7 @@ function tierStats(t) {
if (b.ts >= d30 && rows.some(x => x !== b && rowTier(x) === k && x.ts < b.ts)) o.renewals30d += 1;
}
}
for (const [, o] of orders) if (o.status === 'waiting') out[tierOk(o.tier) ? o.tier : 'weekly'].waitingOrders += 1;
for (const [, o] of orders) if (o.status === 'waiting' && o.kind !== 'hero') out[tierOk(o.tier) ? o.tier : 'weekly'].waitingOrders += 1;
for (const k of TIERS) for (const f of ['usdWeek', 'usdMonth', 'usdTotal']) out[k][f] = Math.round(out[k][f] * 100) / 100;
return out;
}
@@ -479,7 +600,7 @@ function adminStats(now) {
const t = now || Date.now(); const c = cfg(); const ws = weekStart(t); const day = dayKey(t); const wkFrom = dayKey(ws);
let active = 0, soldTotal = 0, usdTotal = 0, soldWeek = 0, usdWeek = 0, waiting = 0, comped = 0;
for (const [, p] of passes) { if (!p) continue; if (topTier(tiersOf(p), t)) active += 1; for (const b of p.bought || []) { if (!isSale(b)) { comped += 1; continue; } soldTotal += 1; usdTotal += Number(b.usd) || 0; if (b.ts >= ws) { soldWeek += 1; usdWeek += Number(b.usd) || 0; } } }
for (const [, o] of orders) if (o.status === 'waiting') waiting += 1;
for (const [, o] of orders) if (o.status === 'waiting' && o.kind !== 'hero') waiting += 1;
const wk = { pass: { allowed: 0, hitsDaily: 0, hitsTotal: 0 }, free: { allowed: 0, hitsDaily: 0, hitsTotal: 0 }, carried: 0, dropped: 0, deferredOut: 0, grants: 0, would: { dropped: 0, deferred: 0, hitsDaily: 0, hitsTotal: 0 }, players: 0 };
const today = { allowed: 0, grants: 0, players: 0 };
let qEntries = 0, qPol = 0, qMembers = 0; const byGame = {};
@@ -524,5 +645,5 @@ function prune(now) {
return n;
}
module.exports = { init, cfg, GAMES, NAMES, TIERS, TIER_NAMES, TIER_DEFS, flag, activity, view, buy, cancelOrder, 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, HERO_DEFS, HERO_KEYS, heroesOwned, heroClaim, heroView, buyHero, cancelHeroOrder, compHero, revokeHero, heroStats, flag, activity, view, buy, cancelOrder, comp, revoke, onEvent, capsFor, grant, voidGrant, tournamentTick, runTournament, pending, markPaid, adminStats, prune, weekStart, dayKey,
_ledger: () => L };
+1 -1
View File
@@ -653,6 +653,6 @@
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
<script src="/assets/admin-kb.js?v=20261020kb"></script>
<script src="/assets/admin.js?v=20261101th"></script><script src="/assets/admin-sponsorcheck.js?v=20261022sc"></script><script src="/assets/admin-kits.js?v=20261101th"></script>
<script src="/assets/admin.js?v=20261105hr"></script><script src="/assets/admin-sponsorcheck.js?v=20261022sc"></script><script src="/assets/admin-kits.js?v=20261101th"></script>
</body>
</html>
+32 -1
View File
@@ -1276,6 +1276,35 @@
// Tier test and preview (2026-10-25, Marty): the member Games card shows the admin exactly what a member sees, so every tier test lives
// here. Every action touches ONLY the signed-in admin's own account; a test buy opens the same waiting order a member gets (a fresh
// package on /my fulfils it, sponsors paid as usual), a test comp starts the tier at once with no sale recorded.
// Shards of Valor bonus heroes (2026-11-05, Marty approved): sold ONE TIME. The same test path as the tiers, on the admin's own account:
// a test buy opens the real waiting order (a fresh $20 / $50 package on /my fulfils it), Give grants it at once as comped, Remove takes it back.
function heroTestHtml(H) {
if (!H || !H.items) return '';
const row = (key, name, sub, usd, pkg, owned, waiting, free) => '<div class="gpt-tier' + (owned ? ' on' : '') + '"><h4>' + esc(name) + '</h4><p class="small muted" style="margin:0 0 4px">' + esc(sub) + '</p>'
+ '<p class="gpt-price">' + (free ? 'Free for everyone' : '$' + usd + ' <span class="small muted">one time, the $' + pkg + ' package</span>') + '</p>'
+ '<p class="small" style="margin:4px 0">' + (owned ? '<b>Your account: owned</b>' : waiting ? '<b>Your account: test order waiting for a $' + pkg + ' package</b>' : 'Your account: not owned') + '</p><div class="gpt-acts">'
+ (free || owned ? '' : waiting ? '<a class="btn small" href="/my?from=heroes#buy" target="_blank" rel="noopener">Buy the $' + pkg + ' package on /my</a><button class="btn small sec" type="button" data-ht-cancel="' + key + '">Cancel test order</button>' : '<button class="btn small" type="button" data-ht-buy="' + key + '">Test buy (real order, $' + pkg + ' package)</button>')
+ (owned || free ? '' : '<button class="btn small sec" type="button" data-ht-comp="' + key + '">Give my account ' + esc(name.split(' ')[0]) + ' now (test)</button>')
+ (owned && !free && key !== 'bundle' ? '<button class="btn small sec" type="button" data-ht-revoke="' + key + '">Remove from my account</button>' : '') + '</div></div>';
const B = H.bundle;
return '<h3 style="margin:16px 0 6px">Shards of Valor bonus heroes <span class="chip flat">' + (H.sale ? 'on sale: members see them' : 'hidden from members (heroSales off)') + '</span></h3>'
+ '<p class="muted" style="margin:0 0 8px">Sold one time, owned for good, paid by a fresh package like a pass (no credits). Prices, the free list and the bundle are settings: heroPrice&lt;Name&gt;Cents (0 = free for everyone), heroBundleHeroes, heroBundlePriceCents. heroBundleCap stays empty (the bundle is heroes only). Members see heroes only once <b>heroSales</b> is on.</p>'
+ '<div class="gpt-grid">' + H.items.map(i => row(i.key, i.name, i.blurb, i.usd, i.package, i.owned, i.waiting, i.free)).join('')
+ (B ? row('bundle', 'Hero bundle', B.names.join(', '), B.usd, B.package, B.owned, B.waiting, false) : '') + '</div>';
}
function wireHeroTest(box, g) {
const nm = k => k === 'bundle' ? 'the hero bundle' : ((g.heroes.items.find(i => i.key === k) || {}).name || k);
box.querySelectorAll('[data-ht-buy]').forEach(b => b.addEventListener('click', busy(b, async () => {
const k = b.dataset.htBuy; if (!(await IAP.confirmBox('Open a TEST order for ' + nm(k) + ' on your own account (' + g.email + ')? It is fulfilled when a fresh package of at least its price from one of your positions settles on chain. Members still cannot buy heroes while heroSales is off.', { title: 'Test buy: ' + nm(k), ok: 'Open the test order', cancel: 'Not now' }))) return;
const x = await api('/api/admin/heroes/test-buy', { hero: k }); IAP.status('Test order for ' + nm(k) + ' is waiting for a $' + x.package + ' package on ' + x.email + '.', 'ok'); await loadGpTest();
})));
box.querySelectorAll('[data-ht-cancel]').forEach(b => b.addEventListener('click', busy(b, async () => { const k = b.dataset.htCancel; await api('/api/admin/heroes/test-cancel', { hero: k }); IAP.status('Test order for ' + nm(k) + ' cancelled.', 'ok'); await loadGpTest(); })));
box.querySelectorAll('[data-ht-comp]').forEach(b => b.addEventListener('click', busy(b, async () => {
const k = b.dataset.htComp; if (!(await IAP.confirmBox('Give your own account ' + nm(k) + ' now, for testing? Recorded as comped (no sale); the game shows it the next time you sign in to it from /my Games.', { title: 'Test ' + nm(k), ok: 'Give it to me', cancel: 'Not now' }))) return;
await api('/api/admin/heroes/test-comp', { hero: k }); IAP.status(nm(k) + ' is on your account (test).', 'ok'); await loadGpTest();
})));
box.querySelectorAll('[data-ht-revoke]').forEach(b => b.addEventListener('click', busy(b, async () => { const k = b.dataset.htRevoke; await api('/api/admin/heroes/test-revoke', { hero: k }); IAP.status(nm(k) + ' removed from your account.', 'ok'); await loadGpTest(); })));
}
async function loadGpTest() {
const box = $('gpTest'); if (!box) return;
let g; try { g = await api('/api/admin/gamepass/preview'); } catch (e) { box.innerHTML = '<p class="muted">' + esc(e.message) + '</p>'; return; }
@@ -1299,8 +1328,10 @@
+ 'These are the tier cards as members will see them. Every button here acts on your own account (' + esc(g.email) + ') and nobody else’s. The member Games card on /my shows you exactly what a member sees: while you hold a test tier it shows that tier the way it would for any member who holds one.</p>'
+ '<div class="gpt-grid">' + rows.map(card).join('') + '</div>'
+ '<p class="muted" style="margin:10px 0 0"><b>Test buy</b> opens the same waiting order a member gets: a fresh package of at least the price, bought on /my by one of your positions, starts it (sponsors paid as usual). Cancel a test order you will not pay, or a later real package of that size fulfils it. <b>Give my account</b> starts one pass period at once, recorded as comped (no sale); <b>End</b> stops it. '
+ 'To test it in game, open <b>Shards of Valor &gt; Passes</b> (key P) after signing in to the game again from /my Games: the game reads your highest tier from InstantAdPay at sign-in.</p>';
+ 'To test it in game, open <b>Shards of Valor &gt; Passes</b> (key P) after signing in to the game again from /my Games: the game reads your highest tier from InstantAdPay at sign-in.</p>'
+ heroTestHtml(g.heroes);
const tierName = k => (rows.find(r => r.tier === k) || {}).name || k;
wireHeroTest(box, g);
box.querySelectorAll('[data-gpt-buy]').forEach(b => b.addEventListener('click', busy(b, async () => {
const k = b.dataset.gptBuy; const r = rows.find(x => x.tier === k);
if (!(await IAP.confirmBox('Open a TEST order for ' + tierName(k) + ' on your own account (' + g.email + ')? It starts when a fresh $' + r.package + ' or bigger package from one of your positions settles on chain. Members still cannot see or buy this tier.', { title: 'Test buy: ' + tierName(k), ok: 'Open the test order', cancel: 'Not now' }))) return;
+39 -2
View File
@@ -2048,6 +2048,35 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
// package's ad credits (the base credits per package, same table as Buy packages; day bonuses can add more)
const GP_PKG_CREDITS = { 5: 500, 10: 1000, 20: 2000, 50: 5500, 100: 12000, 250: 32500, 500: 70000 };
const gpLen = d => d >= 365 && d % 365 === 0 ? (d === 365 ? '1 year' : (d / 365) + ' years') : d + ' days';
// Shards of Valor bonus heroes (2026-11-05, Marty approved): sold ONE TIME, yours for good, paid by a new package like a pass (credits
// never buy one). Shown while heroSales is on, or to a member who owns one. gp.heroes comes from gamepass.js heroView.
function heroesHtml(H) {
if (!H || !H.show) return '';
const btn = (key, label, pkg) => '<button class="btn small" type="button" data-hero-buy="' + esc(key) + '">' + esc(label) + ' · $' + pkg + ' package</button>';
const item = i => '<div class="gp-tier' + (i.owned ? ' on' : '') + '"><h4>' + esc(i.name) + '</h4>'
+ '<p class="gp-price">' + (i.free ? 'Free for everyone' : '$' + i.usd + ' <span class="small muted">one time</span>') + '</p>'
+ '<p class="small muted" style="margin:0 0 6px">' + esc(i.blurb) + '</p>'
+ (i.owned ? '<p class="small"><b>Yours for good</b></p>' : i.waiting ? '<button class="btn small" type="button" data-gp-go="1">Buy a $' + i.package + ' package</button>' : i.open ? btn(i.key, 'Get ' + i.name.split(' ')[0], i.package) : '<span class="small muted">Not on sale right now.</span>') + '</div>';
const B = H.bundle;
const bundle = !B ? '' : '<div class="gp-tier' + (B.owned ? ' on' : '') + '"><h4>Hero bundle</h4><p class="gp-price">$' + B.usd + ' <span class="small muted">one time</span></p>'
+ '<p class="small muted" style="margin:0 0 6px">' + esc(B.names.join(', ')) + ', together.</p>'
+ (B.owned ? '<p class="small"><b>Yours for good</b></p>' : B.waiting ? '<button class="btn small" type="button" data-gp-go="1">Buy a $' + B.package + ' package</button>' : B.open ? btn('bundle', 'Get all three', B.package) : B.some ? '<span class="small muted">You already have one of them: get the others one at a time.</span>' : '<span class="small muted">Not on sale right now.</span>') + '</div>';
return '<div id="gpHeroes" style="margin-top:14px"><h4 style="margin:0 0 6px">Shards of Valor bonus heroes</h4>'
+ '<p class="small" style="margin:0 0 8px">Extra heroes for your party, bought <b>one time</b> and yours for good: no subscription. Three heroes fight at a time and you pick which three. A bonus hero joins at your party level (at most 20) with its own bound gear, never stronger than heroes and gear you can earn. The whole story stays free with Aldric, Sylwen and Borin.</p>'
+ '<div class="gp-tiers">' + H.items.map(item).join('') + bundle + '</div>'
+ '<p class="small muted" style="margin:8px 0 0">Every hero is paid by a new package purchase of at least its price, so your sponsor and team are paid; you keep the package credits for your ads. Credits you already hold never buy a hero.</p></div>';
}
function wireHeroes(card, H) {
if (!H) return;
card.querySelectorAll('[data-hero-buy]').forEach(b => b.addEventListener('click', async () => {
const k = b.dataset.heroBuy, i = k === 'bundle' ? Object.assign({ name: 'the hero bundle (' + H.bundle.names.join(', ') + ')' }, H.bundle) : H.items.find(x => x.key === k); if (!i) return;
const yes = await IAP.confirmBox('Get ' + i.name + ' for $' + i.usd + ', one time? It is paid by a new package purchase of $' + i.package + ' or more: your sponsor and team are paid from it as usual, you keep all its credits for your ads, and ' + (k === 'bundle' ? 'the heroes join' : 'the hero joins') + ' you in Shards of Valor the moment it settles. Credits you already hold never buy a hero.', { title: 'Bonus heroes', ok: 'Get ' + (k === 'bundle' ? 'the bundle' : i.name.split(' ')[0]), cancel: 'Not now' });
if (!yes) return; b.disabled = true;
try { const x = await api('/api/my/heroes/buy', { hero: k }); if (x.needPay) { IAP.status(x.message || 'Buy a package and the hero joins when it settles.', 'ok'); setPane('buy'); return; } }
catch (e) { IAP.status(e.message, 'bad'); b.disabled = false; }
}));
card.querySelectorAll('#gpHeroes [data-gp-go]').forEach(b => b.addEventListener('click', () => setPane('buy')));
}
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);color:var(--gold-ink)">' + esc(top.name) + ' active · until ' + esc(gpCT(top.until)) + '</span>'
@@ -2071,7 +2100,9 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
+ '<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. Each higher pass includes everything below it and adds more of Shards of Valor: weapons, gear, bonus islands, heroes and a higher level cap. <b>Paid passes add heroes, islands, a higher level cap and new looks.</b> Pass gear is never better than gear players can earn, and passes 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">Every pass is paid by a new package purchase of at least its price, so your sponsor and team are paid; you keep the package credits for your ads. Credits you already hold 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>';
+ '<p class="small muted" style="margin:10px 0 0">Every pass is paid by a new package purchase of at least its price, so your sponsor and team are paid; you keep the package credits for your ads. Credits you already hold 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>'
+ heroesHtml(gp.heroes);
wireHeroes(card, gp.heroes);
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 ' + gpLen(r.days) : 'Get ' + r.name + ' for ' + gpLen(r.days)) + ' ($' + r.usd + ')? Every pass is paid by a new package purchase of $' + r.package + ' or more: your sponsor and team are paid from it as usual, you keep all its credits for your ads, and the pass starts the moment it settles. Credits you already hold never buy a pass. The same POL caps as every pass: no extra POL.', { title: r.name, ok: r.active ? 'Extend' : 'Get ' + r.name, cancel: 'Not now' });
@@ -2116,6 +2147,10 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
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 || gp.show) && gp.heroes && gp.heroes.show) { // heroes on sale (or owned) while no pass is: a card with the heroes only
card.hidden = false; card.classList.toggle('gp-hl', !!highlight);
card.innerHTML = '<div class="card-head"><h3>\u{1F6E1}\uFE0F Shards of Valor heroes</h3><span class="sub">one time · yours for good</span></div>' + heroesHtml(gp.heroes); wireHeroes(card, gp.heroes); return;
}
if (!gp || !(gp.enabled || gp.show)) { card.hidden = true; return; }
await gpShownLoad();
if ((gp.passes || []).some(r => r.tier !== 'weekly')) return renderPassTiers(card, gp, highlight);
@@ -2139,7 +2174,9 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
+ (gp.waiting ? '<p class="small">Your pass is waiting: buy a $' + (gp.usd || 5) + ' package and it starts the moment the purchase settles. You keep every credit of the package for your ads.</p>' : '')
+ '<p style="display:flex;gap:10px;flex-wrap:wrap;align-items:center;margin:10px 0 0">'
+ (gp.waiting ? '<button class="btn" type="button" id="gpGoBuy">Buy a $' + (gp.usd || 5) + ' package</button>' : '<button class="btn" type="button" id="gpBuy">' + (gp.active ? 'Extend ' + (gp.days || 7) + ' more days' : 'Get the Pass') + ' \u00b7 buy a $' + (gp.usd || 5) + ' package</button>')
+ '<span class="small muted">Paid by a new $' + (gp.usd || 5) + ' or bigger package, so your sponsor and team are paid. You keep the package credits for your ads; credits you already hold never buy a pass.</span></p>';
+ '<span class="small muted">Paid by a new $' + (gp.usd || 5) + ' or bigger package, so your sponsor and team are paid. You keep the package credits for your ads; credits you already hold never buy a pass.</span></p>'
+ heroesHtml(gp.heroes);
wireHeroes(card, gp.heroes);
const b = $('gpBuy'); if (b) b.addEventListener('click', async () => {
const yes = await IAP.confirmBox((gp.active ? 'Extend your Game Pass by ' + (gp.days || 7) + ' days' : 'Get the Game Pass for ' + (gp.days || 7) + ' days') + '? The Pass is paid by a new package purchase of $' + (gp.usd || 5) + ' or more: your sponsor and team are paid from it as usual, you keep all its credits for your ads, and the Pass starts the moment it settles. Credits you already hold never buy a pass.', { title: 'Game Pass', ok: gp.active ? 'Extend the Pass' : 'Get the Pass', cancel: 'Not now' });
if (!yes) return;
+1 -1
View File
@@ -1263,7 +1263,7 @@
<script src="/assets/wallet.js?v=20260911a"></script>
<script src="/assets/promo.js?v=20261103gp"></script>
<script src="/assets/support.js?v=20261101th"></script>
<script src="/assets/my.js?v=20261104il"></script>
<script src="/assets/my.js?v=20261105hr"></script>
<script src="/assets/fuel.js?v=20261025ff"></script>
<script src="/assets/engine-room.js?v=20261101th"></script>
<script src="/assets/chat.js?v=20261016n"></script>
+3
View File
@@ -11,6 +11,7 @@
# bash qa/run.sh door # Spooky Doors door + costume shop flows on their own local copy (qa/door.mjs boots it)
# bash qa/run.sh warpwares # Warp & Wares: Games card gating, the hand-off, a sponsor dock on the refuel rail (visit kind dock + its cap), chatbot gating (qa/warpwares.mjs boots a local copy + a mock game)
# bash qa/run.sh gamepass # Game Pass buy flow + account-wide POL caps (polgrant) on their own local copy (qa/gamepass.mjs boots it)
# bash qa/run.sh sov-passes # (+ qa/sov-heroes-store.cjs: Shards of Valor bonus heroes sold one time, also runs in member)
# bash qa/run.sh sov-passes # pass tiers (Explorer/Champion/Sovereign/Legend): store unit checks + admin buys Explorer + Sovereign with seeded purchased credits on a local copy (screenshots D:/tmp/sov-passes)
# bash qa/run.sh nas # Network Ad Space billing: served-count trap, stopped-ad restart (no phantom delivery), the 1/N network rate + PassiveDrip partner visits (stubbed NAS, throwaway data)
# bash qa/run.sh login-queue # prepaid login-ad line: JSON store end to end + the MySQL path's lease/guard logic against a fake SQL layer (no server, throwaway data)
@@ -65,6 +66,7 @@ elif [ "$MODE" = "member" ]; then
node qa/walletnudge.test.cjs || status=1
node qa/bixpay.test.cjs || status=1
node qa/profile-policy.test.cjs || status=1
node qa/sov-heroes-store.cjs || status=1
elif [ "$MODE" = "theme" ]; then
start_local 8797 && { LOCAL=http://127.0.0.1:8797 node qa/theme-contrast.mjs || status=1; }; stop_local 8797
elif [ "$MODE" = "policy" ]; then
@@ -89,6 +91,7 @@ elif [ "$MODE" = "gamepass" ]; then
node qa/gamepass.mjs || status=1
elif [ "$MODE" = "sov-passes" ]; then
node qa/sov-passes-store.cjs || status=1
node qa/sov-heroes-store.cjs || status=1
node qa/sov-passes-local.mjs || status=1
elif [ "$MODE" = "nas" ]; then
node qa/nas-served.mjs || status=1
+89
View File
@@ -0,0 +1,89 @@
// Shards of Valor bonus heroes (2026-11-05, Marty approved): unit checks of the gamepass.js hero store, no server.
// node qa/sov-heroes-store.cjs
// Sold ONE TIME, paid exactly like a pass: buy opens a waiting order; a FRESH package of at least the price, by one of the member's own
// positions, fulfils it. Covers: the heroSales switch (off refuses members, the admin test may buy), $20 each / $50 bundle (Valda, Morag,
// Roland by default), order -> fulfil -> ownership (permanent, no expiry), the bundle grants all three, no double charge (owned hero
// refused, a waiting order for an owned hero cancelled, each tx once, one package one order), packages bought before the order or too
// small, a pass order and a hero order side by side, settings (price 0 = free for everyone, bundle list), the hand-off claim (heroes,
// heroBundle, heroSale, heroBundleCap only when set), comp / revoke, stats, and that hero sales never touch the pass records. Exit 1 on failure.
'use strict';
const fs = require('fs'); const os = require('os'); const path = require('path');
const gp = require('../gamepass');
let fails = 0; const ok = (c, label, extra) => { console.log((c ? 'PASS ' : 'FAIL ') + label + (extra ? ' ' + extra : '')); if (!c) fails++; };
const SC = { gamePassEnabled: '1', sovTiers: '0', heroSales: '0', capsStartDate: '2026-10-01' };
const maps = {};
gp.init({ dataDir: fs.mkdtempSync(path.join(os.tmpdir(), 'iap-heroes-')), siteConfig: () => Object.assign({}, SC), persistedMap: k => (maps[k] = maps[k] || new Map()), isProd: false,
accounts: { byMemberId: async () => null, byEmail: async () => null }, marks: { claim: async () => true }, polUsd: async () => 0.1, telegram: async () => {}, notify: async () => {} });
const passes = maps.gamepass, orders = maps.gporders;
const T0 = Date.parse('2026-11-05T19:00:00Z');
let txN = 0;
const pkg = (email, cents, at, tx) => gp.onEvent({ type: 'Purchase', priceCents: cents, tx: tx || ('0xhero' + (++txN)), ts: at, devEmail: email, devMinedAt: at, devNow: at });
(async () => {
// 1. defaults and the switch
const c = gp.cfg().heroes;
ok(c.sale === false && c.price.kestrel === 2000 && c.price.valda === 2000 && c.price.morag === 2000 && c.price.roland === 2000 && c.bundle.price === 5000 && c.bundle.heroes.join() === 'valda,morag,roland' && c.cap === null && c.free.length === 0,
'defaults: heroSales off, $20 each, $50 bundle of Valda + Morag + Roland, no bundle cap, nothing free', JSON.stringify(c));
let r = gp.buyHero('m@x.com', T0, 'kestrel'); ok(r.error === 'Bonus heroes are not on sale yet.', 'heroSales off: a member is refused', JSON.stringify(r));
ok(![...orders.values()].length, 'a refused buy opens no order');
let v = gp.view('m@x.com', T0).heroes; ok(v.show === false && v.items.every(i => !i.open), 'heroSales off: the member card hides the heroes', JSON.stringify(v.items.map(i => i.open)));
v = gp.view('admin@x.com', T0, { preview: true }).heroes; ok(v.show && v.preview && v.items.every(i => i.open) && v.bundle.open && v.items.map(i => i.package).join() === '20,20,20,20' && v.bundle.package === 50, 'the admin preview: every hero open, $20 packages, the bundle on the $50 package', JSON.stringify(v));
r = gp.buyHero('admin@x.com', T0, 'roland', { preview: true }); ok(r.needPay && r.price === 2000 && r.package === 20 && /Roland the Paladin joins you in Shards of Valor/.test(r.message) && !/—/.test(r.message), 'the admin test opens a $20 order', JSON.stringify(r));
r = gp.cancelHeroOrder('admin@x.com', 'roland'); ok(r.ok && r.order, 'the admin cancels the test order');
ok(!(await pkg('admin@x.com', 2000, T0 + 1000)), 'a cancelled order is never fulfilled later');
// 2. on sale: one hero, order then a fresh package
SC.heroSales = '1';
r = gp.buyHero('m@x.com', T0, 'kestrel'); ok(r.needPay && r.payUrl.includes('#buy') && r.usd === 20, 'on sale: buy opens a waiting order, no charge', JSON.stringify(r));
const r2 = gp.buyHero('m@x.com', T0 + 10, 'kestrel'); ok(r2.reused && r2.order === r.order, 'a second click reuses the same order');
ok(!(await pkg('m@x.com', 2000, T0 - 60000)), 'a package bought before the order does not fulfil it');
ok(!(await pkg('m@x.com', 1000, T0 + 1000)), 'a $10 package is too small');
let ev = await pkg('m@x.com', 2000, T0 + 2000, '0xkes1');
ok(ev && ev.hero === 'kestrel' && ev.heroes.join() === 'kestrel', 'a fresh $20 package fulfils it', JSON.stringify(ev));
ok(gp.heroesOwned('m@x.com').owned.join() === 'kestrel', 'Kestrel is owned');
ok(!(await pkg('m@x.com', 2000, T0 + 3000, '0xkes1')), 'the same tx never counts twice');
r = gp.buyHero('m@x.com', T0 + 4000, 'kestrel'); ok(/already have Kestrel/.test(r.error || ''), 'no double charge: an owned hero is refused', JSON.stringify(r));
const rec = passes.get('m@x.com'); ok(rec.heroes.kestrel.tx === '0xkes1' && rec.heroes.kestrel.via === 'package' && rec.heroes.kestrel.usd === 20 && !rec.heroes.kestrel.until && !(rec.bought || []).length && !rec.tiers, 'stored for good (no expiry), never as a pass sale', JSON.stringify(rec));
ok(gp.flag('m@x.com', T0).active === false, 'a hero is not a Game Pass');
ok(gp.heroesOwned('m@x.com').owned.includes('kestrel') && gp.heroesOwned('m@x.com', T0 + 3650 * 86400000).owned.includes('kestrel'), 'owned years later too');
// 3. the bundle: all three, and its refusals
r = gp.buyHero('m@x.com', T0, 'bundle'); ok(r.needPay && r.price === 5000 && r.package === 50 && /Valda the Barbarian, Morag the Druid, Roland the Paladin/.test(r.message), 'Kestrel owner may buy the bundle (Kestrel is not in it)', JSON.stringify(r));
ok(!(await pkg('m@x.com', 2000, T0 + 5000)), 'a $20 package does not pay the $50 bundle');
ev = await pkg('m@x.com', 5000, T0 + 6000);
ok(ev && ev.hero === 'bundle' && ev.heroes.join() === 'valda,morag,roland', 'a $50 package fulfils the bundle: all three', JSON.stringify(ev));
ok(gp.heroesOwned('m@x.com').owned.join() === 'kestrel,valda,morag,roland' && gp.heroesOwned('m@x.com').bundle, 'four owned, bundle flag set');
r = gp.buyHero('m@x.com', T0, 'bundle'); ok(/already have/.test(r.error || ''), 'the bundle twice: refused');
r = gp.buyHero('n@x.com', T0, 'morag'); await pkg('n@x.com', 2000, T0 + 100); r = gp.buyHero('n@x.com', T0 + 200, 'bundle');
ok(/already have Morag the Druid, so the bundle is not for you/.test(r.error || ''), 'a member who owns one bundle hero is sent to buy the rest one at a time', JSON.stringify(r));
// 4. a waiting order made pointless by a bundle is cancelled (no second charge); one package fulfils one order
gp.buyHero('o@x.com', T0, 'valda'); gp.buyHero('o@x.com', T0 + 1, 'bundle');
ev = await pkg('o@x.com', 5000, T0 + 1000); ok(ev && ev.hero === 'bundle', 'a $50 package picks the highest-priced order it covers (the bundle)', JSON.stringify(ev));
ok(![...orders.values()].some(o => o.email === 'o@x.com' && o.status === 'waiting'), 'the Valda order is cancelled: Valda came with the bundle');
ok(!(await pkg('o@x.com', 2000, T0 + 2000)), 'a later package charges nothing more for her');
// a pass order and a hero order side by side: each package fulfils one
gp.buy('p@x.com', T0, 'weekly'); gp.buyHero('p@x.com', T0, 'roland');
const e1 = await pkg('p@x.com', 2000, T0 + 1000), e2 = await pkg('p@x.com', 500, T0 + 2000);
ok(e1 && e1.hero === 'roland' && e2 && e2.tier === 'weekly' && gp.flag('p@x.com', T0 + 3000).active, 'a $20 package pays the hero, a $5 package the weekly pass', JSON.stringify({ e1, e2 }));
// 5. settings: price 0 = free for every account; bundle list
SC.heroPriceKestrelCents = '0';
ok(gp.heroesOwned('nobody@x.com').owned.join() === 'kestrel', 'Kestrel priced 0: owned by every account');
r = gp.buyHero('q@x.com', T0, 'kestrel'); ok(/free for everyone/.test(r.error || ''), 'a free hero is never sold');
let claim = gp.heroClaim('nobody@x.com'); ok(claim.heroes.join() === 'kestrel' && claim.heroSale.free.join() === 'kestrel' && claim.heroBundle === false && !('heroBundleCap' in claim), 'the hand-off says Kestrel is free (the game opens her for guests too)', JSON.stringify(claim));
delete SC.heroPriceKestrelCents; SC.heroBundleHeroes = 'kestrel,valda,morag';
ok(gp.cfg().heroes.bundle.heroes.join() === 'kestrel,valda,morag', 'the bundle list is a setting');
delete SC.heroBundleHeroes;
// 6. the hand-off claim and the bundle cap (unset by default; only for bundle owners once set)
claim = gp.heroClaim('m@x.com'); ok(claim.heroes.join() === 'kestrel,valda,morag,roland' && claim.heroBundle === true && !('heroBundleCap' in claim) && claim.heroSale.bundle.join() === 'valda,morag,roland' && claim.heroSale.each === 20 && claim.heroSale.bundlePrice === 50, 'claim: owned heroes, bundle, sale; no cap', JSON.stringify(claim));
SC.heroBundleCap = '40'; ok(gp.heroClaim('m@x.com').heroBundleCap === 40 && !('heroBundleCap' in gp.heroClaim('n@x.com')), 'heroBundleCap set: only bundle owners carry it'); delete SC.heroBundleCap;
// 7. comp, revoke, stats
r = gp.compHero('z@x.com', 'valda', 'admin hero test'); ok(r.ok && gp.heroesOwned('z@x.com').owned.join() === 'valda', 'comp grants a hero');
r = gp.revokeHero('z@x.com', 'valda', 'admin hero test'); ok(r.ok && !gp.heroesOwned('z@x.com').owned.length, 'revoke takes it back (support only)');
const st = gp.heroStats(); ok(st.sold.kestrel === 1 && st.sold.valda === 2 && st.sold.morag === 3 && st.sold.roland === 3 && st.bundles === 2 && st.usd === 160 && st.comped === 0, 'stats: per hero, bundles, dollars (3 x $20 + 2 x $50 = $160)', JSON.stringify(st));
const ps = gp.adminStats(T0 + 3000).passes; ok(ps.soldTotal === 1 && ps.usdTotal === 5, 'pass stats count only the weekly pass (no hero in the pass pool)', JSON.stringify(ps));
console.log(fails ? '\n' + fails + ' FAILED' : '\nALL PASSED'); process.exit(fails ? 1 : 0);
})().catch(e => { console.error(e); process.exit(1); });
+1 -1
View File
@@ -123,7 +123,7 @@ try {
await page.fill('#adEmail', ADMIN_EMAIL); await page.click('#adSend'); await page.waitForSelector('#adVerify:not([hidden])'); await page.click('#adVerify'); await sleep(1200);
const nav = await page.$('.bo-menu [data-pane="gamepass"]'); if (nav) { await nav.click(); await page.waitForSelector('#gpTest [data-gpt-buy="explorer"]', { timeout: 10000 }).catch(() => {}); }
let txt = await page.textContent('#gpTest').catch(() => '');
ok(/Test \/ preview, admin only/.test(txt) && /hidden from members/.test(txt) && /Sovereign/.test(txt) && /Necromancer/.test(txt) && /Legend/.test(txt) && /\$250 /.test(txt) && /for 1 year/.test(txt) && /Archer/.test(txt) && /Druid/.test(txt) && /level cap 30/.test(txt) && /\$20 /.test(txt) && !/\.99/.test(txt) && /Shards of Valor > Passes/.test(txt) && !/\u2014/.test(txt) && errs.length === 0, 'Admin > Game Pass > Tier test and preview: labelled test/preview, all five tiers with what each includes, no em dashes', errs.join(' | ') || (nav ? '' : 'admin nav not found'));
ok(/Test \/ preview, admin only/.test(txt) && /hidden from members/.test(txt) && /Sovereign/.test(txt) && /Roland the Paladin/.test(txt) && /heroSales off/.test(txt) && /Legend/.test(txt) && /\$250 /.test(txt) && /for 1 year/.test(txt) && /Archer/.test(txt) && /Druid/.test(txt) && /level cap 30/.test(txt) && /\$20 /.test(txt) && !/\.99/.test(txt) && /Shards of Valor > Passes/.test(txt) && !/\u2014/.test(txt) && errs.length === 0, 'Admin > Game Pass > Tier test and preview: labelled test/preview, all five tiers with what each includes, no em dashes', errs.join(' | ') || (nav ? '' : 'admin nav not found'));
await page.locator('#gpTestCard').scrollIntoViewIfNeeded(); await sleep(300);
await page.locator('#gpTestCard').screenshot({ path: path.join(SHOTS, '3-admin-tier-test-panel.png') });
await page.click('#gpTest [data-gpt-buy="explorer"]'); await page.waitForSelector('#dlgOk', { timeout: 5000 });
+34 -4
View File
@@ -564,7 +564,8 @@ async function boot() {
messages.init({ dataDir: DATA_DIR });
reports.init({ dataDir: DATA_DIR });
drip.init({ dataDir: DATA_DIR, mailer, accounts, chain, site: 'https://instantadpay.com' });
chatbot.init({ dataDir: DATA_DIR, chain, bixLive: () => bixpay.live(), gameLive: slug => String(siteConfig().gamesLive == null ? 'polhunter' : siteConfig().gamesLive).split(',').map(x => x.trim().toLowerCase()).includes(slug), refuelOn: () => refuel.cfg().on, passTiers: () => { const c = gamepass.cfg(); return { on: c.enabled && c.tierSales, rows: gamepass.TIER_DEFS.filter(d => d.key !== 'weekly').map(d => ({ name: d.name, perks: d.perks, price: c.tiers[d.key].price, usd: c.tiers[d.key].price / 100, days: c.tiers[d.key].days, sale: c.tiers[d.key].sale })) }; } }); // pass tiers fact follows sovTiers (2026-10-22)
chatbot.init({ dataDir: DATA_DIR, chain, bixLive: () => bixpay.live(), gameLive: slug => String(siteConfig().gamesLive == null ? 'polhunter' : siteConfig().gamesLive).split(',').map(x => x.trim().toLowerCase()).includes(slug), refuelOn: () => refuel.cfg().on, passTiers: () => { const c = gamepass.cfg(); return { on: c.enabled && c.tierSales, rows: gamepass.TIER_DEFS.filter(d => d.key !== 'weekly').map(d => ({ name: d.name, perks: d.perks, price: c.tiers[d.key].price, usd: c.tiers[d.key].price / 100, days: c.tiers[d.key].days, sale: c.tiers[d.key].sale })) }; },
heroSale: () => { const h = gamepass.cfg().heroes, N = Object.fromEntries(gamepass.HERO_DEFS.map(d => [d.key, d.name])); return { sale: h.sale, rows: gamepass.HERO_DEFS.map(d => ({ name: d.name, usd: h.price[d.key] / 100, free: h.price[d.key] === 0 })), bundle: { names: h.bundle.heroes.map(k => N[k]), usd: h.bundle.price / 100 } }; } }); // pass tiers fact follows sovTiers (2026-10-22); bonus heroes follow heroSales (2026-11-05)
setTimeout(() => ads.dailySweep().catch(e => console.error('sweep', e.message)), 60 * 1000);
setInterval(() => ads.dailySweep().catch(e => console.error('sweep', e.message)), 60 * 60 * 1000);
setInterval(() => ads.scheduleSweep().catch(e => console.error('schedule sweep', e.message)), 5 * 60 * 1000); // scheduled starts/ends
@@ -832,6 +833,11 @@ function siteConfig() {
// 2026-10-25 (Marty): prices = the one-click packages: Explorer $20, Champion $50, Sovereign $100, Legend $250 (cents below).
sovTiers: '0', gamePassExplorerEnabled: '1', gamePassExplorerPriceCredits: 2000, gamePassExplorerDays: 30, gamePassChampionEnabled: '1', gamePassChampionPriceCredits: 5000, gamePassChampionDays: 30,
gamePassSovereignEnabled: '1', gamePassSovereignPriceCredits: 10000, gamePassSovereignDays: 30, gamePassLegendEnabled: '1', gamePassLegendPriceCredits: 25000, gamePassLegendDays: 365, passTournamentTierSales: '0',
// Shards of Valor bonus heroes (2026-11-05, Marty approved; gamepass.js HERO_DEFS): sold ONE TIME, paid by a fresh package like a pass.
// heroSales = the sale switch (OFF until Marty flips it; the admin tests from Admin > Game Pass). Prices in cents: 2000 = $20 (the
// Activation package); 0 = that hero is free for every account. heroBundleHeroes = the $50 bundle's list (default Valda, Morag,
// Roland). heroBundleCap = a level cap the bundle would raise to; leave EMPTY (Marty has not approved one: the bundle is heroes only).
heroSales: '0', heroPriceKestrelCents: 2000, heroPriceValdaCents: 2000, heroPriceMoragCents: 2000, heroPriceRolandCents: 2000, heroBundlePriceCents: 5000, heroBundleHeroes: 'valda,morag,roland', heroBundleCap: '',
supportTelegramChat: '1289244227', // help desk pings: Marty's PRIVATE chat only (a positive user id; group/channel ids are refused). Sent with telegramBotToken, Hermes bot as fallback
supportTemplates: '', // help desk saved replies, JSON [{name, body}] (Admin > Support > Saved replies); empty = the built-in set
telegramGamesChatId: '', telegramGamesTopicId: '661565', // Game Achievements topic for the weekly Pass Tournament post (chat blank = the shared echo chat)
@@ -1718,7 +1724,8 @@ const SOV_SECRET = () => String(process.env.SOV_SSO_SECRET || '').trim();
const SOV_URL = () => String(process.env.SOV_URL || 'https://shardsofvalor.com').replace(/\/+$/, '');
const SOV_ALT = () => String(process.env.SOV_ALT_URLS || 'https://www.shardsofvalor.com,https://sov.saasy.top').split(',').map(x => x.trim().replace(/\/+$/, '')).filter(Boolean);
const sovSign = p => drB64u(crypto.createHmac('sha256', SOV_SECRET()).update(p).digest());
function sovMint(claims, ttlMs) { const payload = JSON.stringify(Object.assign({ iat: Date.now(), exp: Date.now() + (ttlMs || 300000), nonce: crypto.randomBytes(12).toString('hex') }, claims, gpClaim(claims))); return drB64u(payload) + '.' + sovSign(payload); }
// 2026-11-05: the bonus heroes ride along too (gamepass.heroClaim: heroes owned, heroBundle, the current sale; heroBundleCap only if set)
function sovMint(claims, ttlMs) { const payload = JSON.stringify(Object.assign({ iat: Date.now(), exp: Date.now() + (ttlMs || 300000), nonce: crypto.randomBytes(12).toString('hex') }, claims, gpClaim(claims), claims && claims.email ? gamepass.heroClaim(claims.email) : {})); return drB64u(payload) + '.' + sovSign(payload); }
function seekOpen(token) {
if (SEEK_SECRET().length < 32) return { error: 'ClutterHunt is not connected yet.' };
const [p, sig] = String(token || '').split('.'); if (!p || !sig) return { error: 'That link is not valid.' };
@@ -4399,8 +4406,8 @@ const server = http.createServer(async (req, res) => {
if (!gpSigOk(crypto.createHmac('sha256', chk.secret).update('player:' + (m > 0 ? String(m) : e) + ':' + ts).digest('hex'), sig)) return json(res, 401, { error: 'bad signature' });
const r = await gpResolve(m, e); if (!r) return json(res, 404, { error: 'no such member', pass: { active: false, until: null, tier: null, tiers: { weekly: null, explorer: null, champion: null } } });
const now = gpDevNow(u.searchParams.get('devDay'));
return json(res, 200, { ok: true, memberId: r.memberId, username: r.acct.username || null, wallet: r.acct.address || null, suspended: fraud.isSuspended(r.email),
pass: gamepass.flag(r.email, now), caps: gamepass.capsFor(r.email, now, game), gamePassEnabled: gamepass.cfg().enabled });
return json(res, 200, Object.assign({ ok: true, memberId: r.memberId, username: r.acct.username || null, wallet: r.acct.address || null, suspended: fraud.isSuspended(r.email),
pass: gamepass.flag(r.email, now), caps: gamepass.capsFor(r.email, now, game), gamePassEnabled: gamepass.cfg().enabled }, game === 'shardsofvalor' ? gamepass.heroClaim(r.email) : {}));
}
if ((p === '/api/partner/polgrant' || p === '/api/partner/polgrant/void' || p === '/api/partner/tournament/paid') && req.method === 'POST') {
let raw; try { raw = (await readRaw(req, 16384)).toString('utf8'); } catch (e) { return json(res, 413, { error: 'too big' }); }
@@ -4444,6 +4451,29 @@ const server = http.createServer(async (req, res) => {
const r = gamepass.buy(s.email, gpDevNow(b.devDay), b.tier);
return json(res, r.error ? 400 : 200, r);
}
// Shards of Valor bonus heroes (2026-11-05, Marty approved): sold one time. Buy only opens a waiting order; a FRESH package of at least the
// price ($20 hero = Activation, $50 bundle = Builder), bought by one of this member's own positions, fulfils it (gamepass.onEvent), so the
// sponsor line is paid as usual. Refused while heroSales is off (the admin tests from Admin > Game Pass).
if (p === '/api/my/heroes/buy' && req.method === 'POST') {
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
if (fraud.isSuspended(s.email)) return json(res, 403, { error: 'This account is suspended.' });
const b = await readBody(req); const r = gamepass.buyHero(s.email, Date.now(), b.hero);
return json(res, r.error ? 400 : 200, r);
}
// Admin > Game Pass hero test (2026-11-05): the admin's OWN account only, as the tier test below
if (['/api/admin/heroes/test-buy', '/api/admin/heroes/test-cancel', '/api/admin/heroes/test-comp', '/api/admin/heroes/test-revoke'].includes(p) && req.method === 'POST') {
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
const as = adminFromRequest(req); const me = String((as && as.email) || ADMIN_EMAIL || '').trim().toLowerCase();
if (!me) return json(res, 400, { error: 'No admin account email (ADMIN_EMAIL) is set.' });
const b = await readBody(req); const hero = String(b.hero || '').toLowerCase(); let r;
if (p === '/api/admin/heroes/test-buy') r = gamepass.buyHero(me, Date.now(), hero, { preview: true });
else if (p === '/api/admin/heroes/test-cancel') r = gamepass.cancelHeroOrder(me, hero);
else if (p === '/api/admin/heroes/test-comp') r = gamepass.compHero(me, hero, 'admin hero test');
else r = gamepass.revokeHero(me, hero || 'all', 'admin hero test');
if (!r.error) console.log('bonus heroes admin test', p.split('/').pop(), hero, me);
return json(res, r.error ? 400 : 200, Object.assign({ email: me, test: true, heroes: gamepass.heroView(me, Date.now(), { preview: true }) }, r));
}
if (p === '/api/admin/heroes/stats' && req.method === 'GET') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, gamepass.heroStats()); }
// Admin > Game Pass tier test (2026-10-25, Marty): every tier as members will see it, with the admin's OWN account's state, and a
// test buy of a tier that is not on sale yet (opens the same waiting order a member gets; a fresh package on /my fulfils it).
// Always the signed-in admin's own account (the bearer password falls back to ADMIN_EMAIL); never another member's.