Game Pass package rail, part two: Admin > Game Pass gets a Pass sales table (every sale labelled package / credit-paid (old rule) / package (old rule), pass value, package value, package tx link) and stats passes.pay + sales; the chatbot canned answer, tier fact and system prompt say every pass is paid by a new package bought after tapping Get (sponsor and team paid, credits kept for ads, held credits never buy a pass); docs/GAME-PASS.md "Payment: the package rail" section; release-note update draft (not sent); admin.js tag bumped. Fulfilment stamps the pass at the event time again (as before). Tests: sov-passes store + local rebuilt on order + fresh package (seeded credits never spent), gamepass ALL PASS, member walk 0 bugs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+4
-4
@@ -38,7 +38,7 @@ const CANNED = [
|
||||
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.' },
|
||||
{ id: 'game-pass', title: 'Game Pass and daily POL caps', q: ['What is the Game Pass?', 'Why did I hit the daily POL cap in the games?', 'Does a boss reward carry over to the next day?'], tags: ['games', 'game pass', 'daily cap', 'tournament'],
|
||||
re: /(game ?pass|pass tournament|daily (pol )?cap|pol cap|cap(ped|s)? (on|in|for) (the )?games?|hit (the|my|today.s) (free )?cap|carr(y|ied) (over|forward))/i,
|
||||
a: 'The Game Pass is $5 for 7 days and covers all nine games on your InstantAdPay account (linked positions included). Free play keeps paying real POL every day; the Pass plays more: higher daily POL caps across every game (1.50 POL a day on repeatable rewards instead of 0.30, and 5 POL a day in all instead of 2), a seat in the weekly Pass Tournament (POL prizes from 5% of pass sales, settled Mondays, top 3 posted to Game Achievements), extra plays or a perk in each game, and the gold Game Pass badge with your name. Per game: PolHunter 5 missions a day instead of 3 plus 2 Ad Detective cases; Gem Kingdom one free continue a day; Spooky Doors one extra door a day; ClutterHunt 2 bonus hints a day; SpellWheel daily streak 0.30 POL instead of 0.15 plus 1 free hint a day; PolyBreak daily gem limit 1.5 POL instead of 0.5 plus an extra paddle every round; PolyWarriors a 4th daily mission and defense pays 25 Circuits instead of 15; Drip Runner a free shield at the start of every run; Road Agent 2 patrols a day and 25% more scrap. The full list is on the Game Pass card. Caps are account-wide and reset at midnight Central. A one-time progress reward (a boss, a chapter, a sector) is never lost: whatever is over the day\u2019s total carries to the next day until it is paid in full; repeatable daily play over the daily cap is simply not paid that day. The Pass never changes how much any reward pays, so it is more game, not more payback. Buy it in Members > Games > Game Pass: it costs 500 purchased credits (credits from a package you bought; earned credits do not count). If you have none, buy a $5 package and the pass starts the moment it settles, and you keep every credit of the package for your ads. Buying while a pass is active adds 7 days.' },
|
||||
a: 'The Game Pass is $5 for 7 days and covers all nine games on your InstantAdPay account (linked positions included). Free play keeps paying real POL every day; the Pass plays more: higher daily POL caps across every game (1.50 POL a day on repeatable rewards instead of 0.30, and 5 POL a day in all instead of 2), a seat in the weekly Pass Tournament (POL prizes from 5% of pass sales, settled Mondays, top 3 posted to Game Achievements), extra plays or a perk in each game, and the gold Game Pass badge with your name. Per game: PolHunter 5 missions a day instead of 3 plus 2 Ad Detective cases; Gem Kingdom one free continue a day; Spooky Doors one extra door a day; ClutterHunt 2 bonus hints a day; SpellWheel daily streak 0.30 POL instead of 0.15 plus 1 free hint a day; PolyBreak daily gem limit 1.5 POL instead of 0.5 plus an extra paddle every round; PolyWarriors a 4th daily mission and defense pays 25 Circuits instead of 15; Drip Runner a free shield at the start of every run; Road Agent 2 patrols a day and 25% more scrap. The full list is on the Game Pass card. Caps are account-wide and reset at midnight Central. A one-time progress reward (a boss, a chapter, a sector) is never lost: whatever is over the day\u2019s total carries to the next day until it is paid in full; repeatable daily play over the daily cap is simply not paid that day. The Pass never changes how much any reward pays, so it is more game, not more payback. Get it in Members > Games > Game Pass: every pass is paid by a NEW package purchase of $5 or more. Tap Get the Pass, then buy the package; the pass starts the moment that purchase settles on chain. Your sponsor and team are paid from that package as usual, and you keep every credit of the package for your ads. Credits you already hold (earned or purchased) never buy a pass, and a package bought before you tapped Get the Pass does not count. Buying again while a pass is active adds 7 days.' },
|
||||
{ id: 'road-agent', title: 'Road Agent (night-highway shooter)', q: ['What is Road Agent?', 'How do fuel stops work in Road Agent?'], tags: ['games', 'road agent', 'fuel stop'],
|
||||
re: /(road ?agent|night.?highway|fuel stop|weapons truck)/i,
|
||||
a: 'Road Agent is the network’s night-highway shooter, live since October 15 for every member: Games tab > Road Agent > Play, or roadagent.app with your InstantAdPay email. First clear of each sector pays POL to the wallet on your InstantAdPay account, plus a daily patrol reward. Fuel comes from a sponsor visit (a fuel stop), which is a normal verified visit, so advertisers’ visits campaigns get traffic from the game automatically.' },
|
||||
@@ -196,8 +196,8 @@ function passTiersFact() {
|
||||
if (!t || !t.on) return soon;
|
||||
const rows = (t.rows || []).filter(r => r.sale);
|
||||
if (!rows.length) return soon;
|
||||
return '- GAME PASS TIERS (on sale, Members > Games > Game Pass at https://instantadpay.com/my#games): beside the $5 weekly Game Pass, ' + rows.map(r => r.name + ' $' + r.usd + ' for ' + r.days + ' days (' + r.price + ' purchased credits): ' + r.perks.join('; ')).join(' | ')
|
||||
+ '. Each higher pass includes everything below it. Every pass is a Game Pass in all nine games with the SAME daily POL caps (1.50 / 5 POL): a higher pass never pays more POL. Passes run side by side, each with its own end date; no auto-renew; buying again adds the pass length from its end date (or from now if it ended). Paid with purchased credits only; with none, a package of at least the price starts the pass when it settles. Nothing earned in a game is taken away when a pass ends.\n';
|
||||
return '- GAME PASS TIERS (on sale, Members > Games > Game Pass at https://instantadpay.com/my#games): beside the $5 weekly Game Pass, ' + rows.map(r => r.name + ' $' + r.usd + ' for ' + r.days + ' days (' + 'paid by a new package of at least $' + r.usd + '): ' + r.perks.join('; ')).join(' | ')
|
||||
+ '. Each higher pass includes everything below it. Every pass is a Game Pass in all nine games with the SAME daily POL caps (1.50 / 5 POL): a higher pass never pays more POL. Passes run side by side, each with its own end date; no auto-renew; buying again adds the pass length from its end date (or from now if it ended). Every pass is paid by a NEW package purchase of at least its price, made after tapping Get on that pass; the pass starts when it settles, the sponsor and team are paid from the package as usual, and the member keeps the package credits for ads. Credits already held never buy a pass. Nothing earned in a game is taken away when a pass ends.\n';
|
||||
}
|
||||
function systemPrompt(kbBlock) {
|
||||
return `You are the assistant on InstantAdPay (https://instantadpay.com), a membership advertising platform.
|
||||
@@ -239,7 +239,7 @@ ${passTiersFact()}- ROAD AGENT (LIVE 2026-10-15, https://roadagent.app): a night
|
||||
- VISIT PACKS ARE PAID UP FRONT (2026-09-15, Michael's question): a verified-visits campaign charges the whole pack when it is created (3 credits per visit, so 1,000 visits = 3,000 credits) and then delivers over time as members complete verified visits (each member can do at most 20 a day, so packs fill gradually: tens per day at today's size). The Campaigns row shows 'paid up front' and 'N of M visits delivered'; the credits are not being consumed again, they were reserved once. Same for featured-day bookings: a featured link is a flat buy (featuredPerDay credits per day, whole run charged when booked), its row shows 'paid up front', the day count and 'runs through <date>', and it ends on its last day ('run ended'). FEATURED CANNOT TAKE ADDED CREDITS (2026-09-16, Hugh and Michael both tried): the row offers 'Extend run' which books more days after the current run (or from today if it ended) and charges them right away; there is no 'Buy more views' on a featured row any more. Visit packs offer 'Buy more visits' (charged now, adds to the pack). Credits added to a campaign are set aside immediately (Available drops at once) and whatever is unspent returns to Available when the campaign ends.
|
||||
- BANNER CREATIVE MUST BE AN IMAGE LINK (2026-09-16): the New campaign image field needs a direct image URL (ends in .png/.jpg/.gif/.webp/.svg) or an upload; a web-page link (a join page, an imgbb/ibb.co page) is refused with a message. Easiest source: Promo tools > Banners > Copy image URL. A campaign created with a page link before this check served a broken banner and was repaired by admin.
|
||||
- PAYMENT TRACE (2026-09-16): Members > Earnings > "Trace a payment": enter a member number or @username (yourself, anyone up to 3 levels below you, or your own 3 uplines) and every purchase they were part of is listed tier by tier — who was paid at level 1/2/3 (50/20/10%), who was skipped and why ("not qualified: had N of 2 qualifying buyers then"), the platform's 20%, and a verify link to the transaction. Use it to answer "why didn't my sponsor / why didn't I get paid on X's purchase" — the usual answers are (a) the sponsor had not unlocked that level when the purchase settled (qualification never applies backwards), (b) the buyer used Qualified Start, so the purchase came from a linked wallet whose on-chain sponsor is the buyer's own main position (level 1 goes to the buyer themselves), (c) the sponsor's payouts were not switched on. Admins see the same trace under the member card in Admin > Members.
|
||||
- GAME PASS (2026-10-16, Members > Games > Game Pass): $5 for 7 days, one pass per account covering ALL NINE games (linked positions share it). Paid with 500 PURCHASED-grade credits (ads.gamePurchase purchasedOnly, the PolyWarriors mint rule; earned credits never buy a pass); with no purchased credits the pass waits and a $5 package bought meanwhile starts it automatically (the member keeps the package credits). Buying while active extends by 7 days. ACCOUNT-WIDE DAILY POL CAPS across the games, reset at midnight Central: free 0.30 POL/day on repeatable daily-play rewards and 2.0 POL/day for everything; Pass 1.50 and 5.0. Caps apply only from the announced start date (capsStartDate); until then the games' own caps stand. A one-time PROGRESS reward (stage, boss, chapter, sector, room) over the day's total is DEFERRED and carried to the next day, never lost (a 10 POL Gem Kingdom boss still pays 10 POL, over a few days); repeatable DAILY-play POL over the daily cap is dropped for that day. Reward AMOUNTS never change with the pass: say 'free play pays; the Pass plays more', NEVER 'earn more' or 'pays for itself' (max repeatable per pass week is 10.5 POL, under the $5). Pass perks per game: PolHunter 5 missions/day and Ad Detective twice; Gem Kingdom a free continue a day; SpellWheel streak 0.30 and a free hint; PolyWarriors +1 mission, defense 25 Circuits, Pass mark; Road Agent 2 patrols and +25% scrap; ClutterHunt 2 free hints; PolyBreak gem cap 1.5 and an extra paddle; Drip Runner a starting shield; Spooky Doors +1 door while the season runs. WEEKLY PASS TOURNAMENT: pass holders ranked by plays reported across the games Monday to Sunday Central; prize pool = 5% of that week's pass sales in POL (50/30/20 to the top 3), settled Mondays 9 AM Central, top 3 posted to the Game Achievements Telegram topic, prizes paid in POL by the games to the winner's InstantAdPay wallet. Members see the card, state and expiry in Members > Games (deep link /my#games?pass=1); an Overview nudge appears once a day after a game reports a free-cap hit. PER-GAME PERKS (live 2026-10-22, also listed on the Game Pass card): PolHunter 5 missions/day instead of 3 + 2 Ad Detective cases/day; Gem Kingdom 1 free continue/day; Spooky Doors +1 door/day; ClutterHunt 2 bonus hints/day; SpellWheel streak 0.30 POL instead of 0.15 + 1 free hint/day; PolyBreak gem limit 1.5 POL/day instead of 0.5 + extra paddle every round; PolyWarriors 4th daily mission + defense 25 Circuits instead of 15; Drip Runner free shield every run; Road Agent 2 patrols/day + 25% more scrap. Buying a pass unlocks the gold Game Pass achievement badge (Members > Overview badges, share or post to Telegram). New free caps start 2026-10-29.
|
||||
- GAME PASS (2026-10-16, Members > Games > Game Pass): $5 for 7 days, one pass per account covering ALL NINE games (linked positions share it). PAYMENT (changed 2026-10-22): every pass is paid by a NEW on-chain package purchase of at least the pass price ($5 for the weekly pass), bought from one of the member's own positions AFTER tapping Get the Pass. The pass starts the moment that purchase settles. The sponsor and team are paid from that package exactly like any package, and the member keeps every credit of the package for ads. Credits (earned or purchased, old balances included) NEVER buy a pass, and a package bought before tapping Get the Pass does not count; if someone asks why, say the pass is paid by a fresh package so the team that brought them in is paid too. Passes bought before this change keep running. Buying again while active extends by 7 days. ACCOUNT-WIDE DAILY POL CAPS across the games, reset at midnight Central: free 0.30 POL/day on repeatable daily-play rewards and 2.0 POL/day for everything; Pass 1.50 and 5.0. Caps apply only from the announced start date (capsStartDate); until then the games' own caps stand. A one-time PROGRESS reward (stage, boss, chapter, sector, room) over the day's total is DEFERRED and carried to the next day, never lost (a 10 POL Gem Kingdom boss still pays 10 POL, over a few days); repeatable DAILY-play POL over the daily cap is dropped for that day. Reward AMOUNTS never change with the pass: say 'free play pays; the Pass plays more', NEVER 'earn more' or 'pays for itself' (max repeatable per pass week is 10.5 POL, under the $5). Pass perks per game: PolHunter 5 missions/day and Ad Detective twice; Gem Kingdom a free continue a day; SpellWheel streak 0.30 and a free hint; PolyWarriors +1 mission, defense 25 Circuits, Pass mark; Road Agent 2 patrols and +25% scrap; ClutterHunt 2 free hints; PolyBreak gem cap 1.5 and an extra paddle; Drip Runner a starting shield; Spooky Doors +1 door while the season runs. WEEKLY PASS TOURNAMENT: pass holders ranked by plays reported across the games Monday to Sunday Central; prize pool = 5% of that week's pass sales in POL (50/30/20 to the top 3), settled Mondays 9 AM Central, top 3 posted to the Game Achievements Telegram topic, prizes paid in POL by the games to the winner's InstantAdPay wallet. Members see the card, state and expiry in Members > Games (deep link /my#games?pass=1); an Overview nudge appears once a day after a game reports a free-cap hit. PER-GAME PERKS (live 2026-10-22, also listed on the Game Pass card): PolHunter 5 missions/day instead of 3 + 2 Ad Detective cases/day; Gem Kingdom 1 free continue/day; Spooky Doors +1 door/day; ClutterHunt 2 bonus hints/day; SpellWheel streak 0.30 POL instead of 0.15 + 1 free hint/day; PolyBreak gem limit 1.5 POL/day instead of 0.5 + extra paddle every round; PolyWarriors 4th daily mission + defense 25 Circuits instead of 15; Drip Runner free shield every run; Road Agent 2 patrols/day + 25% more scrap. Buying a pass unlocks the gold Game Pass achievement badge (Members > Overview badges, share or post to Telegram). New free caps start 2026-10-29.
|
||||
- PLATFORM FACTS (2026-10-06): instantadpay.com/facts (footer link 'Platform facts') and instantadpay.com/llms.txt are the verified reference for how InstantAdPay works: contract 0xBE1ECA72AFF47d13D8E907e523F55eB9e2d365E0 on Polygon; split 50% L1 / 20% L2 (needs 2 referred $20+ buyers) / 10% L3 (needs 5) / 10% platform wallet A / 10% platform wallet B, unqualified shares pass up (25 steps) then go to wallet A; purchased credits are on-chain (engine burns them in batches), earned credits are in the site database; credits are not transferable or cashable; POL payments are final, platform may return credits when a campaign fails because of a platform problem. When someone asks how the platform, payouts, credits or refunds work, answer from these facts and link /facts.
|
||||
- CREDIT ACTIVITY LEDGER (2026-09-16): Members > Campaigns has a 'Credit activity' list (last 40 lines, newest first; also linked from the Earn credits pane) showing every real credit movement with a reason: welcome credits, sign-in bonus with streak, daily claim, inbox reads, video watches, verified visits, milestone and leaderboard bonuses, partner codes, admin/team grants, AI Copy Engine charges and refunds, flat buys (featured runs, extensions, visit packs, more visits), login-ad days, and metered delivery rolled up as one line per campaign per day ('Ad views: NAME', 'Inbox deliveries: NAME', 'Video views: NAME'); lines marked '(purchased credits)' spent on-chain purchased credits rather than the earned pool. Reservations (credits set aside for a live campaign) are NOT ledger lines; they show as 'in live campaigns'. Earned credits are spent before purchased ones, so an earn followed by a buy appears as two lines. The ledger starts 2026-09-16; nothing earlier is listed.
|
||||
- PAYMENT + MISSED-PAYMENT NOTICES (2026-09-15): every payout that lands (who bought, level, share in POL and dollars, transaction link) and every missed payout is delivered BOTH by email and as an on-site inbox message from the company account, shown in the login pop-up and the Messages card, so it is waiting when the member signs in. MISSED-PAYOUT detail: when a level-2 or level-3 share passes a member by because that level is not open on their account, the member gets an email the same minute: who bought, the POL and dollar amount they missed, how many qualifying buyers they have versus the 2 or 5 needed, and the two ways to close the gap (bring buyers, or Qualified Start). Qualified members whose wallet rejected a transfer get a different email telling them to link a regular wallet. MISSED PAYOUTS ARE ALSO PUBLIC (2026-09-16): the team's Telegram payments feed posts, by username, who was passed over on a purchase, why (not qualified yet with N of 2 buyers, or payouts not switched on), the amount, and who received it instead; the same for a sale that routed past an unactivated sponsor. Nothing about the contract changed; it is visibility.
|
||||
|
||||
@@ -23,9 +23,9 @@ Every member earns real POL in our games, and that does not change. What is new:
|
||||
instead of 2), a place in the weekly **Pass Tournament**, extra plays or a perk in each game (more PolHunter missions, a free
|
||||
continue in Gem Kingdom, a free hint in SpellWheel and ClutterHunt, an extra patrol in Road Agent, a starting shield in Drip
|
||||
Runner, an extra paddle in PolyBreak, an extra mission in PolyWarriors, an extra door in Spooky Doors), and the Pass badge.
|
||||
- **How to get it.** Members > Games > Game Pass. It costs 500 purchased credits, the credits from a package you bought. If you
|
||||
have none, buy a $5 package and the pass starts the moment it settles; you keep every credit of that package for your ads. Buying
|
||||
while a pass is active adds 7 days.
|
||||
- **How to get it.** Members > Games > Game Pass. Tap Get the Pass, then buy a new package of $5 or more. The pass starts the
|
||||
moment that purchase settles. Your sponsor and team are paid from it as usual, and you keep every credit of the package for your
|
||||
ads. Credits you already hold never buy a pass. Buying again while a pass is active adds 7 days.
|
||||
- **Account-wide daily caps, from [DATE].** Until now each game had its own daily limit. From [DATE] the limit is one number for
|
||||
your whole account across all the games, reset at midnight Central: free play 0.30 POL a day on repeatable rewards (finds, daily
|
||||
puzzles, patrols, gems, drips) and 2 POL a day for everything; with the Pass 1.50 and 5. A one-time reward (a boss, a chapter, a
|
||||
@@ -48,3 +48,25 @@ The Pass does not change what any reward pays. Free play pays; the Pass plays mo
|
||||
|
||||
Never "earn more", "pays for itself", "income". Always "free play pays; the Pass plays more". Reward amounts never change with the
|
||||
Pass. Caps are per account, per Central day. Deferred progress rewards are "paid over the next days", never "lost".
|
||||
|
||||
## Update draft, 2026-10-22: how the Game Pass is paid (not sent)
|
||||
|
||||
Status: DRAFT for Marty's review. Nothing has been posted, emailed or published.
|
||||
|
||||
**Short version (Telegram / feed)**
|
||||
|
||||
A change to how the Game Pass is paid: from today every pass is paid by a new package purchase. Tap Get the Pass in Members >
|
||||
Games, buy a package of $5 or more, and the pass starts the moment it settles. Your sponsor and team are paid from that package,
|
||||
and you keep all of its credits for your ads. Credits you already hold no longer buy a pass. Passes you already have keep running.
|
||||
|
||||
**Release note (Admin > Releases)**
|
||||
|
||||
**The Game Pass is now paid with a new package**
|
||||
|
||||
- Tap Get the Pass (or Get on any pass) in Members > Games. Then buy a package of at least the pass price: $5 for the weekly Game
|
||||
Pass.
|
||||
- The pass starts the moment that purchase settles on chain. A package bought before you tapped Get does not count.
|
||||
- Your sponsor and team are paid from that package exactly like any other package, and every credit of the package stays yours for
|
||||
your ads.
|
||||
- Credits you already hold, earned or purchased, no longer buy a pass.
|
||||
- Any pass you already have keeps running to its end date.
|
||||
|
||||
+34
-3
@@ -1,5 +1,8 @@
|
||||
# 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).
|
||||
@@ -31,7 +34,7 @@ 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.
|
||||
- Paid with **purchased-grade credits only** (500 credits = the $5 package), through the existing game-purchase path
|
||||
- (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.
|
||||
@@ -95,7 +98,7 @@ that anyway." The paced total cap spreads a big boss payout over a few days; the
|
||||
> `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` skips the credit charge.
|
||||
> 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.
|
||||
@@ -114,7 +117,7 @@ with its shared secret (the `/api/partner/player` pattern); the new calls use th
|
||||
`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: `POST /api/my/gamepass/buy` spends 500 purchased-grade credits (`ads.gamePurchase` with
|
||||
- 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.
|
||||
@@ -333,3 +336,31 @@ drives the REAL `spooky-doors/server/polgrant.js` and `polhunter/lib/tournament.
|
||||
(`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.
|
||||
|
||||
+26
-2
@@ -257,7 +257,7 @@ async function onEvent(ev) {
|
||||
.sort((x, y) => c.tiers[y.tier].price - c.tiers[x.tier].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; }
|
||||
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) : Date.now(), w.tier);
|
||||
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 };
|
||||
}
|
||||
@@ -419,6 +419,29 @@ function tierStats(t) {
|
||||
for (const k of TIERS) for (const f of ['usdWeek', 'usdMonth', 'usdTotal']) out[k][f] = Math.round(out[k][f] * 100) / 100;
|
||||
return out;
|
||||
}
|
||||
// every sale row, newest first, labelled by how it was paid. Rows from the new package rail carry buyerId (2026-10-22); the two
|
||||
// rows from before (one paid with a credit balance, one fulfilled by a package under the old rule) are labelled as such.
|
||||
function payLabel(b) {
|
||||
if (b.via === 'credits') return 'credit-paid (old rule)';
|
||||
if (b.via === 'package') return ('buyerId' in b) ? 'package' : 'package (old rule)';
|
||||
return String(b.via || '?');
|
||||
}
|
||||
function salesList(limit) {
|
||||
const out = [];
|
||||
for (const [e, p] of passes) for (const b of (p && p.bought) || []) if (isSale(b)) out.push({ ts: b.ts, email: e, tier: rowTier(b), name: TIER_NAMES[rowTier(b)], via: b.via, label: payLabel(b),
|
||||
tx: b.tx || null, usd: Number(b.usd) || 0, packageUsd: b.packageUsd || (b.cents ? b.cents / 100 : null), credits: b.credits || null, buyerId: b.buyerId || null });
|
||||
return out.sort((a, b) => b.ts - a.ts).slice(0, limit || 50);
|
||||
}
|
||||
function payMix() {
|
||||
const m = { credit: { n: 0, usd: 0 }, packageOld: { n: 0, usd: 0 }, package: { n: 0, usd: 0, packageUsd: 0 } };
|
||||
for (const [, p] of passes) for (const b of (p && p.bought) || []) {
|
||||
if (!isSale(b)) continue; const usd = Number(b.usd) || 0;
|
||||
const k = b.via === 'credits' ? 'credit' : (b.via === 'package' && !('buyerId' in b)) ? 'packageOld' : 'package';
|
||||
m[k].n += 1; m[k].usd = Math.round((m[k].usd + usd) * 100) / 100;
|
||||
if (k === 'package') m.package.packageUsd = Math.round((m.package.packageUsd + (Number(b.packageUsd) || (b.cents ? b.cents / 100 : 0))) * 100) / 100;
|
||||
}
|
||||
return m;
|
||||
}
|
||||
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;
|
||||
@@ -446,7 +469,8 @@ function adminStats(now) {
|
||||
return { enabled: c.enabled, tierSales: c.tierSales, settings: { price: c.price, days: c.days, tiers: c.tiers, tournamentTierSales: c.tournamentTierSales, free: c.free, pass: c.pass, capsStart: c.start || null, pct: c.pct, enforced: enforcedOn(c, day) },
|
||||
week: { start: ws, label: 'week of ' + dayLabel(wkFrom), day },
|
||||
tiers: tierStats(t), month: { start: monthStart(t), label: dayLabel(dayKey(monthStart(t))) + ' to date' },
|
||||
passes: { soldWeek, soldTotal, usdWeek: Math.round(usdWeek * 100) / 100, usdTotal: Math.round(usdTotal * 100) / 100, active, comped, waitingOrders: waiting },
|
||||
passes: { soldWeek, soldTotal, usdWeek: Math.round(usdWeek * 100) / 100, usdTotal: Math.round(usdTotal * 100) / 100, active, comped, waitingOrders: waiting, pay: payMix() },
|
||||
sales: salesList(50),
|
||||
pol: { week: { pass: wk.pass.allowed, free: wk.free.allowed, carried: wk.carried, dropped: wk.dropped, deferredOut: wk.deferredOut, grants: wk.grants, players: wk.players, perPass: soldWeek ? r6(wk.pass.allowed / soldWeek) : 0 }, today },
|
||||
capHits: { week: { free: { daily: wk.free.hitsDaily, total: wk.free.hitsTotal }, pass: { daily: wk.pass.hitsDaily, total: wk.pass.hitsTotal } }, would: wk.would },
|
||||
deferredQueue: { entries: qEntries, pol: qPol, members: qMembers, byGame },
|
||||
|
||||
+6
-2
@@ -552,11 +552,15 @@
|
||||
<div class="card-head"><h3>By pass tier</h3><span class="sub" id="gpTiersSub"></span></div>
|
||||
<div id="gpTiers" class="small">…</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-head"><h3>Pass sales</h3><span class="sub" id="gpSalesSub"></span></div>
|
||||
<div id="gpSales" class="small">…</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-head"><h3>Comp a pass</h3><span class="sub">support: one pass period, recorded as no sale</span></div>
|
||||
<p style="display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin:0"><input id="gpCompEmail" placeholder="member email" style="max-width:260px"><select id="gpCompTier"><option value="weekly">Game Pass (weekly)</option><option value="explorer">Explorer (monthly)</option><option value="champion">Champion (monthly)</option><option value="sovereign">Sovereign (monthly)</option><option value="legend">Legend (yearly)</option></select><input id="gpCompWhy" placeholder="why" style="max-width:220px"><button class="btn small" id="gpComp" type="button">Give one pass period</button><button class="btn small sec" id="gpRevoke" type="button">End this tier now (refund)</button></p>
|
||||
</div>
|
||||
<p class="small muted">Settings live in Settings › Site settings: gamePassEnabled (1/0), gamePassPriceCredits, gamePassDays, capFreeDaily, capFreeTotal, capPassDaily, capPassTotal, capsStartDate (Central YYYY-MM-DD; empty = caps recorded, not enforced), passTournamentPct, telegramGamesTopicId. Tiers above weekly: sovTiers (1/0, the sale switch for all of them; off = only the admin account sees them), gamePassExplorerEnabled / gamePassChampionEnabled / gamePassSovereignEnabled / gamePassLegendEnabled (0 stops one tier), gamePassExplorerPriceCredits (1999), gamePassChampionPriceCredits (3999), gamePassSovereignPriceCredits (9999), gamePassLegendPriceCredits (24999), gamePassExplorerDays / gamePassChampionDays / gamePassSovereignDays (30), gamePassLegendDays (365), passTournamentTierSales (1 = their sales feed the tournament pool; default 0). Prize POL is paid by the games from their faucets (GET /api/partner/tournament/pending), not from here.</p>
|
||||
<p class="small muted">Every pass is paid by a new package purchase of at least its price (since 2026-10-22; credits never buy a pass). The *PriceCredits settings are the pass price in cents. Settings live in Settings › Site settings: gamePassEnabled (1/0), gamePassPriceCredits, gamePassDays, capFreeDaily, capFreeTotal, capPassDaily, capPassTotal, capsStartDate (Central YYYY-MM-DD; empty = caps recorded, not enforced), passTournamentPct, telegramGamesTopicId. Tiers above weekly: sovTiers (1/0, the sale switch for all of them; off = only the admin account sees them), gamePassExplorerEnabled / gamePassChampionEnabled / gamePassSovereignEnabled / gamePassLegendEnabled (0 stops one tier), gamePassExplorerPriceCredits (1999), gamePassChampionPriceCredits (3999), gamePassSovereignPriceCredits (9999), gamePassLegendPriceCredits (24999), gamePassExplorerDays / gamePassChampionDays / gamePassSovereignDays (30), gamePassLegendDays (365), passTournamentTierSales (1 = their sales feed the tournament pool; default 0). Prize POL is paid by the games from their faucets (GET /api/partner/tournament/pending), not from here.</p>
|
||||
</div>
|
||||
|
||||
<div class="pane" id="pane-settings" hidden>
|
||||
@@ -602,6 +606,6 @@
|
||||
|
||||
<script src="/assets/common.js?v=20261016n"></script><script src="/assets/welcome.js?v=20260923b"></script>
|
||||
<script src="/assets/admin-kb.js?v=20261020kb"></script>
|
||||
<script src="/assets/admin.js?v=20261022gpt"></script><script src="/assets/admin-sponsorcheck.js?v=20261022sc"></script>
|
||||
<script src="/assets/admin.js?v=20261022gpk"></script><script src="/assets/admin-sponsorcheck.js?v=20261022sc"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1172,6 +1172,14 @@
|
||||
$('gpTiers').innerHTML = '<table class="adm-table"><tr><th>Tier</th><th>Price</th><th class="num">Active</th><th class="num">Sold week</th><th class="num">Sold month</th><th class="num">All time</th><th class="num">Renewals 30d</th><th class="num">Ending in 7 days</th><th class="num">Comped</th><th class="num">Waiting</th></tr>'
|
||||
+ (Object.keys(TS).length ? Object.keys(TS) : ['weekly', 'explorer', 'champion', 'sovereign', 'legend']).map(k => { const x = TS[k] || {}, c = TC[k] || {}; return '<tr><td style="white-space:nowrap">' + esc(x.name || k) + (c.sale ? '' : '<br><span class="chip flat">not on sale</span>') + '</td><td style="white-space:nowrap">' + (c.price || 0) + ' cr<br>' + (c.days || 0) + ' d</td><td class="num">' + (x.active || 0) + '</td><td class="num">' + (x.soldWeek || 0) + ' · ' + usd(x.usdWeek) + '</td><td class="num">' + (x.soldMonth || 0) + ' · ' + usd(x.usdMonth) + '</td><td class="num">' + (x.soldTotal || 0) + ' · ' + usd(x.usdTotal) + '</td><td class="num">' + (x.renewals30d || 0) + '</td><td class="num">' + (x.expiring7d || 0) + '</td><td class="num">' + (x.comped || 0) + '</td><td class="num">' + (x.waitingOrders || 0) + '</td></tr>'; }).join('')
|
||||
+ '</table><p class="muted" style="margin:8px 0 0">Every tier gets the same pass caps (no extra POL). Each higher tier includes everything below it and adds Shards of Valor content (Legend is yearly).</p>';
|
||||
// pass sales by how they were paid (2026-10-22: every new pass is a fresh package purchase; the old credit-paid rows stay, labelled)
|
||||
const PM = P.pay || {}, SL = r.sales || [];
|
||||
$('gpSalesSub').textContent = (PM.package ? PM.package.n : 0) + ' paid by a new package (' + usd(PM.package && PM.package.usd) + ' pass value, packages ' + usd(PM.package && PM.package.packageUsd) + ')'
|
||||
+ ' · ' + (PM.credit ? PM.credit.n : 0) + ' credit-paid (old rule, ' + usd(PM.credit && PM.credit.usd) + ')' + ' · ' + (PM.packageOld ? PM.packageOld.n : 0) + ' package under the old rule (' + usd(PM.packageOld && PM.packageOld.usd) + ')';
|
||||
const txLink = h => h ? '<a href="/tx/' + esc(h) + '" target="_blank" rel="noopener">' + esc(String(h).slice(0, 10)) + '…</a>' : '';
|
||||
$('gpSales').innerHTML = !SL.length ? '<p class="muted">No pass sold yet.</p>' : '<table class="adm-table"><tr><th>When</th><th>Member</th><th>Pass</th><th>Paid by</th><th class="num">Pass</th><th class="num">Package</th><th>Package tx</th></tr>'
|
||||
+ SL.map(x => '<tr><td style="white-space:nowrap">' + when(x.ts) + '</td><td>' + esc(x.email) + '</td><td>' + esc(x.name || x.tier) + '</td><td>' + esc(x.label) + (x.credits ? ' · ' + x.credits + ' cr' : '') + '</td><td class="num">' + usd(x.usd) + '</td><td class="num">' + (x.packageUsd ? usd(x.packageUsd) : '') + '</td><td>' + txLink(x.tx) + '</td></tr>').join('')
|
||||
+ '</table>';
|
||||
$('gpTourSub').textContent = (T.lastRun ? 'last settled ' + when(T.lastRun) : 'never run') + ' · next Monday 9 AM Central (' + when(T.next) + ') · ' + (T.pending || 0) + ' prize' + (T.pending === 1 ? '' : 's') + ' unpaid';
|
||||
const L = T.last;
|
||||
$('gpTour').innerHTML = !L ? '<p class="muted">No week settled yet. The job runs hourly and settles the closed week once Monday 9 AM Central has passed; ' + S.pct + '% of that week\u2019s pass sales becomes the POL prize pool (50 / 30 / 20).</p>'
|
||||
|
||||
+21
-8
@@ -6,6 +6,8 @@
|
||||
// Explorer in the browser through the REAL ads.gamePurchase(purchasedOnly) charge; the 500 left is short for a second Explorer
|
||||
// (waiting order, $20 package copy); the Shards of Valor hand-off token and GET /api/partner/player carry tier explorer;
|
||||
// polgrant answers pass: true with the weekly pass caps; Admin > Game Pass shows the tier table. Exit 1 on any failure.
|
||||
// 2026-10-22 (Marty): no pass is bought with credits any more. The seeded credits must stay untouched: every tier is an order plus a
|
||||
// fresh package purchase (faked locally with /api/dev/gamepass-purchase), and the card sends the member to Buy credits.
|
||||
// 2026-10-22: + Sovereign / Legend: members refused while sovTiers is off, the admin preview lists all five, the admin buys Sovereign
|
||||
// (real charge), a Legend waiting order is settled by a $250 package (a year), the token / partner player carry tier legend + tiers.
|
||||
import crypto from 'node:crypto';
|
||||
@@ -102,14 +104,23 @@ try {
|
||||
await page.click('#gpCard [data-gp-tier="explorer"]'); await page.waitForSelector('#dlgOk', { timeout: 5000 });
|
||||
await page.screenshot({ path: path.join(SHOTS, '3-admin-confirm-explorer.png') });
|
||||
await page.click('#dlgOk');
|
||||
await page.waitForFunction(() => /Explorer active/.test((document.getElementById('gpCard') || {}).textContent || ''), null, { timeout: 15000 }).catch(() => {});
|
||||
await page.waitForFunction(() => /#buy/.test(location.hash) || !!document.querySelector('.pane.on#pane-buy, [data-pane="buy"].on'), null, { timeout: 10000 }).catch(() => {});
|
||||
await sleep(800);
|
||||
ok(errs.length === 0, 'Get Explorer: no page errors, the member is sent to buy a package', page.url() + ' ' + errs.join(' | '));
|
||||
await page.screenshot({ path: path.join(SHOTS, '4-admin-sent-to-buy.png') });
|
||||
let g1 = (await api('/api/my/gamepass', null, hA)).j; const ex1 = g1.passes.find(x => x.tier === 'explorer');
|
||||
ok(!g1.active && ex1 && ex1.waiting === true && !ex1.active, 'the click opened a waiting Explorer order; nothing active yet', JSON.stringify(ex1));
|
||||
ok(!/gamepass bought with credits/.test(srvLog), 'no credit charge: the seeded purchased credits were not spent on the pass', '');
|
||||
const dv0 = (await api('/api/dev/gamepass-purchase', { data: { cents: 2000, email: ADMIN_EMAIL } })).j;
|
||||
ok(dv0 && dv0.order && dv0.order.tier === 'explorer', 'a fresh $20 package fulfils the Explorer order', JSON.stringify(dv0));
|
||||
await page.goto(B + '/my#passes'); await page.waitForFunction(() => /Explorer active/.test((document.getElementById('gpCard') || {}).textContent || ''), null, { timeout: 15000 }).catch(() => {});
|
||||
const after = await page.textContent('#gpCard');
|
||||
ok(/Explorer active/.test(after) && errs.length === 0, 'after the buy the card shows Explorer active (Central date)', errs.join(' | '));
|
||||
await page.locator('#gpCard').screenshot({ path: path.join(SHOTS, '4-admin-explorer-active.png') }); await ctx.close(); }
|
||||
ok(/Explorer active/.test(after) && errs.length === 0, 'after the package the card shows Explorer active (Central date)', errs.join(' | '));
|
||||
await page.locator('#gpCard').screenshot({ path: path.join(SHOTS, '5-admin-explorer-active.png') }); await ctx.close(); }
|
||||
g = (await api('/api/my/gamepass', null, hA)).j;
|
||||
const ex = g.passes.find(x => x.tier === 'explorer');
|
||||
ok(g.active && g.tier === 'explorer' && ex.active && Math.abs(ex.until - (Date.now() + 30 * 86400000)) < 120000, 'GET /api/my/gamepass: tier explorer, 30 days', JSON.stringify({ tier: g.tier, until: ex && new Date(ex.until).toISOString() }));
|
||||
ok(/gamepass bought with credits explorer qa-admin@example.com 1999/.test(srvLog), 'paid through the real ads.gamePurchase(purchasedOnly) path, 1999 credits', '');
|
||||
ok(/gamepass fulfilled by package explorer qa-admin@example.com/.test(srvLog), 'Explorer paid by the package rail, not credits', '');
|
||||
|
||||
// 3. the Shards of Valor hand-off token and the partner player answer carry tier explorer
|
||||
const ho = await api('/api/my/shardsofvalor', null, hA);
|
||||
@@ -127,12 +138,14 @@ try {
|
||||
// 3b. Sovereign (9999 credits, 30 days) and the yearly Legend (24999, 365 days), 2026-10-22: the admin buys Sovereign through the
|
||||
// real charge, then is short for Legend (waiting order, $250 package) and for a second Explorer; a $250 package settles Legend.
|
||||
r = await api('/api/my/gamepass/buy', { data: { tier: 'sovereign' } }, hA);
|
||||
ok(r.status === 200 && r.j.ok && r.j.tier === 'sovereign' && r.j.days === 30 && Math.abs(r.j.until - (Date.now() + 30 * 86400000)) < 120000, 'admin buys Sovereign (sovTiers off, testing): 30 days', JSON.stringify(r.j));
|
||||
ok(/gamepass bought with credits sovereign qa-admin@example.com 9999/.test(srvLog), 'Sovereign paid through the real ads.gamePurchase(purchasedOnly) path, 9999 credits', '');
|
||||
ok(r.status === 200 && r.j.needPay === true && r.j.tier === 'sovereign' && r.j.package === 100, 'admin Sovereign (sovTiers off, testing): a waiting order for a $100 package, credits untouched', JSON.stringify(r.j));
|
||||
let dvS = (await api('/api/dev/gamepass-purchase', { data: { cents: 10000, email: ADMIN_EMAIL } })).j;
|
||||
ok(dvS && dvS.order && dvS.order.tier === 'sovereign' && Math.abs(dvS.order.until - (Date.now() + 30 * 86400000)) < 120000, 'a fresh $100 package fulfils Sovereign: 30 days', JSON.stringify(dvS));
|
||||
ok(!/gamepass bought with credits/.test(srvLog), 'still no credit charge anywhere', '');
|
||||
r = await api('/api/my/gamepass/buy', { data: { tier: 'explorer' } }, hA);
|
||||
ok(r.status === 200 && r.j.needPay === true && r.j.tier === 'explorer' && r.j.available === 500 && /\$20 package/.test(r.j.message), 'a second Explorer: only 500 purchased credits left -> waiting order, "$20 package"', JSON.stringify({ needPay: r.j.needPay, available: r.j.available, payUrl: r.j.payUrl }));
|
||||
ok(r.status === 200 && r.j.needPay === true && r.j.tier === 'explorer' && /package of \$20 or more/.test(r.j.message), 'a second Explorer -> waiting order, "package of $20 or more"', JSON.stringify({ needPay: r.j.needPay, payUrl: r.j.payUrl, msg: r.j.message }));
|
||||
r = await api('/api/my/gamepass/buy', { data: { tier: 'legend' } }, hA);
|
||||
ok(r.status === 200 && r.j.needPay === true && r.j.tier === 'legend' && r.j.available === 500 && r.j.price === 24999 && r.j.payUrl === '/my?from=gamepass&tier=legend#buy' && /\$250 package/.test(r.j.message), 'Legend with 500 credits: waiting order, "$250 package", payUrl with tier', JSON.stringify({ needPay: r.j.needPay, payUrl: r.j.payUrl, msg: r.j.message }));
|
||||
ok(r.status === 200 && r.j.needPay === true && r.j.tier === 'legend' && r.j.price === 24999 && r.j.payUrl === '/my?from=gamepass&tier=legend#buy' && /package of \$250 or more/.test(r.j.message), 'Legend: waiting order, "package of $250 or more", payUrl with tier', JSON.stringify({ needPay: r.j.needPay, payUrl: r.j.payUrl, msg: r.j.message }));
|
||||
let dv = (await api('/api/dev/gamepass-purchase', { data: { cents: 10000, email: ADMIN_EMAIL } })).j;
|
||||
ok(dv && dv.order && dv.order.tier === 'explorer' && dv.order.until === ex.until + 30 * 86400000, 'a $100 package fulfils the waiting Explorer (extends it from its end), never Legend', JSON.stringify(dv));
|
||||
g = (await api('/api/my/gamepass', null, hA)).j;
|
||||
|
||||
+71
-59
@@ -1,6 +1,6 @@
|
||||
// Pass tiers (2026-10-18, ultima-rpg docs/IAP-PASSES-SPEC.md section 8): unit checks of the gamepass.js store, no server.
|
||||
// node qa/sov-passes-store.cjs
|
||||
// Loads gamepass.js with in-memory maps and a fake site config. Covers: lazy migration of a weekly-only record, buy per tier,
|
||||
// Loads gamepass.js with in-memory maps and a fake site config. Since 2026-10-22 every "buy" is an order + a fresh package (buyX). Covers: lazy migration of a weekly-only record, buy per tier,
|
||||
// extend from max(now, until), side-by-side expiry, highest active tier wins, the sovTiers switch (off refuses, admin may buy),
|
||||
// waiting orders per tier fulfilled by a big-enough package (each tx once, highest price first), the same caps for every tier
|
||||
// (no extra POL), comp and revoke, admin stats per tier (each account once at its top tier, Central week/month). Exit 1 on failure.
|
||||
@@ -18,8 +18,20 @@ gp.init({ dataDir, siteConfig: () => Object.assign({}, SC), persistedMap: k => (
|
||||
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-10-20T17:00:00Z'); // Tue Oct 20, noon Central
|
||||
const paid = async () => ({ ok: true, campaignId: 1 });
|
||||
const short = async () => ({ error: 'short', available: 0, need: 1 });
|
||||
// 2026-10-22: no pass is bought with credits any more. buy() only opens a waiting order; a fresh package Purchase fulfils it.
|
||||
// buyX keeps the old test shape: `short` = the member opens the order and pays nothing yet; any other payer (paid / a spy) = the member
|
||||
// opens the order and then buys a package of exactly the pass price, mined at `now` (the spy sees the price and the pass label).
|
||||
const paid = async () => ({ ok: true });
|
||||
const short = async () => ({ error: 'short' });
|
||||
let txN = 0;
|
||||
async function buyX(email, payer, now, tier, opts) {
|
||||
const r = gp.buy(email, now, tier, opts); if (r.error || payer === short) return r;
|
||||
const t = r.tier; const days = gp.cfg().tiers[t].days;
|
||||
await payer(r.price, (t === 'weekly' ? 'Game Pass' : gp.TIER_NAMES[t] + ' pass') + ' (' + days + ' days)');
|
||||
const ev = await gp.onEvent({ type: 'Purchase', priceCents: r.price, tx: '0xpkg' + (++txN), ts: now, devEmail: email, devMinedAt: now, devNow: now });
|
||||
if (!ev) return { error: 'package did not fulfil the order', r };
|
||||
return { ok: true, tier: ev.tier, until: ev.until, days, paid: 'package' };
|
||||
}
|
||||
|
||||
(async () => {
|
||||
// 1. migration: a record from before tiers (until only) reads as the weekly tier; flag answers as before plus tier
|
||||
@@ -29,47 +41,47 @@ const short = async () => ({ error: 'short', available: 0, need: 1 });
|
||||
f = gp.flag('old@x.com', T0 + 5 * DAY);
|
||||
ok(f.active === false && f.tier === null && f.until === T0 + 3 * DAY, 'expired weekly-only record: inactive, until kept as before tiers, tier null', JSON.stringify(f));
|
||||
f = gp.flag('never@x.com', T0); ok(f.active === false && f.until === null && f.tier === null, 'never bought: { active false, until null, tier null }', JSON.stringify(f));
|
||||
await gp.buy('old@x.com', paid, T0, 'weekly');
|
||||
await buyX('old@x.com', paid, T0, 'weekly');
|
||||
const oldRec = passes.get('old@x.com');
|
||||
ok(oldRec.tiers && oldRec.tiers.weekly.until === T0 + 10 * DAY && oldRec.until === T0 + 10 * DAY, 'buying weekly on a migrated record extends from its until and writes tiers + legacy until', JSON.stringify({ until: oldRec.until, tiers: oldRec.tiers }));
|
||||
|
||||
// 2. the switch: off refuses Explorer/Champion for members, the weekly pass is unchanged; the admin may buy
|
||||
let r = await gp.buy('a@x.com', paid, T0, 'explorer');
|
||||
let r = await buyX('a@x.com', paid, T0, 'explorer');
|
||||
ok(r.error === 'The Explorer pass is not open yet.', 'sovTiers off: Explorer refused', JSON.stringify(r));
|
||||
r = await gp.buy('a@x.com', paid, T0, 'champion');
|
||||
r = await buyX('a@x.com', paid, T0, 'champion');
|
||||
ok(r.error === 'The Champion pass is not open yet.', 'sovTiers off: Champion refused', JSON.stringify(r));
|
||||
ok(!passes.get('a@x.com'), 'a refused buy writes nothing', '');
|
||||
let v = gp.view('a@x.com', T0);
|
||||
ok(v.passes.length === 1 && v.passes[0].tier === 'weekly' && v.show === true && v.tierPreview === false, 'sovTiers off: a member sees only the weekly pass', JSON.stringify(v.passes.map(x => x.tier)));
|
||||
v = gp.view('admin@x.com', T0, { admin: true });
|
||||
ok(v.passes.map(x => x.tier).join() === 'weekly,explorer,champion,sovereign,legend' && v.tierPreview === true && v.passes.slice(1).every(x => x.open === true) && v.passes.map(x => x.price).join() === '500,1999,3999,9999,24999' && v.passes.map(x => x.days).join() === '7,30,30,30,365' && v.passes.map(x => x.package).join() === '5,20,50,100,250', 'sovTiers off: the admin sees all five (preview), prices 500 / 1999 / 3999 / 9999 / 24999, days 7 / 30 / 30 / 30 / 365, packages $5 / $20 / $50 / $100 / $250', JSON.stringify(v.passes));
|
||||
r = await gp.buy('admin@x.com', paid, T0, 'explorer', { admin: true });
|
||||
r = await buyX('admin@x.com', paid, T0, 'explorer', { admin: true });
|
||||
ok(r.ok && r.tier === 'explorer' && r.until === T0 + 30 * DAY && r.days === 30, 'sovTiers off: the admin can buy Explorer (testing)', JSON.stringify(r));
|
||||
r = await gp.buy('a@x.com', paid, T0); // tier missing = weekly
|
||||
r = await buyX('a@x.com', paid, T0); // tier missing = weekly
|
||||
ok(r.ok && r.tier === 'weekly' && r.until === T0 + 7 * DAY && r.days === 7, 'tier missing = weekly: 500 credits, 7 days, as before', JSON.stringify(r));
|
||||
let charged = null; await gp.buy('z@x.com', async (price, label) => { charged = { price, label }; return { ok: true }; }, T0);
|
||||
let charged = null; await buyX('z@x.com', async (price, label) => { charged = { price, label }; return { ok: true }; }, T0);
|
||||
ok(charged && charged.price === 500 && charged.label === 'Game Pass (7 days)', 'weekly charge unchanged: 500 credits, label "Game Pass (7 days)"', JSON.stringify(charged));
|
||||
r = await gp.buy('a@x.com', paid, T0, 'platinum'); ok(r.error === 'There is no such pass.', 'unknown tier refused', JSON.stringify(r));
|
||||
r = await buyX('a@x.com', paid, T0, 'platinum'); ok(r.error === 'There is no such pass.', 'unknown tier refused', JSON.stringify(r));
|
||||
SC.gamePassEnabled = '0'; SC.sovTiers = '1';
|
||||
r = await gp.buy('a@x.com', paid, T0, 'explorer'); ok(!!r.error, 'sovTiers on but the weekly Game Pass off: Explorer refused for members', JSON.stringify(r));
|
||||
r = await buyX('a@x.com', paid, T0, 'explorer'); ok(!!r.error, 'sovTiers on but the weekly Game Pass off: Explorer refused for members', JSON.stringify(r));
|
||||
SC.gamePassEnabled = '1';
|
||||
|
||||
// 3. on: each tier extends only itself; buying again extends from max(now, until)
|
||||
charged = null; r = await gp.buy('b@x.com', async (price, label) => { charged = { price, label }; return { ok: true }; }, T0, 'explorer');
|
||||
charged = null; r = await buyX('b@x.com', async (price, label) => { charged = { price, label }; return { ok: true }; }, T0, 'explorer');
|
||||
ok(r.ok && r.until === T0 + 30 * DAY && charged.price === 1999 && charged.label === 'Explorer pass (30 days)', 'sovTiers on: Explorer charges 1999 credits, 30 days', JSON.stringify(charged));
|
||||
let rec = passes.get('b@x.com');
|
||||
ok(rec.tiers.explorer.until === T0 + 30 * DAY && !rec.tiers.weekly && !rec.tiers.champion && rec.until === 0 && rec.bought[0].tier === 'explorer' && rec.bought[0].usd === 19.99, 'only the Explorer tier moved; legacy until (weekly) stays 0; bought row has tier + $19.99', JSON.stringify(rec));
|
||||
r = await gp.buy('b@x.com', paid, T0 + 10 * DAY, 'explorer');
|
||||
r = await buyX('b@x.com', paid, T0 + 10 * DAY, 'explorer');
|
||||
ok(r.until === T0 + 60 * DAY, 'Explorer again while active: extends from its until (+30 days, nothing lost)', new Date(r.until).toISOString());
|
||||
r = await gp.buy('c@x.com', paid, T0, 'champion'); ok(r.ok && r.until === T0 + 30 * DAY, 'Champion: 30 days', '');
|
||||
r = await gp.buy('c@x.com', paid, T0 + 45 * DAY, 'champion');
|
||||
r = await buyX('c@x.com', paid, T0, 'champion'); ok(r.ok && r.until === T0 + 30 * DAY, 'Champion: 30 days', '');
|
||||
r = await buyX('c@x.com', paid, T0 + 45 * DAY, 'champion');
|
||||
ok(r.until === T0 + 75 * DAY, 'Champion again after it ended: extends from now', new Date(r.until).toISOString());
|
||||
charged = null; await gp.buy('c2@x.com', async (price) => { charged = price; return { ok: true }; }, T0, 'champion'); ok(charged === 3999, 'Champion charges 3999 credits', String(charged));
|
||||
charged = null; await buyX('c2@x.com', async (price) => { charged = price; return { ok: true }; }, T0, 'champion'); ok(charged === 3999, 'Champion charges 3999 credits', String(charged));
|
||||
|
||||
// 4. side by side: Champion over Explorer, then Explorer shows through; weekly underneath
|
||||
await gp.buy('d@x.com', paid, T0, 'weekly'); // weekly to T0+7
|
||||
await gp.buy('d@x.com', paid, T0, 'explorer'); // explorer to T0+30
|
||||
await gp.buy('d@x.com', paid, T0 - 20 * DAY, 'champion'); // champion bought earlier, to T0+10
|
||||
await buyX('d@x.com', paid, T0, 'weekly'); // weekly to T0+7
|
||||
await buyX('d@x.com', paid, T0, 'explorer'); // explorer to T0+30
|
||||
await buyX('d@x.com', paid, T0 - 20 * DAY, 'champion'); // champion bought earlier, to T0+10
|
||||
f = gp.flag('d@x.com', T0 + DAY);
|
||||
ok(f.tier === 'champion' && f.until === T0 + 10 * DAY && f.active && f.tiers.weekly === T0 + 7 * DAY && f.tiers.explorer === T0 + 30 * DAY && f.tiers.champion === T0 + 10 * DAY, 'all three on: tier champion, until = Champion end, tiers side by side', JSON.stringify(f));
|
||||
f = gp.flag('d@x.com', T0 + 12 * DAY);
|
||||
@@ -78,7 +90,7 @@ const short = async () => ({ error: 'short', available: 0, need: 1 });
|
||||
|
||||
// 5. no extra POL: the caps are identical for weekly, explorer and champion holders (and higher than free)
|
||||
const day = '2026-10-21'; const at = Date.parse(day + 'T17:00:00Z');
|
||||
await gp.buy('w@x.com', paid, at, 'weekly'); await gp.buy('e@x.com', paid, at, 'explorer'); await gp.buy('ch@x.com', paid, at, 'champion');
|
||||
await buyX('w@x.com', paid, at, 'weekly'); await buyX('e@x.com', paid, at, 'explorer'); await buyX('ch@x.com', paid, at, 'champion');
|
||||
const capsOf = e => { const c = gp.capsFor(e, at); return [c.pass, c.daily, c.total].join('/'); };
|
||||
ok(capsOf('w@x.com') === capsOf('e@x.com') && capsOf('e@x.com') === capsOf('ch@x.com') && capsOf('w@x.com') === 'true/1.5/5' && capsOf('free@x.com') === 'false/0.3/2', 'capsFor: weekly = explorer = champion = pass caps 1.50 / 5', [capsOf('w@x.com'), capsOf('e@x.com'), capsOf('ch@x.com'), capsOf('free@x.com')].join(' '));
|
||||
const g = e => gp.grant({ email: e, game: 'polhunter', kind: 'daily', pol: 3, ref: 'cap:' + e, now: at });
|
||||
@@ -86,14 +98,14 @@ const short = async () => ({ error: 'short', available: 0, need: 1 });
|
||||
ok(gw.allowed === 1.5 && ge.allowed === 1.5 && gc.allowed === 1.5 && gw.pass && ge.pass && gc.pass, 'polgrant: a 3 POL daily grant allows 1.50 for every tier, pass: true (a boolean)', [gw.allowed, ge.allowed, gc.allowed, typeof gc.pass].join(' '));
|
||||
|
||||
// 6. waiting orders per tier; a package of at least the tier price fulfils it; each tx once; highest-priced first
|
||||
r = await gp.buy('p@x.com', short, T0, 'explorer');
|
||||
ok(r.needPay && r.tier === 'explorer' && r.payUrl === '/my?from=gamepass&tier=explorer#buy' && r.package === 20 && /\$20 package/.test(r.message), 'Explorer short: waiting order, payUrl with tier, "$20 package"', JSON.stringify({ payUrl: r.payUrl, msg: r.message }));
|
||||
r = await buyX('p@x.com', short, T0, 'explorer');
|
||||
ok(r.needPay && r.tier === 'explorer' && r.payUrl === '/my?from=gamepass&tier=explorer#buy' && r.package === 20 && /package of \$20 or more/.test(r.message), 'Explorer short: waiting order, payUrl with tier, "$20 package"', JSON.stringify({ payUrl: r.payUrl, msg: r.message }));
|
||||
const ordE = r.order;
|
||||
r = await gp.buy('p@x.com', short, T0, 'explorer'); ok(r.order === ordE, 'same tier again reuses its waiting order', '');
|
||||
r = await gp.buy('p@x.com', short, T0, 'champion'); const ordC = r.order;
|
||||
ok(r.needPay && r.order !== ordE && r.package === 50 && /\$50 package/.test(r.message), 'Champion short: its own waiting order; copy names the $50 package (there is no $40 one)', r.message);
|
||||
r = await gp.buy('p@x.com', short, T0, 'weekly');
|
||||
ok(r.payUrl === '/my?from=gamepass#buy' && /Buy a \$5 package/.test(r.message), 'weekly short: payUrl and copy exactly as before', r.payUrl);
|
||||
r = await buyX('p@x.com', short, T0, 'explorer'); ok(r.order === ordE, 'same tier again reuses its waiting order', '');
|
||||
r = await buyX('p@x.com', short, T0, 'champion'); const ordC = r.order;
|
||||
ok(r.needPay && r.order !== ordE && r.package === 50 && /package of \$50 or more/.test(r.message), 'Champion short: its own waiting order; copy names the $50 package (there is no $40 one)', r.message);
|
||||
r = await buyX('p@x.com', short, T0, 'weekly');
|
||||
ok(r.payUrl === '/my?from=gamepass#buy' && /package of \$5 or more/.test(r.message), 'weekly short: payUrl and copy exactly as before', r.payUrl);
|
||||
let ev = await gp.onEvent({ type: 'Purchase', priceCents: 500, tx: '0xa1', ts: T0 + 60000, devEmail: 'p@x.com' });
|
||||
ok(ev && ev.tier === 'weekly', 'a $5 package fulfils the weekly order, not Explorer or Champion', JSON.stringify(ev));
|
||||
ev = await gp.onEvent({ type: 'Purchase', priceCents: 1000, tx: '0xa2', ts: T0 + 60000, devEmail: 'p@x.com' });
|
||||
@@ -104,7 +116,7 @@ const short = async () => ({ error: 'short', available: 0, need: 1 });
|
||||
ok(ev === null, 'the same tx again counts once', JSON.stringify(ev));
|
||||
ev = await gp.onEvent({ type: 'Purchase', priceCents: 5000, tx: '0xa4', ts: T0 + 60000, devEmail: 'p@x.com' });
|
||||
ok(ev && ev.tier === 'champion' && ev.order === ordC, 'a $50 package fulfils the Champion order', JSON.stringify(ev));
|
||||
await gp.buy('q@x.com', short, T0, 'weekly'); await gp.buy('q@x.com', short, T0, 'explorer'); await gp.buy('q@x.com', short, T0, 'champion');
|
||||
await buyX('q@x.com', short, T0, 'weekly'); await buyX('q@x.com', short, T0, 'explorer'); await buyX('q@x.com', short, T0, 'champion');
|
||||
ev = await gp.onEvent({ type: 'Purchase', priceCents: 2000, tx: '0xb1', ts: T0, devEmail: 'q@x.com' });
|
||||
ok(ev && ev.tier === 'explorer', 'three orders waiting, a $20 package: the highest-priced one it covers (Explorer) is fulfilled first', JSON.stringify(ev));
|
||||
ev = await gp.onEvent({ type: 'Purchase', priceCents: 50000, tx: '0xb2', ts: T0, devEmail: 'q@x.com' });
|
||||
@@ -126,13 +138,13 @@ const short = async () => ({ error: 'short', available: 0, need: 1 });
|
||||
// 8. admin stats: each account once at its top tier, Central week and month
|
||||
for (const k of [...passes.keys()]) passes.delete(k); for (const k of [...orders.keys()]) orders.delete(k);
|
||||
const NOW = Date.parse('2026-11-04T18:00:00Z'); // Wed Nov 4, noon Central (CST); week from Mon Nov 2, month from Nov 1
|
||||
await gp.buy('s1@x.com', paid, Date.parse('2026-11-02T06:30:00Z'), 'weekly'); // Mon Nov 2 00:30 Central: this week
|
||||
await gp.buy('s1@x.com', paid, Date.parse('2026-11-02T05:30:00Z'), 'explorer'); // Sun Nov 1 23:30 Central: last week, this month
|
||||
await gp.buy('s2@x.com', paid, Date.parse('2026-11-01T04:30:00Z'), 'champion'); // Oct 31 23:30 Central: last month
|
||||
await gp.buy('s2@x.com', paid, Date.parse('2026-11-03T18:00:00Z'), 'champion'); // a renewal this week
|
||||
await gp.buy('s3@x.com', paid, NOW - 2 * DAY, 'weekly'); // ends within 7 Central days
|
||||
await buyX('s1@x.com', paid, Date.parse('2026-11-02T06:30:00Z'), 'weekly'); // Mon Nov 2 00:30 Central: this week
|
||||
await buyX('s1@x.com', paid, Date.parse('2026-11-02T05:30:00Z'), 'explorer'); // Sun Nov 1 23:30 Central: last week, this month
|
||||
await buyX('s2@x.com', paid, Date.parse('2026-11-01T04:30:00Z'), 'champion'); // Oct 31 23:30 Central: last month
|
||||
await buyX('s2@x.com', paid, Date.parse('2026-11-03T18:00:00Z'), 'champion'); // a renewal this week
|
||||
await buyX('s3@x.com', paid, NOW - 2 * DAY, 'weekly'); // ends within 7 Central days
|
||||
gp.comp('s4@x.com', 'qa', 'explorer', NOW - DAY);
|
||||
await gp.buy('s5@x.com', short, NOW, 'champion');
|
||||
await buyX('s5@x.com', short, NOW, 'champion');
|
||||
const st = gp.adminStats(NOW); const S = st.tiers;
|
||||
ok(S.weekly.active === 1 && S.explorer.active === 2 && S.champion.active === 1, 'active counts each account once at its top tier (s1 = explorer, not weekly)', JSON.stringify({ w: S.weekly.active, e: S.explorer.active, c: S.champion.active }));
|
||||
ok(S.weekly.soldWeek === 2 && S.explorer.soldWeek === 0 && S.explorer.soldMonth === 1 && S.champion.soldWeek === 1 && S.champion.soldMonth === 1 && S.champion.soldTotal === 2 && S.champion.usdTotal === 79.98, 'Central week (from Mon 00:00) and month (from the 1st 00:00) boundaries', JSON.stringify({ w: [S.weekly.soldWeek, S.weekly.soldMonth], e: [S.explorer.soldWeek, S.explorer.soldMonth], c: [S.champion.soldWeek, S.champion.soldMonth, S.champion.soldTotal, S.champion.usdTotal] }));
|
||||
@@ -154,34 +166,34 @@ const short = async () => ({ error: 'short', available: 0, need: 1 });
|
||||
ok(C0.weekly.price === 500 && C0.weekly.days === 7 && C0.explorer.price === 1999 && C0.champion.price === 3999 && C0.sovereign.price === 9999 && C0.sovereign.days === 30 && C0.legend.price === 24999 && C0.legend.days === 365 && !C0.sovereign.sale && !C0.legend.sale && C0.weekly.sale, 'defaults: weekly 500/7 (unchanged), Sovereign 9999/30, Legend 24999/365; sovTiers off = not on sale, weekly on sale', JSON.stringify(C0));
|
||||
// off switch: members refused, nothing written, nothing charged; the weekly pass still sells
|
||||
charged = null; const spy = async (price, label) => { charged = { price, label }; return { ok: true }; };
|
||||
r = await gp.buy('m@x.com', spy, T0, 'sovereign'); ok(r.error === 'The Sovereign pass is not open yet.' && !charged, 'sovTiers off: Sovereign refused for a member, nothing charged', JSON.stringify(r));
|
||||
r = await gp.buy('m@x.com', spy, T0, 'legend'); ok(r.error === 'The Legend pass is not open yet.' && !charged, 'sovTiers off: Legend refused for a member, nothing charged', JSON.stringify(r));
|
||||
r = await gp.buy('m@x.com', short, T0, 'legend'); ok(r.error && !orders.size, 'sovTiers off: a short member gets no waiting Legend order either', JSON.stringify(r));
|
||||
r = await buyX('m@x.com', spy, T0, 'sovereign'); ok(r.error === 'The Sovereign pass is not open yet.' && !charged, 'sovTiers off: Sovereign refused for a member, nothing charged', JSON.stringify(r));
|
||||
r = await buyX('m@x.com', spy, T0, 'legend'); ok(r.error === 'The Legend pass is not open yet.' && !charged, 'sovTiers off: Legend refused for a member, nothing charged', JSON.stringify(r));
|
||||
r = await buyX('m@x.com', short, T0, 'legend'); ok(r.error && ![...orders.values()].some(o => o.email === 'm@x.com' && o.status === 'waiting'), 'sovTiers off: a short member gets no waiting Legend order either', JSON.stringify(r));
|
||||
ok(!passes.get('m@x.com'), 'refused Sovereign/Legend buys write nothing', '');
|
||||
v = gp.view('m@x.com', T0); ok(v.passes.map(x => x.tier).join() === 'weekly' && !v.tierPreview, 'sovTiers off: the member still sees only the weekly pass', JSON.stringify(v.passes.map(x => x.tier)));
|
||||
charged = null; r = await gp.buy('m@x.com', spy, T0); ok(r.ok && r.tier === 'weekly' && charged.price === 500 && charged.label === 'Game Pass (7 days)' && r.until === T0 + 7 * DAY, 'sovTiers off: the weekly Game Pass sells exactly as before', JSON.stringify(charged));
|
||||
charged = null; r = await gp.buy('adm@x.com', spy, T0, 'legend', { admin: true });
|
||||
charged = null; r = await buyX('m@x.com', spy, T0); ok(r.ok && r.tier === 'weekly' && charged.price === 500 && charged.label === 'Game Pass (7 days)' && r.until === T0 + 7 * DAY, 'sovTiers off: the weekly Game Pass sells exactly as before', JSON.stringify(charged));
|
||||
charged = null; r = await buyX('adm@x.com', spy, T0, 'legend', { admin: true });
|
||||
ok(r.ok && r.tier === 'legend' && r.days === 365 && r.until === T0 + 365 * DAY && charged.price === 24999 && charged.label === 'Legend pass (365 days)', 'sovTiers off: the admin can buy Legend (testing): 24999 credits, 365 days', JSON.stringify({ r, charged }));
|
||||
SC.sovTiers = '1';
|
||||
// buy with enough purchased credits
|
||||
charged = null; r = await gp.buy('sv@x.com', spy, T0, 'sovereign');
|
||||
charged = null; r = await buyX('sv@x.com', spy, T0, 'sovereign');
|
||||
ok(r.ok && r.tier === 'sovereign' && r.days === 30 && r.until === T0 + 30 * DAY && charged.price === 9999 && charged.label === 'Sovereign pass (30 days)', 'sovTiers on: Sovereign charges 9999 credits, 30 days', JSON.stringify(charged));
|
||||
rec = passes.get('sv@x.com');
|
||||
ok(rec.tiers.sovereign.until === T0 + 30 * DAY && !rec.tiers.weekly && !rec.tiers.legend && rec.until === 0 && rec.bought[0].tier === 'sovereign' && rec.bought[0].usd === 99.99 && rec.bought[0].credits === 9999, 'only the Sovereign tier moved; bought row has tier, $99.99, 9999 credits', JSON.stringify(rec));
|
||||
charged = null; r = await gp.buy('lg@x.com', spy, T0, 'legend');
|
||||
ok(rec.tiers.sovereign.until === T0 + 30 * DAY && !rec.tiers.weekly && !rec.tiers.legend && rec.until === 0 && rec.bought[0].tier === 'sovereign' && rec.bought[0].usd === 99.99 && rec.bought[0].cents === 9999 && rec.bought[0].via === 'package', 'only the Sovereign tier moved; bought row has tier, $99.99, a 9999-cent package', JSON.stringify(rec));
|
||||
charged = null; r = await buyX('lg@x.com', spy, T0, 'legend');
|
||||
ok(r.ok && r.until === T0 + 365 * DAY && charged.price === 24999 && passes.get('lg@x.com').bought[0].usd === 249.99, 'sovTiers on: Legend charges 24999 credits, a YEAR (365 days), $249.99 row', JSON.stringify(charged));
|
||||
// extend: from max(now, until)
|
||||
r = await gp.buy('lg@x.com', paid, T0 + 100 * DAY, 'legend'); ok(r.until === T0 + 730 * DAY, 'Legend again while active: +365 days from its end (nothing lost)', new Date(r.until).toISOString());
|
||||
r = await gp.buy('sv@x.com', paid, T0 + 10 * DAY, 'sovereign'); ok(r.until === T0 + 60 * DAY, 'Sovereign again while active: +30 days from its end', new Date(r.until).toISOString());
|
||||
r = await gp.buy('sv@x.com', paid, T0 + 90 * DAY, 'sovereign'); ok(r.until === T0 + 120 * DAY, 'Sovereign again after it ended: +30 days from now', new Date(r.until).toISOString());
|
||||
r = await gp.buy('lg2@x.com', paid, T0, 'legend'); r = await gp.buy('lg2@x.com', paid, T0 + 400 * DAY, 'legend'); ok(r.until === T0 + 765 * DAY, 'Legend again after it ended: +365 days from now', new Date(r.until).toISOString());
|
||||
r = await buyX('lg@x.com', paid, T0 + 100 * DAY, 'legend'); ok(r.until === T0 + 730 * DAY, 'Legend again while active: +365 days from its end (nothing lost)', new Date(r.until).toISOString());
|
||||
r = await buyX('sv@x.com', paid, T0 + 10 * DAY, 'sovereign'); ok(r.until === T0 + 60 * DAY, 'Sovereign again while active: +30 days from its end', new Date(r.until).toISOString());
|
||||
r = await buyX('sv@x.com', paid, T0 + 90 * DAY, 'sovereign'); ok(r.until === T0 + 120 * DAY, 'Sovereign again after it ended: +30 days from now', new Date(r.until).toISOString());
|
||||
r = await buyX('lg2@x.com', paid, T0, 'legend'); r = await buyX('lg2@x.com', paid, T0 + 400 * DAY, 'legend'); ok(r.until === T0 + 765 * DAY, 'Legend again after it ended: +365 days from now', new Date(r.until).toISOString());
|
||||
// ordering: all five side by side
|
||||
await gp.buy('all@x.com', paid, T0, 'weekly'); await gp.buy('all@x.com', paid, T0, 'explorer'); await gp.buy('all@x.com', paid, T0, 'champion');
|
||||
await gp.buy('all@x.com', paid, T0, 'sovereign'); await gp.buy('all@x.com', paid, T0 - 360 * DAY, 'legend'); // legend to T0+5
|
||||
await buyX('all@x.com', paid, T0, 'weekly'); await buyX('all@x.com', paid, T0, 'explorer'); await buyX('all@x.com', paid, T0, 'champion');
|
||||
await buyX('all@x.com', paid, T0, 'sovereign'); await buyX('all@x.com', paid, T0 - 360 * DAY, 'legend'); // legend to T0+5
|
||||
f = gp.flag('all@x.com', T0 + DAY);
|
||||
ok(f.active && f.tier === 'legend' && f.until === T0 + 5 * DAY && f.tiers.sovereign === T0 + 30 * DAY && f.tiers.legend === T0 + 5 * DAY && f.tiers.champion === T0 + 30 * DAY && f.tiers.weekly === T0 + 7 * DAY && Object.keys(f.tiers).join() === 'weekly,explorer,champion,sovereign,legend', 'all five on: tier legend, until = Legend end, every tier side by side in the payload', JSON.stringify(f));
|
||||
f = gp.flag('all@x.com', T0 + 6 * DAY); ok(f.tier === 'sovereign' && f.until === T0 + 30 * DAY && f.tiers.legend === null, 'Legend ended: Sovereign shows through (above Champion and Explorer, same end)', JSON.stringify(f));
|
||||
await gp.buy('ce@x.com', paid, T0, 'champion'); await gp.buy('ce@x.com', paid, T0, 'sovereign'); await gp.buy('ce@x.com', paid, T0, 'explorer');
|
||||
await buyX('ce@x.com', paid, T0, 'champion'); await buyX('ce@x.com', paid, T0, 'sovereign'); await buyX('ce@x.com', paid, T0, 'explorer');
|
||||
ok(gp.flag('ce@x.com', T0 + 1).tier === 'sovereign', 'Sovereign outranks Champion and Explorer whatever the buy order', gp.flag('ce@x.com', T0 + 1).tier);
|
||||
// the same caps (no extra POL) and pass: true
|
||||
const at2 = Date.parse('2026-10-22T17:00:00Z');
|
||||
@@ -189,33 +201,33 @@ const short = async () => ({ error: 'short', available: 0, need: 1 });
|
||||
const gs = gp.grant({ email: 'lg@x.com', game: 'shardsofvalor', kind: 'daily', pol: 3, ref: 'cap:lg', now: at2 });
|
||||
ok(gs.allowed === 1.5 && gs.pass === true, 'polgrant: a Legend holder is capped at 1.50 on daily play, pass: true (a boolean)', JSON.stringify(gs));
|
||||
// waiting orders: a $50 package does not cover Sovereign, $100 does; $100 does not cover Legend, $250 does
|
||||
r = await gp.buy('wo@x.com', short, T0, 'sovereign');
|
||||
ok(r.needPay && r.tier === 'sovereign' && r.payUrl === '/my?from=gamepass&tier=sovereign#buy' && r.package === 100 && /\$100 package/.test(r.message) && r.price === 9999, 'Sovereign short: waiting order, payUrl with tier, "$100 package"', r.message);
|
||||
r = await buyX('wo@x.com', short, T0, 'sovereign');
|
||||
ok(r.needPay && r.tier === 'sovereign' && r.payUrl === '/my?from=gamepass&tier=sovereign#buy' && r.package === 100 && /package of \$100 or more/.test(r.message) && r.price === 9999, 'Sovereign short: waiting order, payUrl with tier, "$100 package"', r.message);
|
||||
const ordS = r.order;
|
||||
r = await gp.buy('wo@x.com', short, T0, 'legend'); const ordL = r.order;
|
||||
ok(r.needPay && r.order !== ordS && r.package === 250 && /\$250 package/.test(r.message) && r.payUrl === '/my?from=gamepass&tier=legend#buy', 'Legend short: its own waiting order, "$250 package"', r.message);
|
||||
r = await gp.buy('wo@x.com', short, T0, 'legend'); ok(r.order === ordL, 'Legend again: reuses its waiting order', '');
|
||||
r = await buyX('wo@x.com', short, T0, 'legend'); const ordL = r.order;
|
||||
ok(r.needPay && r.order !== ordS && r.package === 250 && /package of \$250 or more/.test(r.message) && r.payUrl === '/my?from=gamepass&tier=legend#buy', 'Legend short: its own waiting order, "$250 package"', r.message);
|
||||
r = await buyX('wo@x.com', short, T0, 'legend'); ok(r.order === ordL, 'Legend again: reuses its waiting order', '');
|
||||
ev = await gp.onEvent({ type: 'Purchase', priceCents: 5000, tx: '0xd1', ts: T0, devEmail: 'wo@x.com' }); ok(ev === null, 'a $50 package fulfils neither Sovereign nor Legend', JSON.stringify(ev));
|
||||
ev = await gp.onEvent({ type: 'Purchase', priceCents: 10000, tx: '0xd2', ts: T0, devEmail: 'wo@x.com' });
|
||||
ok(ev && ev.tier === 'sovereign' && ev.order === ordS && ev.until === T0 + 30 * DAY, 'a $100 package fulfils the Sovereign order (not Legend)', JSON.stringify(ev));
|
||||
ev = await gp.onEvent({ type: 'Purchase', priceCents: 10000, tx: '0xd2', ts: T0, devEmail: 'wo@x.com' }); ok(ev === null, 'the same tx again counts once', JSON.stringify(ev));
|
||||
ev = await gp.onEvent({ type: 'Purchase', priceCents: 25000, tx: '0xd3', ts: T0, devEmail: 'wo@x.com' });
|
||||
ok(ev && ev.tier === 'legend' && ev.order === ordL && ev.until === T0 + 365 * DAY, 'a $250 package fulfils the Legend order: a year', JSON.stringify(ev));
|
||||
await gp.buy('wo2@x.com', short, T0, 'champion'); await gp.buy('wo2@x.com', short, T0, 'sovereign'); await gp.buy('wo2@x.com', short, T0, 'legend');
|
||||
await buyX('wo2@x.com', short, T0, 'champion'); await buyX('wo2@x.com', short, T0, 'sovereign'); await buyX('wo2@x.com', short, T0, 'legend');
|
||||
ev = await gp.onEvent({ type: 'Purchase', priceCents: 50000, tx: '0xd4', ts: T0, devEmail: 'wo2@x.com' }); ok(ev && ev.tier === 'legend', 'three orders waiting, a $500 package: Legend (the highest-priced it covers) first', JSON.stringify(ev));
|
||||
ev = await gp.onEvent({ type: 'Purchase', priceCents: 10000, tx: '0xd5', ts: T0, devEmail: 'wo2@x.com' }); ok(ev && ev.tier === 'sovereign', 'then a $100 package: Sovereign', JSON.stringify(ev));
|
||||
// kill switches: one tier stops alone, the rest keep selling
|
||||
SC.gamePassLegendEnabled = '0';
|
||||
r = await gp.buy('ks@x.com', paid, T0, 'legend'); const r2 = await gp.buy('ks@x.com', paid, T0, 'sovereign');
|
||||
r = await buyX('ks@x.com', paid, T0, 'legend'); const r2 = await buyX('ks@x.com', paid, T0, 'sovereign');
|
||||
ok(r.error === 'The Legend pass is not open yet.' && r2.ok, 'gamePassLegendEnabled 0: Legend refused, Sovereign still sells', JSON.stringify(r));
|
||||
v = gp.view('ks2@x.com', T0); ok(v.passes.map(x => x.tier).join() === 'weekly,explorer,champion,sovereign', 'a stopped tier drops off the member card', v.passes.map(x => x.tier).join());
|
||||
v = gp.view('lg@x.com', T0); const lrow = v.passes.find(x => x.tier === 'legend');
|
||||
ok(lrow && lrow.active && !lrow.open, 'a Legend holder still sees their pass (not on sale) after the switch stops it', JSON.stringify(lrow));
|
||||
delete SC.gamePassLegendEnabled; SC.gamePassSovereignEnabled = '0';
|
||||
r = await gp.buy('ks@x.com', paid, T0, 'sovereign'); ok(r.error === 'The Sovereign pass is not open yet.', 'gamePassSovereignEnabled 0: Sovereign refused', JSON.stringify(r));
|
||||
r = await buyX('ks@x.com', paid, T0, 'sovereign'); ok(r.error === 'The Sovereign pass is not open yet.', 'gamePassSovereignEnabled 0: Sovereign refused', JSON.stringify(r));
|
||||
delete SC.gamePassSovereignEnabled;
|
||||
SC.gamePassLegendPriceCredits = '20000'; SC.gamePassLegendDays = '180';
|
||||
charged = null; r = await gp.buy('pr@x.com', spy, T0, 'legend'); ok(charged.price === 20000 && r.until === T0 + 180 * DAY, 'gamePassLegendPriceCredits / gamePassLegendDays settings override the defaults', JSON.stringify(charged));
|
||||
charged = null; r = await buyX('pr@x.com', spy, T0, 'legend'); ok(charged.price === 20000 && r.until === T0 + 180 * DAY, 'gamePassLegendPriceCredits / gamePassLegendDays settings override the defaults', JSON.stringify(charged));
|
||||
delete SC.gamePassLegendPriceCredits; delete SC.gamePassLegendDays;
|
||||
// comp and revoke
|
||||
cp = gp.comp('cv@x.com', 'qa', 'legend', T0); f = gp.flag('cv@x.com', T0 + 1);
|
||||
@@ -233,7 +245,7 @@ const short = async () => ({ error: 'short', available: 0, need: 1 });
|
||||
// tournament: Legend/Sovereign sales stay out of the pool unless passTournamentTierSales
|
||||
for (const k of [...passes.keys()]) passes.delete(k);
|
||||
const wkT = Date.parse('2026-11-10T18:00:00Z');
|
||||
await gp.buy('t1@x.com', paid, wkT, 'weekly'); await gp.buy('t2@x.com', paid, wkT, 'legend'); await gp.buy('t3@x.com', paid, wkT, 'sovereign');
|
||||
await buyX('t1@x.com', paid, wkT, 'weekly'); await buyX('t2@x.com', paid, wkT, 'legend'); await buyX('t3@x.com', paid, wkT, 'sovereign');
|
||||
let tr = await gp.runTournament(wkT, { force: true }); ok(tr.sales === 1 && tr.salesUsd === 5, 'passTournamentTierSales default off: Sovereign/Legend sales do not feed the pool', JSON.stringify({ s: tr.sales, u: tr.salesUsd }));
|
||||
SC.passTournamentTierSales = '1';
|
||||
tr = await gp.runTournament(wkT, { force: true }); ok(tr.sales === 3 && tr.salesUsd === 354.98, 'passTournamentTierSales on: Legend ($249.99) and Sovereign ($99.99) are added', JSON.stringify({ s: tr.sales, u: tr.salesUsd }));
|
||||
|
||||
Reference in New Issue
Block a user