Files
martbost abfb3e3199 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>
2026-11-05 14:04:47 -06:00

36 KiB

Game Pass: draft spec (2026-10-16)

PAYMENT RULE CHANGED 2026-10-22 (Marty): every pass is paid by a FRESH on-chain package purchase; no pass is ever bought with credits again. See "Payment: the package rail" at the end. Older sections below that mention credits describe the rule as it was.

Marty's direction (10-16): a $5 weekly Game Pass that covers all nine games and raises the daily POL cap; a tighter free cap so nobody farms the games all day for free. Pass = "more game", never pitched as payback. Free play keeps paying real POL (the "paid before they ever pay" funnel in the presentation, deck and guide).

1. What the games pay today (live settings, 7-day earnings to 2026-10-16)

Two kinds of POL rewards exist in every game:

  • Progress rewards: one-time per account (first clear of a stage, boss, sector, rival, chapter, room). Finite.
  • Daily play rewards: repeatable every day (finds, daily puzzle, patrol, gems, drips). This is the "all day" risk.
Game Progress rewards (one-time, POL) Daily play rewards (repeatable) Game cap/day Players (7d) Median / p90 / max per player-day POL out / week
PolHunter none finds 0.05-1.00 (skewed small), 3 missions/day 40 38 0.48 / 0.97 / 4.04 102.1
Gem Kingdom stages 0.02-0.15; bosses 0.25 / 0.5 / 2 / 5 / 7.5 / 10 none 40 25 0.46 / 11.35 / 25.49 101.4
SpellWheel levels 0.02-0.05; chapters 0.25-1 daily puzzle 0.03, streak 0.15 20 102 0.04 / 0.16 / 1.50 17.6
Spooky Doors (to Oct 31) ladder 0.1 / 0.25 / 0.5 / 1 / 2 none 25 11 0.85 / 1.00 / 2.00 10.7
PolyWarriors rivals 0.02-0.10, ladder 0.5, elite 0.12-0.5, elite clear 2 none (PvP pays Circuits) 20 10 0.18 / 1.09 / 4.94 8.8
ClutterHunt per room: clear 0.05, 3-star 0.05, expert 0.15, expert stars 0.10 none 20 13 0.20 / 0.95 / 1.05 6.4
PolyBreak rounds 0.02 / 0.03 / 0.05 gems 0.01-0.15, up to 0.5/day 5 39 0.02 / 0.06 / 0.12 1.3
Drip Runner chapters drips 0.05, items 5 15 0.05 / 0.15 / 0.25 1.2
Road Agent sectors 0.05-1.00 (3.60 total) patrol 0.03/day 25 5 0.08 / 0.16 / 0.16 0.5
All games 250 POL/week ($23 at 9c)

PolHunter and Gem Kingdom are 81% of the burn. PolHunter is repeatable play (and every find is a delivered sponsor visit, so that burn delivers advertiser inventory). Gem Kingdom's burn is its boss amounts: one player took 25.5 POL in a single day. No other game pays more than 2 POL for any single reward.

2. The pass

  • $5, 7 days, all nine games. One pass per account; buying while active extends by 7 days.
  • (Superseded 2026-10-22, see "Payment: the package rail".) Paid with purchased-grade credits only (500 credits = the $5 package), through the existing game-purchase path (ads.gamePurchase with purchasedOnly, the same rule as PolyWarriors mint passes). A $5 package bought while a pass order waits fulfils it (the pwpasses pattern). Earned credits never buy a pass, or no money enters and the pass is just a free cap increase.
  • Money flow is the normal on-chain split of the $5 package: $2.50 sponsor, $1.00 level 2, $0.50 level 3, $1.00 company. The company's $1 is what funds the extra POL; the games' 30% pool-share rule is an allowance, not cash.

3. Caps (account-wide, across all nine games)

Free Pass
Daily play rewards (repeatable) 0.30 POL/day 1.50 POL/day
Everything (progress + daily), paced 2.0 POL/day 5.0 POL/day
Progress rewards unchanged amounts for everyone; excess over the daily total carries to the next day (never lost) same

