Kestrel is free at level 20 in Shards of Valor (Marty approved 2026-11-14, Dallas: "The Archer should be free to everyone at level 20")
gamepass.js: HERO_DEFS kestrel freeAt 20. She is never sold here any more: buyHero refuses her ("free for every player at level 20
in Shards of Valor, so she is not for sale"), a bundle setting that names her drops her, heroOrderPrices/heroOrderOpen skip her, and a
waiting Kestrel order from before is cancelled unpaid (never fulfilled by a package). A member who bought her keeps her (the hand-off
still lists kestrel); nothing refunded. Valda, Morag, Roland, the $50 bundle of those three and every price unchanged.
Member card: Kestrel shows "Free at level 20" and "Not for sale" (my.js?v=20261114kes). Chatbot canned answer + AI fact say so.
qa/sov-heroes-store.cjs reworked for it (old Kestrel buyer kept, stale order cancelled, stats $180). iap-qa member: ALL PASSED.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+3
-3
@@ -53,7 +53,7 @@ const CANNED = [
|
||||
// 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.' },
|
||||
a: 'Shards of Valor has four bonus heroes: Kestrel the Archer, Valda the Barbarian, Morag the Druid and Roland the Paladin. Kestrel is free for every player: she joins for good once a hero in your party reaches level 20, and she is not sold. Valda, Morag and Roland are each a one-time purchase, yours for good, with no subscription, and there is a bundle of those 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.' },
|
||||
@@ -290,9 +290,9 @@ function seeds() {
|
||||
// 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.';
|
||||
const base = 'Shards of Valor bonus heroes: Kestrel the Archer, Valda the Barbarian, Morag the Druid, Roland the Paladin. Kestrel is FREE for every player once a hero in the party reaches level 20 (since 2026-11-14) and is NOT sold; anyone who bought her before keeps her. Valda, Morag and Roland are 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(', ');
|
||||
const each = (h.rows || []).map(r => r.name + (r.freeAt ? ' free at level ' + r.freeAt + ' (not sold)' : 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() {
|
||||
|
||||
+20
-7
@@ -71,14 +71,19 @@ const r6 = x => Math.round((Number(x) || 0) * 1e6) / 1e6;
|
||||
// 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).
|
||||
// 2026-11-14 (Marty approved, "Yes make it free"; Dallas: "The Archer should be free to everyone at level 20"): Kestrel is FREE for every
|
||||
// player once a hero in their party reaches level 20 (the game decides, Shards of Valor classes.json freeAt) and is NOT SOLD here any more
|
||||
// (freeAt): no buy, not in any bundle, waiting Kestrel orders are cancelled unpaid. A member who bought her keeps her (record.heroes.kestrel);
|
||||
// nothing refunded. Valda, Morag and Roland, the $50 bundle and every price are unchanged.
|
||||
const HERO_DEFS = [
|
||||
{ key: 'kestrel', set: 'Kestrel', name: 'Kestrel the Archer', price: 2000, blurb: 'Quick and sharp-eyed: arrows on every foe.' },
|
||||
{ key: 'kestrel', set: 'Kestrel', name: 'Kestrel the Archer', price: 2000, freeAt: 20, 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_SOLD = HERO_DEFS.filter(d => !d.freeAt).map(d => d.key); // free at a level in the game (Kestrel at 20): never sold, never in a bundle
|
||||
const HERO_BUNDLE_DEFAULT = 'valda,morag,roland';
|
||||
|
||||
let R = null; // deps from server.js
|
||||
@@ -129,7 +134,7 @@ function cfg() {
|
||||
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 list = [...new Set(raw.split(',').map(x => x.trim().toLowerCase()).filter(k => HERO_SOLD.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 };
|
||||
@@ -362,12 +367,19 @@ async function onEvent(ev) {
|
||||
// ---- 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 heroOrders(e) {
|
||||
const out = [];
|
||||
for (const [k, o] of orders) if (o.status === 'waiting' && o.email === e && o.kind === 'hero') {
|
||||
if (HERO_DEF[o.hero] && HERO_DEF[o.hero].freeAt) { orders.set(k, Object.assign({}, o, { status: 'cancelled', cancelledAt: Date.now(), why: 'free at level ' + HERO_DEF[o.hero].freeAt + ' in the game' })); continue; } // never paid: she is free now
|
||||
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));
|
||||
const heroOrderPrices = c => [c.heroes.bundle.price].concat(HERO_SOLD.map(k => c.heroes.price[k]).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); }
|
||||
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_SOLD.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) || {};
|
||||
@@ -393,7 +405,7 @@ function grantHeroes(e, key, via, extra, now) {
|
||||
// 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 items = HERO_DEFS.map(d => { const price = c.heroes.price[d.key], fa = d.freeAt || null; return { key: d.key, name: d.name, blurb: d.blurb, price, usd: price / 100, package: packageFor(price / 100), free: price === 0, freeAt: fa, owned: own.has(d.key), waiting: !fa && !!heroOrder(e, d.key), open: !fa && 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 };
|
||||
@@ -410,6 +422,7 @@ function buyHero(email, now, key, opts) {
|
||||
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 (HERO_DEF[key].freeAt) return { error: HERO_DEF[key].name + ' is free for every player at level ' + HERO_DEF[key].freeAt + ' in Shards of Valor, so she is not for sale.' };
|
||||
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.' };
|
||||
}
|
||||
@@ -444,7 +457,7 @@ function heroStats() {
|
||||
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;
|
||||
for (const [, o] of orders) if (o.status === 'waiting' && o.kind === 'hero' && !(HERO_DEF[o.hero] && HERO_DEF[o.hero].freeAt)) out.waiting += 1;
|
||||
out.usd = Math.round(out.usd * 100) / 100; return out;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -2120,9 +2120,9 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
|
||||
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="gp-price">' + (i.free ? 'Free for everyone' : i.freeAt ? 'Free at level ' + i.freeAt : '$' + 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>';
|
||||
+ (i.owned ? '<p class="small"><b>Yours for good</b></p>' : i.freeAt ? '<span class="small muted">Not for sale: joins every player free in the game once a hero reaches level ' + i.freeAt + '.</span>' : 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>'
|
||||
|
||||
+1
-1
@@ -1311,7 +1311,7 @@
|
||||
<script src="/assets/promo.js?v=20261103gp"></script>
|
||||
<script src="/assets/support.js?v=20261101th"></script>
|
||||
<script src="/assets/netkits.js?v=20261114ns"></script>
|
||||
<script src="/assets/my.js?v=20261114sso"></script>
|
||||
<script src="/assets/my.js?v=20261114kes"></script>
|
||||
<script src="/assets/fuel.js?v=20261113sso"></script>
|
||||
<script src="/assets/engine-room.js?v=20261113sso"></script>
|
||||
<script src="/assets/netsso.js?v=20261113sso"></script>
|
||||
|
||||
+40
-26
@@ -5,7 +5,9 @@
|
||||
// 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.
|
||||
// heroBundle, heroSale, heroBundleCap only when set), comp / revoke, stats, and that hero sales never touch the pass records.
|
||||
// 2026-11-14 (Marty approved): Kestrel is free in the game at level 20, so she is never sold here (no buy, never in a bundle, a waiting
|
||||
// Kestrel order is cancelled unpaid); a member who bought her before keeps her. Exit 1 on failure.
|
||||
'use strict';
|
||||
const fs = require('fs'); const os = require('os'); const path = require('path');
|
||||
const gp = require('../gamepass');
|
||||
@@ -27,33 +29,43 @@ const pkg = (email, cents, at, tx) => gp.onEvent({ type: 'Purchase', priceCents:
|
||||
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));
|
||||
v = gp.view('admin@x.com', T0, { preview: true }).heroes; ok(v.show && v.preview && v.items.filter(i => !i.freeAt).every(i => i.open) && v.items.find(i => i.key === 'kestrel').freeAt === 20 && !v.items.find(i => i.key === 'kestrel').open && v.bundle.open && v.items.map(i => i.package).join() === '20,20,20,20' && v.bundle.package === 50, 'the admin preview: every sold hero open (Kestrel shown free at 20, not 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
|
||||
// 2. on sale: Kestrel is never sold (free at 20 in the game); a past Kestrel buyer keeps her; a waiting Kestrel order is cancelled unpaid
|
||||
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');
|
||||
r = gp.buyHero('m@x.com', T0, 'kestrel'); ok(/Kestrel the Archer is free for every player at level 20 in Shards of Valor, so she is not for sale\./.test(r.error || '') && !/\u2014/.test(r.error), 'Kestrel is refused: free at level 20', JSON.stringify(r));
|
||||
ok(![...orders.values()].some(o => o.hero === 'kestrel' && o.status === 'waiting'), 'no Kestrel order opened');
|
||||
passes.set('k@x.com', { until: 0, bought: [], heroes: { kestrel: { ts: T0 - 86400000, via: 'package', tx: '0xoldkes', cents: 2000, usd: 20 } } });
|
||||
ok(gp.heroesOwned('k@x.com').owned.join() === 'kestrel' && gp.heroClaim('k@x.com').heroes.join() === 'kestrel', 'a member who bought Kestrel before keeps her (the hand-off still says so)');
|
||||
v = gp.view('k@x.com', T0).heroes; ok(v.items.find(i => i.key === 'kestrel').owned && v.show, 'her card says Yours for good');
|
||||
orders.set('hero-oldkes', { status: 'waiting', kind: 'hero', hero: 'kestrel', email: 'w@x.com', ts: T0 });
|
||||
ok(!(await pkg('w@x.com', 2000, T0 + 1000)), 'a Kestrel order from before the change is never fulfilled');
|
||||
ok(orders.get('hero-oldkes').status === 'cancelled' && /free at level 20/.test(orders.get('hero-oldkes').why || ''), 'and it is cancelled unpaid', JSON.stringify(orders.get('hero-oldkes')));
|
||||
ok(gp.heroesOwned('w@x.com').owned.length === 0, 'nothing granted for it');
|
||||
// one sold hero: order then a fresh package
|
||||
r = gp.buyHero('m@x.com', T0, 'roland'); 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, 'roland'); 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));
|
||||
let ev = await pkg('m@x.com', 2000, T0 + 2000, '0xrol1');
|
||||
ok(ev && ev.hero === 'roland' && ev.heroes.join() === 'roland', 'a fresh $20 package fulfils it', JSON.stringify(ev));
|
||||
ok(gp.heroesOwned('m@x.com').owned.join() === 'roland', 'Roland is owned');
|
||||
ok(!(await pkg('m@x.com', 2000, T0 + 3000, '0xrol1')), 'the same tx never counts twice');
|
||||
r = gp.buyHero('m@x.com', T0 + 4000, 'roland'); ok(/already have Roland/.test(r.error || ''), 'no double charge: an owned hero is refused', JSON.stringify(r));
|
||||
const rec = passes.get('m@x.com'); ok(rec.heroes.roland.tx === '0xrol1' && rec.heroes.roland.via === 'package' && rec.heroes.roland.usd === 20 && !rec.heroes.roland.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');
|
||||
ok(gp.heroesOwned('m@x.com').owned.includes('roland') && gp.heroesOwned('m@x.com', T0 + 3650 * 86400000).owned.includes('roland'), '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);
|
||||
r = gp.buyHero('k@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), 'a Kestrel owner may buy the bundle (Kestrel is not in it)', JSON.stringify(r));
|
||||
ok(!(await pkg('k@x.com', 2000, T0 + 5000)), 'a $20 package does not pay the $50 bundle');
|
||||
ev = await pkg('k@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');
|
||||
ok(gp.heroesOwned('k@x.com').owned.join() === 'kestrel,valda,morag,roland' && gp.heroesOwned('k@x.com').bundle, 'four owned, bundle flag set');
|
||||
r = gp.buyHero('k@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));
|
||||
|
||||
@@ -68,22 +80,24 @@ const pkg = (email, cents, at, tx) => gp.onEvent({ type: 'Purchase', priceCents:
|
||||
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');
|
||||
SC.heroPriceRolandCents = '0';
|
||||
ok(gp.heroesOwned('nobody@x.com').owned.join() === 'roland', 'Roland priced 0: owned by every account');
|
||||
r = gp.buyHero('q@x.com', T0, 'roland'); ok(/free for everyone/.test(r.error || ''), 'a free hero is never sold');
|
||||
let claim = gp.heroClaim('nobody@x.com'); ok(claim.heroes.join() === 'roland' && claim.heroSale.free.join() === 'roland' && claim.heroBundle === false && !('heroBundleCap' in claim), 'the hand-off says Roland is free (the game opens him for guests too)', JSON.stringify(claim));
|
||||
delete SC.heroPriceRolandCents; SC.heroBundleHeroes = 'valda,morag';
|
||||
ok(gp.cfg().heroes.bundle.heroes.join() === 'valda,morag', 'the bundle list is a setting');
|
||||
SC.heroBundleHeroes = 'kestrel,valda,morag';
|
||||
ok(gp.cfg().heroes.bundle.heroes.join() === 'valda,morag', 'a bundle setting naming Kestrel drops her (free at 20, never sold)');
|
||||
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;
|
||||
claim = gp.heroClaim('k@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('k@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 st = gp.heroStats(); ok(st.sold.kestrel === 1 && st.sold.valda === 2 && st.sold.morag === 3 && st.sold.roland === 4 && st.bundles === 2 && st.usd === 180 && st.comped === 0 && st.waiting === 0, 'stats: per hero, bundles, dollars (4 x $20 incl. the old Kestrel sale + 2 x $50 = $180), no waiting order', 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); });
|
||||
|
||||
@@ -636,7 +636,7 @@ async function boot() {
|
||||
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 })) }; },
|
||||
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)
|
||||
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, freeAt: d.freeAt || null })), 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
|
||||
|
||||
Reference in New Issue
Block a user