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:
martbost
2026-11-14 16:21:12 -06:00
parent 4ccdb914c7
commit 911dd623c0
6 changed files with 67 additions and 40 deletions
+40 -26
View File
@@ -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); });