Why these numbers:

  • Free 0.30/day sits under PolHunter's median (0.48) and SpellWheel's p90 (0.16 stays free). The regular PolHunter hunter is the natural pass buyer; the casual SpellWheel player never notices.
  • Pass 1.50/day is above today's p90 for every game, so a pass holder keeps everything they earn today and more. Max repeatable per pass week = 10.5 POL (~$0.98), so the pass can never pay for itself and multi-accounting can't win.
  • The paced total cap stops the Gem Kingdom spike (25 POL in a day) without changing any reward amount: a 10 POL boss still pays 10 POL, over a few days.
  • Company per pass: $1.00 in, at most $0.98 out if a holder maxes the repeatable cap every day. Realistic use (about half) nets about $0.50 a pass. Progress rewards were payable to free players already, so the pass adds no cost there.

DECIDED (Marty, 2026-10-16): Gem Kingdom's bosses stay at 5 / 7.5 / 10 POL. "We need one that pays out bigger like that anyway." The paced total cap spreads a big boss payout over a few days; the amounts do not change.

3a. API contract (both sides build to this)

Built 2026-10-16 (IAP side). Clarifications and additions to this contract, none of them breaking:

  1. Where the endpoints live. GET /api/partner/player exists today on each GAME (IAP reads the player's card line from it). The pass and caps version below is served by IAP (https://instantadpay.com/api/partner/player), so a game CALLS it; nothing changes on the game's own endpoint. Same for polgrant, polgrant/void and tournament/*: all on IAP.
  2. Signature, spelled out. Each game signs with the shared secret it already holds (its *_SSO_SECRET; PolHunter uses HUNT_SSO_SECRET). 10-minute window on ts (ms).
    • GET /api/partner/player?game=<slug>&m=<memberId>&e=<email>&ts=<ms>&sig=<hex> with sig = HMAC-SHA256(secret, 'player:' + who + ':' + ts), who = memberId when > 0, else the lowercased email (the same string the games already compute for IAP's calls to them, with game added so IAP knows which secret to check).
    • POST endpoints: JSON body that includes game: <slug>, headers X-Game-Ts: <ms> and X-Game-Sig: HMAC-SHA256(secret, ts + '\n' + rawBody) hex (sign the exact bytes you send).
    • GET /api/partner/tournament/pending?game=<slug>&ts&sig with who = 'tournament'.
  3. email is accepted beside memberId. Players who have not linked a wallet have memberId: 0 in every hand-off token; send email too (the token has it) and IAP resolves the account by email. A linked position's member id resolves to the owner's account: the pass and the caps are per ACCOUNT.
  4. Extra fields in answers (additive): polgrant also returns carried (POL paid from an earlier day's deferral, already inside allowed), capHit ('daily'|'total'|null), enforced (false before capsStartDate), repeat (true when the ref was already answered), voided. caps also has enforced, pass and pending (POL deferred for this game, not yet paid). player also returns memberId, username, wallet, suspended, gamePassEnabled. A suspended account gets allowed: 0, suspended: true and nothing is recorded (a cleared account can replay the ref).
  5. Carry-forward counts against the later day's total cap (that is what "paced" means): a 10 POL boss on a 2 POL/day free account pays 1.7-2.0 a day until done, paid before that day's new grants. Carry-forward only happens on a LATER Central day than the deferral and only to the same game; the reply that carries it says carried.
  6. void reverses only that ref's own share (its allowed on its day and whatever of its deferral is still queued). POL it already caused to be carried on a later day belongs to that later day and stays. The ref remains answered as voided.
  7. Hand-off tokens carry the flag as gamePass: { active, until } (not pass, which the in-game sign-in flow already uses for its session token). Apply perks from it at sign-in; refresh from player/polgrant answers.
  8. Tournament prize payout seam. IAP records the winners and POL amounts; a game faucet (Road Agent pattern) pays them: GET /api/partner/tournament/pending answers { ok, rows: [{ week, place, email, memberId, wallet, pol, ... }] } (the same list is also under pending, the admin pane's name) for the rows still unpaid, and the paying game calls POST /api/partner/tournament/paid { game, week, place, tx } so the row leaves the list. PolHunter's faucet pays them (polhunter/lib/tournament.js, see "Games: as built"); Admin > Game Pass shows the unpaid rows meanwhile.
  9. Not deviations, just dev conveniences (non-production only): devDay: 'YYYY-MM-DD' on polgrant/player/buy fakes the Central day; POST /api/dev/gamepass-purchase fakes a package event; devPaid: true on buy skipped the credit charge (retired 2026-10-22: there is no charge any more; the dev purchase event takes minedAt, now and tx).

IAP is the single source of truth for the pass and for the account-wide caps. Every game already signs partner calls with its shared secret (the /api/partner/player pattern); the new calls use the same auth.

  • GET /api/partner/player?... (existing) additionally returns pass: { active: bool, until: ms|null } and caps: { daily: n, total: n, used: { daily: n, total: n }, day: 'YYYY-MM-DD' } (Central day).
  • POST /api/partner/polgrant body { memberId, game, kind: 'daily'|'progress', pol, ref } (ref = the game's own idempotency key, e.g. sector:3, find:<id>). Response { allowed: n, deferred: n, pass: bool, day }.
    • kind: 'daily': allowed = min(pol, dailyCapRemaining, totalCapRemaining), the rest is DROPPED (never deferred).
    • kind: 'progress': allowed = min(pol, totalCapRemaining), the rest is DEFERRED: IAP stores it and the game's next call (any kind) on a later day gets it added to allowed first (carry-forward). Nothing is ever lost.
    • Same ref twice = same answer (idempotent). Fail closed: if the game cannot reach IAP it grants nothing and retries the same ref later.
  • POST /api/partner/polgrant/void { memberId, game, ref } when a game decides not to pay after all (rare).
  • Settings on IAP (Admin > Settings, no deploy): gamePassEnabled, gamePassPriceCredits (500), gamePassDays (7), capFreeDaily 0.30, capFreeTotal 2.0, capPassDaily 1.50, capPassTotal 5.0, capsStartDate (the free caps apply only from this Central date; before it, the games' own caps stand, so the change can be announced a week ahead), passTournamentPct 5.
  • Pass purchase (superseded 2026-10-22: Buy only opens an order, a fresh package fulfils it): POST /api/my/gamepass/buy spends 500 purchased-grade credits (ads.gamePurchase with purchasedOnly); a $5 package bought while a pass order waits fulfils it (the pwpasses pattern). Buying while active extends until by 7 days. The Games tab shows the card, the state, and the expiry.
  • Games get the pass flag at the sign-in hand-off and on every polgrant response; apply perks locally.

4. Pass perks per game (more game, not more payback)

Game Pass perk (besides the higher caps)
PolHunter 5 missions/day instead of 3; Ad Detective twice a day. Finds still require the sponsor visit.
Gem Kingdom one free continue per day (small, so Crowns sales are not undercut)
SpellWheel streak bonus 0.15 -> 0.30; one free hint a day
PolyWarriors +1 daily mission; defense pay 15 -> 25 Circuits; Pass mark on the warrior card
Road Agent 2 patrols/day; +25% scrap. Fuel stays a sponsor visit.
ClutterHunt 2 free hints a day
PolyBreak gem cap 0.5 -> 1.5/day; one extra paddle per round
Drip Runner a shield at the start of every run
Spooky Doors +1 door a day while the season runs
All games Weekly Pass Tournament: cross-game leaderboard (finds, clears, wins), prizes from 5% of pass sales (25c per pass) in POL; Pass badge; gold profile frame

Ad-visit mechanics (fuel, Crowns, hints, refuels) stay as they are. Those verified visits are what advertisers pay for.

5. Build outline

  1. IAP (central): durable gamepass map {email: {until, history}}; GET /api/partner/player returns pass:{active, until}; new POST /api/partner/polgrant {member, game, kind: progress|daily, pol} -> {allowed, deferred} enforcing the account-wide caps (fail closed when IAP is unreachable; games retry); Games tab card "Game Pass: $5 for 7 days, all games"; buy flow via purchased credits or the $5 package; admin: passes sold, POL out per pass, cap hits.
  2. Each game: read the pass flag at the sign-in hand-off; call polgrant before every POL grant (replaces each game's own dailyCapPol for the account-wide rule; keep the local cap as a backstop); pace deferred progress rewards (queue, pays out next day); apply its perk; show "Pass" state and a "Get the Pass" nudge when the free cap is hit.
  3. Tournament: weekly job on IAP ranks pass holders across games, pays prizes from the games' wallets, posts to the Game Achievements topic.
  4. Chatbot, release note, presentation games slide, and the guide's games section: say "free play pays; the Pass plays more" (never "earn more").
  5. QA: iap-qa plus a scripted run per game: free cap hit -> nudge; pass bought -> cap raised; progress reward over the cap -> paid the next day; pass expiry -> back to free caps.

6. Rollout

  • Announce one week ahead (the free cap change affects today's PolHunter regulars). First week: pass at $5 with a launch tournament; watch passes sold, POL out per pass, free-tier burn, verified visits delivered.
  • Review after 14 days against: company net per pass >= $0.40, free burn under 150 POL/week, no drop in visit deliveries.

Built (IAP side, 2026-10-16)

Everything below is on IAP, behind gamePassEnabled (default off). The caps are recorded from day one and ENFORCED only from capsStartDate, so the change can be announced a week ahead and Admin can read what the caps would have done meanwhile.

Files

  • gamepass.js (new): pass store, waiting orders, cap ledger (DATA_DIR/gamepass-ledger.json, refs kept 90 days), tournament, admin stats, prune. Durable persisted maps gamepass, gporders, gpprizes (added to the DURABLE set in server.js so a deploy never wipes them).
  • server.js: settings defaults, init + hourly tournament tick + 6-hourly prune, purchase-event fulfilment (inside the marks.claim block, so two app copies never double-fulfil), partner helpers (GP_SECRETS, gpPartnerCheck, gpResolve, gpDevNow), polUsdLive() (catalog rate, 10-minute cache), gpClaim (the gamePass claim on every sign-in hand-off token, including PolHunter's), and the endpoints below.
  • public/my.html + public/assets/my.js: the Game Pass card at the top of Members > Games (state, caps line, Buy/Extend with IAP.confirmBox, waiting state with a Buy-a-package button), deep link /my#games?pass=1 (setPane now strips a ?query from the hash and highlights the card), the Overview nudge card gpNudge (shown once a day per browser after a game reports a free-cap hit, never to pass holders). Asset tag bumped to my.js?v=20261016a.
  • public/admin.html + public/assets/admin.js: Admin > Game Pass pane (passes sold week/total, active, POL out per pass week, free/pass cap hits, deferred queue, tournament last run + unpaid prizes, "Settle last week now", comp a pass). Tag admin.js?v=20261016gp.
  • chatbot.js: canned answer + FACTS line, KNOWLEDGE_DATE 2026-10-16.
  • qa/gamepass.mjs (new, bash qa/run.sh gamepass), qa/walk.mjs (Games tab card on/off + admin pane), qa/run.sh.
  • docs/GAME-PASS-RELEASE.md: the member-facing release note draft (not sent).

Settings (Admin > Settings > Site settings; all read live, no deploy): gamePassEnabled ('0'), gamePassPriceCredits (500), gamePassDays (7), capFreeDaily (0.30), capFreeTotal (2.0), capPassDaily (1.50), capPassTotal (5.0), capsStartDate ('', Central YYYY-MM-DD), passTournamentPct (5), telegramGamesTopicId ('661565'), telegramGamesChatId ('' = the shared echo chat).

Endpoints

  • Members: GET /api/my/gamepass -> { enabled, active, until, price, days, usd, waiting, bought, caps, capsStart, lastCapHit, tournament }; POST /api/my/gamepass/buy -> { ok, active, until } or { needPay: true, payUrl: '/my?from=gamepass#buy', order, price, need }. Spends gamePassPriceCredits purchased-grade credits through ads.gamePurchase(purchasedOnly) with the credit-log label "Game Pass (7 days)"; short = waiting order, fulfilled by the next $5+ package purchase event.
  • Games (signed, see 3a): GET /api/partner/player, POST /api/partner/polgrant, POST /api/partner/polgrant/void, GET /api/partner/tournament/pending, POST /api/partner/tournament/paid.
  • Admin: GET /api/admin/gamepass/stats, POST /api/admin/gamepass/comp { email, why }, POST /api/admin/gamepass/tournament/run { week?, force? }.

Tournament job: hourly tick; once Monday 9 AM Central has passed and the closed week (Mon 00:00 to Mon 00:00 Central) has no row, exactly one app copy (marks.claim('gamepass-tournament:<week>')) ranks the week's pass holders by grants reported through polgrant (progress and daily weigh the same, one point per ref with pol > 0), pool = passTournamentPct of the week's pass sales in USD at the live catalog POL rate, split 50/30/20, rows recorded in gpprizes as pending, top 3 posted to the Game Achievements topic (telegramGamesTopicId, only when enabled), winners get an inbox notice (kind notice). Comps (/comp) are passes, not sales. If the POL rate is unavailable the tick retries next hour.

Known limits / follow-ups

  • The cap ledger is a JSON file on the volume (like the other IAP side stores), not a MySQL table: during the ~30 s deploy overlap two app copies each hold their own copy and the last save wins. A grant answered by the copy that is about to stop could be re-answered fresh by the other on retry. Move refs/days into MySQL if the games report drift.
  • qa/gamepass.mjs stubs the credit charge (devPaid) for the "buy -> active" step: ads.gamePurchase(purchasedOnly) needs a position with on-chain package credits, which a local copy without RPC cannot have. The "short -> waiting order -> package fulfils it" step runs the real path. The purchasedOnly charge itself is the live PolyWarriors mint path.
  • Prize POL is not sent by IAP (see 3a item 8): PolHunter's faucet pays the pending rows every 10 minutes behind GAMEPASS=on; the Games pane lists whatever is still unpaid.
  • Settings pass through /api/admin/site like every other site setting (that endpoint accepts any key; the defaults above make the Game Pass keys show in the Site settings form).

Pass tiers: Explorer, Champion, Sovereign, Legend (IAP side, 2026-10-18; restructured 2026-10-22)

Spec: ultima-rpg/docs/IAP-PASSES-SPEC.md. Marty approved the safe form on 2026-10-18 (never more POL) and Dallas's new structure on 2026-10-22 (plus Sovereign and the yearly Legend). On 2026-10-25 Marty set every tier price to an InstantAdPay one-click package amount ($5, $10, $20, $50, $100, $250, $500), so the cheapest qualifying package is exactly the pass price and the pass comes with that package's ad credits (was $19.99 / $39.99 / $99.99 / $249.99). The weekly pass is unchanged. Everything above weekly stays switched off for members (sovTiers 0) until Marty flips it.

Tier Name Price Length In Shards of Valor (each includes everything below)
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, 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 caps; polgrant keeps answering pass: true (a boolean).
  • Store: record.tiers = { weekly: { until }, explorer: { until }, champion: { until }, sovereign: { until }, legend: { until } }, the legacy until mirrors the weekly tier, bought rows carry tier (missing = weekly), waiting orders carry tier (missing = weekly). Lazy migration: a record without tiers reads its until as the weekly tier.
  • Wire: flag() = { active, until, tier, tiers } (tier = highest active, until = that tier's end; tiers has all five keys). The hand-off token carries gamePass: { active, until, tier }; GET /api/partner/player carries pass: { active, until, tier, tiers }, so Shards of Valor sees sovereign / legend.
  • Buy: POST /api/my/gamepass/buy { tier } (missing = weekly). Every tier above weekly needs sovTiers on (and the weekly pass on); while off, nobody sees or buys them on /my, the admin included (2026-10-25: the member card shows every account the member view). The admin tests them in Admin > Game Pass > Tier test and preview (GET /api/admin/gamepass/preview, POST /api/admin/gamepass/test-buy | test-cancel | test-comp { tier }, always the signed-in admin's own account). Short of purchased credits: a waiting order per tier; a package of at least the tier price fulfils the highest-priced order it covers (one pass per purchase, each tx once). Copy names the package that pays for the pass, which since 2026-10-25 is exactly the price: $20 (Explorer), $50 (Champion), $100 (Sovereign), $250 (Legend); the card says the pass comes with that package's ad credits.
  • Renew / expiry: no auto-renew, no proration. Buying again extends that tier from max(now, until) by its length (Legend: 365 days). Tiers run side by side; when a higher one ends the next one shows through. Admin comp takes a tier; POST /api/admin/gamepass/revoke { email, tier, why } ends one tier now (support refunds only, credits are not returned by it).
  • Tournament: any tier holds a seat; only weekly sales feed the pool unless passTournamentTierSales is 1 (then every tier's sales do).
  • Settings (defaults): sovTiers 0; kill switches gamePassExplorerEnabled / gamePassChampionEnabled / gamePassSovereignEnabled / gamePassLegendEnabled 1 (a 0 stops one tier); gamePassExplorerPriceCredits 2000, gamePassChampionPriceCredits 5000, gamePassSovereignPriceCredits 10000, gamePassLegendPriceCredits 25000; gamePassExplorerDays / gamePassChampionDays / gamePassSovereignDays 30, gamePassLegendDays 365; passTournamentTierSales 0. A value saved in the site settings file wins over these defaults.
  • Chatbot: while sovTiers is off the assistant only says more passes are coming soon (no prices, no contents, no date); once on, its fact lists each tier on sale with the live price, length and contents.
  • Member UI: the Games tab card shows the tiers side by side (end dates in Central time); /my#passes opens it (the Shards of Valor Buy button). Admin: Game Pass pane "By pass tier" table, comp per tier, end-a-tier button.
  • Tests: bash qa/run.sh sov-passes (store unit checks + a local copy where the admin buys Explorer and Sovereign through the real ads.gamePurchase(purchasedOnly) path with credits seeded by qa/sov-passes-stub.cjs, and a Legend order is fulfilled by a $250 package).

Games: as built (2026-10-16, local commits only, nothing deployed)

Everything is behind GAMEPASS=on (env, default off = today's behaviour, so the games can be deployed before launch). IAP_URL is read where it already existed (default https://instantadpay.com). No reward amount changed anywhere; every game's local dailyCapPol / pool / hidden ceiling still stands in FRONT of the IAP call as a backstop and none was raised.

The shared client polgrant.js (byte-identical copy in every repo, md5 f3c00b90…116a; change one, copy to the rest): spooky-doors/server/, road-agent/server/, match3-game/server/, seek-game/, spellwheel/, polybreak/, cyber-battle/game/, polhunter/lib/, drip-runner/lib/.

  • grant({ memberId, email, kind, pol, ref }) -> POST /api/partner/polgrant { game, memberId, email, kind, pol, ref }, headers X-Game-Ts + X-Game-Sig (plus an informational X-Game), 6 s timeout. Returns { allowed, deferred, carried, pass, day, capHit, enforced, repeat, suspended, retry: false } or { allowed: 0, retry: true, error } on ANY non-200 / non-JSON / network error (fail closed; a 404 "no such member" is also a retry, so the games only call it for signed-in IAP members).
  • email always rides along (wallet-less members have memberId: 0; Drip Runner maps its negative emailId to 0). whoOf() = the member id when > 0, else the lowercased email; the pass cache and the retry queue key on it.
  • voidGrant, fetchPass (GET /api/partner/player, cached 10 min, fail-soft), passOf / rememberPass (hand-off claim gamePass: { active, until } + every answer), view() for the lobby, note(resp, kind, nominal) = the player-facing line.
  • Retry queue polgrantq in each game's store: enqueue dedupes per (who, ref); retry(pay) every 5 min, 48 h then stuck + notify('gpstuck') once (each game routes it to its faucet alert path); queued() keeps a waiting ref from being re-asked.
  • Carry-forward collection (SD-pattern games): carrySweep() on the existing tick, once a Central day per account with gpOwed > 0, a zero-POL progress call with ref carry:<YYYY-MM-DD>; IAP folds the carry into allowed (carried). gpOwed is bookkeeping (+= deferred, -= carried); the money truth is IAP's. IAP accepts pol: 0 (verified by the integration test below).
  • tournamentPending() reads rows from GET /api/partner/tournament/pending; tournamentPaid(row, tx) posts { game, id?, week, place, memberId, email, tx } (PolHunter only).

Per game

Game Files Refs (kind) Pass perk Tests
Spooky Doors (spooky-doors) server/pol.js (quote/settleGrant/grantGated/payQueued/carrySweep), server/game.js, server/server.js, server/social.js, src/main.js, test/gamepass.mjs rung:<n> (progress) +1 door/day while the season runs sim 63/63, gamepass 37/37, e2e 200 pass / 3 pre-existing timing fails
Road Agent (road-agent) server/pol.js, server/game.js, server/server.js, server/social.js, src/main.js, test/gamepass.mjs sector:<n> (progress); patrol:<day>, patrol:<day>:2 (daily) 2 patrols/day, +25% scrap sim pass, gamepass 22/22, e2e pass
Gem Kingdom (match3-game) server/pol.js, server/server.js (/api/continue/free), src/world.js, src/battle.js, src/game.js, test/gamepass.cjs stage:<n> (progress, bosses included) one free continue/day, no sponsor visit kingdom.test pass, gamepass 26/26, vite build ok
ClutterHunt (seek-game) pol.js, server.js, public/game.js, public/index.html (game.js?v=20261016gp), test/gamepass.js <season>:<room>:<clear or stars or xclear or xstars> (progress) 2 bonus hints banked once per Central day gamepass 23/23
SpellWheel (spellwheel) pol.js (streakPassPol: 0.30), server.js, public/play.js, public/play.html (play.js?v=7), test/gamepass.js level:<ch>:<n>, chapter:<ch> (progress); daily:<day>, streak:<day> (daily) streak 0.15 -> 0.30, 1 free hint/day gamepass 25/25
PolyBreak (polybreak) pol.js (gemDailyPassPol: 1.5), server.js, public/play.js, public/play.html (play.js?v=6), test/gamepass.js round:<n> (progress); gem:<run>:<id> (daily) gem ceiling 0.5 -> 1.5/day; +1 paddle per round gamepass 27/27, run.js 70/70
PolyWarriors (cyber-battle/game) pol.js, server.js (DEF_PAY_PASS 25), missions.js (3 + pass), public/game.js, public/game.html (game.js?v=30), test/gamepass.js rival:<id>, ladder, elite (progress) +1 daily mission (4), held defense 15 -> 25 Circuits, Pass row on the profile (card.js untouched) gamepass 26/26
Drip Runner (drip-runner) lib/ledger.js (chapterDripGated), lib/game.js, server.js, public/play.js, public/play.html (play.js?v=20261016gp), test/gamepass.js chapter:<n> (progress; the only POL it pays) a shield at every run start gamepass 28/28, run.js pass
PolHunter (polhunter) lib/rewards.js (status capped / gp-wait), lib/detective.js, lib/faucet.js (HUNT_DRY_RUN), lib/tournament.js (new), server.js, public/app.js, public/app.html (app.js?v=22), test/gamepass.js find:<missionId>:<day>, detective:<boxId> (daily) 5 missions/day (+2), 2 Ad Detective cases/day gamepass 42/42, run.js pass

Game commits (local, not pushed): spooky-doors f54ef0c, road-agent d345bbf, match3-game 972dd71, seek-game 9751329, spellwheel b582b72, polybreak e9c3a54, cyber-battle/game fa76d30, drip-runner a7b1fd9, polhunter 7391fd7 + 08486e1. Spooky Doors, Road Agent and Gem Kingdom are Vite builds (hashed assets, no ?v= bump).

Decisions taken on the games side (flip if wanted)

  1. Advertiser-funded PolHunter missions (mission.paid) are NOT gated: the advertiser paid for that completion. Gate them in polhunter/server.js (gp.on() && !m.paid) if the cap should cover them too.
  2. A 0-allowed daily reward is still "done": a capped find counts as today's find (status capped, never reaches the faucet); a capped gem/patrol/daily puzzle is recorded as handled with pol: 0. The player sees the cap line with the Pass link.
  3. Fail closed, visibly: IAP unreachable = the reward is recorded (SD pattern: nothing written until IAP answers, ref queued; PolHunter: a gp-wait row settled by the queue), the player sees "Your reward is recorded and pays as soon as InstantAdPay confirms it."
  4. Perks read the cached flag (hand-off claim -> every grant answer -> fetchPass every 10 min); a pass bought mid-session shows within 10 minutes or on the next grant.
  5. Deferred progress rewards: the ledger row is written with pol: allowed (0 included) so the achievement is marked done; carry comes back through carry:<day> or any later grant.
  6. Not built: a per-game admin view of the queue (PolHunter's admin state shows queue + stuck counts and the tournament payer).

Pass Tournament payer (PolHunter lib/tournament.js): every 10 min behind GAMEPASS=on, only with the faucet wallet configured. Per pending row: a durable claim in tourney-claims BEFORE sending (id:<id> or wk:<week>:<place>), the tx hash written the moment the chain has it, then POST /api/partner/tournament/paid. A claimed row with a hash is only re-reported, never re-sent; a claim without a hash is retried after 10 min; a send failure releases the claim, leaves the row pending on IAP and alerts (tourneyfail); low balance alerts once a day. HUNT_DRY_RUN=on records wouldPay and sends nothing. Trap: a claim written during a dry run is permanent (c.dry rows are skipped forever), so a prize row seen while HUNT_DRY_RUN=on is never paid after the flag is turned off unless tourney-claims.json on the PolHunter volume is cleared. Prizes bypass the per-find daily cap and the payout threshold. Admin: /api/admin/state -> tournament and gamepass blocks.

Integration test (both sides, local): bash qa/run.sh gamepass-games (qa/gamepass-games.cjs) boots IAP like qa/gamepass.mjs and drives the REAL spooky-doors/server/polgrant.js and polhunter/lib/tournament.js against it (needs the sibling game repos under ../..): fetchPass free/pass, daily within/over cap, progress deferral, the carry:<day> zero-POL call on the next Central day (carried > 0, idempotent repeat), void, bad secret and IAP-down -> { allowed: 0, retry: true }, the retry queue, and the tournament payer in dry run and live (mocked faucet.send) until IAP's pending list is empty. 2026-10-16: 44/44 after the rows fix on the pending endpoint (the games read rows; IAP answered only pending).

Payment: the package rail (2026-10-22, Marty)

Why. A pass paid from a credit balance brings in no new money and pays nobody upline: credits come from packages whose POL was already split on chain ($2.50 sponsor, $1 level 2, $0.50 level 3, $1 company on a $5 package). Today's pass buyer paid from an old balance. From now on every pass is a fresh package purchase, so the sponsor and team are paid exactly like any package.

Rule.

  • POST /api/my/gamepass/buy { tier } never charges anything. It opens a waiting order for that tier (or returns the one already open) and answers { needPay: true, order, orderTs, package, payUrl, message }. The card sends the member to Buy credits.
  • The order is fulfilled only by an on-chain Purchase event (gamepass.onEvent, inside the marks.claim block, so one app copy acts) that meets ALL of:
    • the buyer id is one of this account's own positions: the main member id (accounts.byMemberId) or a linked position (accounts.positionByMember);
    • priceCents is at least the tier price (setting gamePass*PriceCredits, now read as cents; the copy names the package that covers it: $5, $20, $50, $100, $250);
    • the purchase was mined AFTER the order was opened: block time from eth_getBlockByNumber (server.js blockTime dep), with a 30 s clock grace; if the block cannot be read after 3 tries the indexed-at time is used (never earlier than the block);
    • the tx has never paid a pass or an order before (checked across every order and every bought row, every account).
  • One pass per purchase: the highest-priced waiting order the package covers. The member keeps every credit of the package.
  • Bought row: { via: 'package', tier, tx, cents, order, buyerId, usd: <pass price>, packageUsd }. buyerId marks the new rail.
  • Existing passes are untouched (never revoked). On 2026-10-22 production held two sales: one via: 'credits' (500 credits, campaign 513) and one via: 'package' fulfilled under the old rule (tx 0xdbfb77c7...). No order was left waiting.
  • Admin > Game Pass > Pass sales: every sale with how it was paid ("package", "credit-paid (old rule)", "package (old rule)"), pass value, package value and the package tx; the header splits the counts. Stats field passes.pay and sales.
  • Tests: qa/gamepass.mjs (order, package mined before the order refused, too small refused, another member refused, fresh package fulfils, replayed tx refused, extend while active); qa/sov-passes-store.cjs and qa/sov-passes-local.mjs updated the same way.
  • Not changed: the caps, the tiers, the tournament (pool = pass price of each sale), the hand-off claims.