From e61475f89b6c7c1959b932b9bb9e282eeedca5f7 Mon Sep 17 00:00:00 2001 From: martbost Date: Thu, 5 Nov 2026 06:19:17 -0600 Subject: [PATCH] Zealy quest checks for the games (Marty 2026-11-05: game quests are important): /api/quest/zealy/game passes once the account has earned any network-game reward (gamepass.activity = grants and POL in the ledger), /api/quest/zealy/gamepass passes while a Game Pass is active (gamepass.flag). Read-only, same key and 200/400 contract as the other checks Co-Authored-By: Claude Opus 5.5 --- gamepass.js | 8 +++++++- server.js | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/gamepass.js b/gamepass.js index c9ba079..298cbc6 100644 --- a/gamepass.js +++ b/gamepass.js @@ -290,6 +290,12 @@ function capsFor(email, now, game) { return out; } +// quest-site check (Zealy, 2026-11-05): has this account earned any game reward, and how much in total +function activity(email) { + const M = L.members[String(email || '').toLowerCase()]; if (!M) return { grants: 0, pol: 0 }; + return Object.values(M.days).reduce((o, d) => ({ grants: o.grants + (d.grants || 0), pol: r6(o.pol + (d.total || 0)) }), { grants: 0, pol: 0 }); +} + // POST /api/partner/polgrant. Returns { allowed, deferred, pass, day } (+ carried, capHit, enforced, repeat). function grant(o) { const e = String(o.email || '').toLowerCase(); const game = String(o.game || '').toLowerCase(); const kind = o.kind === 'progress' ? 'progress' : 'daily'; @@ -518,5 +524,5 @@ function prune(now) { return n; } -module.exports = { init, cfg, GAMES, NAMES, TIERS, TIER_NAMES, TIER_DEFS, flag, view, buy, cancelOrder, comp, revoke, onEvent, capsFor, grant, voidGrant, tournamentTick, runTournament, pending, markPaid, adminStats, prune, weekStart, dayKey, +module.exports = { init, cfg, GAMES, NAMES, TIERS, TIER_NAMES, TIER_DEFS, flag, activity, view, buy, cancelOrder, comp, revoke, onEvent, capsFor, grant, voidGrant, tournamentTick, runTournament, pending, markPaid, adminStats, prune, weekStart, dayKey, _ledger: () => L }; diff --git a/server.js b/server.js index 9d86bf0..f059525 100644 --- a/server.js +++ b/server.js @@ -3170,7 +3170,7 @@ const server = http.createServer(async (req, res) => { } // -- quest-site checks (Marty 2026-11-04: Zealy first). Zealy POSTs { accounts: { email?, wallet? } } with X-Api-Key; // 200 = the member may claim, 400 + message = shown to them. Read-only: looks members up, never changes anything. - const questM = p.match(/^\/api\/quest\/zealy\/(account|wallet|member)$/); + const questM = p.match(/^\/api\/quest\/zealy\/(account|wallet|member|game|gamepass)$/); if (questM && req.method === 'POST') { const key = process.env.QUEST_API_KEY || ''; if (!key) return json(res, 503, { message: 'Quest checks are not switched on yet.' }); @@ -3183,6 +3183,8 @@ const server = http.createServer(async (req, res) => { if (!acct) return json(res, 400, { message: em ? 'No InstantAdPay account uses ' + em + '. Join free at ' + JOIN + ' with this email, then claim again.' : 'No InstantAdPay account is linked to this wallet. Join free at ' + JOIN + ' and link this wallet in your dashboard, then claim again.' }); if (questM[1] === 'wallet' && !acct.address) return json(res, 400, { message: 'Your InstantAdPay account has no Polygon wallet linked yet. Sign in at instantadpay.com/my, link your wallet, then claim again.' }); if (questM[1] === 'member' && !acct.memberId) return json(res, 400, { message: 'Your InstantAdPay account is not an on-chain member yet. Get your first package at instantadpay.com/my, then claim again.' }); + if (questM[1] === 'game' && !(gamepass.activity(acct.email).grants > 0)) return json(res, 400, { message: 'No game rewards on your InstantAdPay account yet. Open any network game from instantadpay.com/games, sign in with your InstantAdPay account and earn your first reward, then claim again.' }); + if (questM[1] === 'gamepass' && !gamepass.flag(acct.email).active) return json(res, 400, { message: 'Your InstantAdPay account has no active Game Pass. Get one in your dashboard at instantadpay.com/my, then claim again.' }); console.log('quest check ok', questM[1], b && b.questId ? String(b.questId).slice(0, 40) : ''); return json(res, 200, { message: 'Verified on InstantAdPay. Thanks for joining!' }); }