diff --git a/server.js b/server.js index 3f1d159..5233b11 100644 --- a/server.js +++ b/server.js @@ -1373,7 +1373,7 @@ async function pwMintOnEvent(ev) { // a package bought while a mint waits earns const a = (!IS_PROD && ev.devEmail) ? { email: ev.devEmail } : await accounts.byMemberId(ev.buyerId); if (!a || !a.email) return null; // devEmail: local tests only const e = String(a.email).toLowerCase(), when = ev.ts || Date.now(), seen = pwPasses.get(e) || {}; if ((seen.log || []).some(x => x.why === 'buy:' + ev.tx)) return null; // each purchase counts once - const waiting = [...pwOrders.entries()].filter(([k, o]) => o.status === 'waiting' && o.email === e && o.ts <= when + 60000).sort((x, y) => x[1].ts - y[1].ts); + const waiting = [...pwOrders.entries()].filter(([k, o]) => o.status === 'waiting' && o.email === e && o.ts <= when + 60000).sort((x, y) => y[1].ts - x[1].ts); // newest first: the warrior the member just tapped Mint on gets the first pass (an old forgotten order took Marty's on 10-06) if (!waiting.length) return null; // passes come from packages bought for minting const earned = Math.floor(ev.priceCents / 500); pwPassAdd(e, earned, 'buy:' + ev.tx); const used = []; @@ -2891,6 +2891,15 @@ const server = http.createServer(async (req, res) => { // -- PolyWarriors hand-off (2026-10-05): sign the member across; the game verifies with PW_SSO_SECRET // PolyWarriors weekly member-fight season prizes (Marty 2026-10-05): the game signs one claim per week and place; InstantAdPay // decides the amount (setting pwWeeklyPrize, default '1000,500,250' earned credits) and pays each week+place once. + // admin: credit or remove PolyWarriors mint passes on an account (support fixes), logged in the pass history + if (p === '/api/admin/pw/pass' && req.method === 'POST') { + if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); + const b = await readBody(req); const e = String(b.email || '').trim().toLowerCase(), n = Math.round(Number(b.n) || 0); + if (!e || !n || Math.abs(n) > 20) return json(res, 400, { error: 'email and n (1-20, or negative to remove) required' }); + const left = pwPassAdd(e, n, 'admin:' + String(b.why || 'support').slice(0, 80)); + console.log('polywarriors admin pass', e, n > 0 ? '+' + n : n, 'left', left, b.why || ''); + return json(res, 200, { ok: true, email: e, passes: left }); + } if (p === '/api/game/pw/prize' && req.method === 'POST') { const b = await readBody(req); const r = pwOpen(b.t); if (r.error) return json(res, 400, { error: r.error });