Warp & Wares integration, gated (2026-10-29): the 30-day Trade Wars-style season game, same protocol as POL Miner and Turkey Drop. WW_SSO_SECRET / WW_URL (default https://warpwares.saasy.top, staging for now) / WW_ALT_URLS / WW_SEASON_START + WW_SEASON_END (default 2026-11-30..2026-12-30, Central, end exclusive) with wwMint/wwOpen/wwIsGameUrl/wwCallback (code defaults only, no env set); GAME_AUTH warpwares (in-game sign-in kit); /api/my/warpwares hand-off + iap.return + my.js redirect; a new visit kind 'dock' in ads.js VISIT_KINDS with its own daily cap (dockCapPerDay, default 10; repeats after the cooldown like refuels; house visits count toward it) and the refuel rail serving game 'warpwares' with that kind (label 'sponsor dock', receipt kind ww-dock, note 'Warp & Wares sponsor dock', refuel.js done text 'Your bonus turns are waiting on the bridge'); GAMES() card with the season window (hidden until 'warpwares' is in gamesLive, its 'Opens' date shown only once live, gone after the season) and STRIP line; growth snapshot counts a season start only when live; walletnudge entry (idle until the secret is set); gamestats + gamepass GAMES/NAMES + GP_SECRETS; Game Pass perks row 'the Season Pass' shown only while the game is in the public games list (gpShown, the Turkey Drop pattern); cap-nudge names; promo tools Games entry (warpwares.saasy.top/?ref=, 3 posts) shown only while live; chatbot CANNED warpwares + fact follow gamesLive and the season window (coming-soon and season-over answers, KB answer kept out of the prompt unless live), KNOWLEDGE_DATE 2026-10-29b; my.js?v=20261029ww, promo.js?v=20261029ww, refuel.js?v=20261029ww. qa/warpwares.mjs (bash qa/run.sh warpwares): 21 checks on a local copy with a mock game (card gating, the hand-off token, a sponsor dock open/challenge/done with receipt + callback, the dock cap separate from refuels, chatbot gating), all passing. Not merged, not deployed.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -566,7 +566,7 @@ async function boot() {
|
||||
supportbot.init({ tickets, chatId: () => String(siteConfig().supportTelegramChat || '1289244227').trim(), site: 'https://instantadpay.com' });
|
||||
badge.init({ publicDir: PUBLIC_DIR });
|
||||
gamestats.init({ dataDir: DATA_DIR });
|
||||
snapshot.init({ dataDir: DATA_DIR, db, chain, siteConfig, publicDir: PUBLIC_DIR, games: gamestats, launchesToday: () => GAMES().filter(g => (g.soon && g.soon.opens === todayCT()) || (g.season && g.season.start === todayCT())).map(g => g.name),
|
||||
snapshot.init({ dataDir: DATA_DIR, db, chain, siteConfig, publicDir: PUBLIC_DIR, games: gamestats, launchesToday: () => GAMES().filter(g => (g.soon && g.soon.opens === todayCT()) || (g.season && g.season.start === todayCT() && String(siteConfig().gamesLive == null ? 'polhunter' : siteConfig().gamesLive).split(',').map(x => x.trim().toLowerCase()).includes(g.slug))).map(g => g.name),
|
||||
send: async (c, t, th) => { await telegramSend(c, t, th); return true; },
|
||||
sendPhoto: (c, jpeg, cap, th) => telegramSendPhoto(c, jpeg, cap, th) });
|
||||
fridaybank.init({ db });
|
||||
@@ -749,7 +749,7 @@ async function boot() {
|
||||
|
||||
// Game Pass partner helpers (2026-10-16): which secret signs for which game, signature compare, member resolution, dev clock
|
||||
const GP_SECRETS = () => ({ polhunter: String(process.env.HUNT_SSO_SECRET || '').trim(), gemkingdom: GK_SECRET(), spellwheel: SW_SECRET(), spookydoors: SD_SECRET(), polywarriors: PW_SECRET(),
|
||||
clutterhunt: SEEK_SECRET(), polybreak: PB_SECRET(), polminer: PM_SECRET(), driprunner: DR_SECRET(), roadagent: RA_SECRET(), shardsofvalor: SOV_SECRET() });
|
||||
clutterhunt: SEEK_SECRET(), polybreak: PB_SECRET(), polminer: PM_SECRET(), warpwares: WW_SECRET(), driprunner: DR_SECRET(), roadagent: RA_SECRET(), shardsofvalor: SOV_SECRET() });
|
||||
function gpPartnerCheck(game) { if (!gamepass.GAMES.includes(game)) return { error: 'unknown game', code: 400 }; const secret = GP_SECRETS()[game] || ''; if (secret.length < 32) return { error: game + ' is not connected', code: 503 }; return { secret }; }
|
||||
const gpSigOk = (want, got) => typeof got === 'string' && want.length === got.length && crypto.timingSafeEqual(Buffer.from(want), Buffer.from(got));
|
||||
async function gpResolve(memberId, email) { // the account behind a game's player: main member id, a linked position's id, or (no wallet yet) the email
|
||||
@@ -1761,6 +1761,31 @@ async function pmCallback(cbUrl, receipt) {
|
||||
if (!pmIsGameUrl(cbUrl)) return false;
|
||||
try { const r = await fetch(cbUrl, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ t: receipt }), signal: AbortSignal.timeout(8000) }); return r.ok; } catch (e) { console.warn('polminer callback', e.message); return false; }
|
||||
}
|
||||
// -- Warp & Wares (2026-10-29): the Trade Wars-style 30-day season game; its own secret WW_SSO_SECRET (also on the game), the same
|
||||
// protocol as POL Miner. Members see nothing until 'warpwares' is in site config gamesLive (Games card, strip, games page, promo
|
||||
// tools, chatbot), and its season window is WW_SEASON (env WW_SEASON_START / WW_SEASON_END, Central days, end exclusive).
|
||||
// A SPONSOR DOCK is its refuel: a verified visit at a sponsor market, visit kind 'dock' with its own daily cap (ads.js), paying
|
||||
// the player bonus turns in the game, never POL.
|
||||
const WW_SECRET = () => String(process.env.WW_SSO_SECRET || '').trim();
|
||||
const WW_URL = () => String(process.env.WW_URL || 'https://warpwares.saasy.top').replace(/\/+$/, '');
|
||||
const WW_ALT = () => String(process.env.WW_ALT_URLS || '').split(',').map(x => x.trim().replace(/\/+$/, '')).filter(Boolean);
|
||||
const WW_SEASON = { start: /^\d{4}-\d{2}-\d{2}$/.test(String(process.env.WW_SEASON_START || '')) ? process.env.WW_SEASON_START : '2026-11-30', end: /^\d{4}-\d{2}-\d{2}$/.test(String(process.env.WW_SEASON_END || '')) ? process.env.WW_SEASON_END : '2026-12-30' };
|
||||
const wwSign = p => drB64u(crypto.createHmac('sha256', WW_SECRET()).update(p).digest());
|
||||
function wwMint(claims, ttlMs) { const payload = JSON.stringify(Object.assign({ iat: Date.now(), exp: Date.now() + (ttlMs || 300000), nonce: crypto.randomBytes(12).toString('hex') }, claims, gpClaim(claims))); return drB64u(payload) + '.' + wwSign(payload); }
|
||||
function wwOpen(token) {
|
||||
if (WW_SECRET().length < 32) return { error: 'Warp & Wares is not connected yet.' };
|
||||
const [p, sig] = String(token || '').split('.'); if (!p || !sig) return { error: 'That link is not valid.' };
|
||||
let payload; try { payload = Buffer.from(String(p).replace(/-/g, '+').replace(/_/g, '/'), 'base64').toString('utf8'); } catch (e) { return { error: 'That link is not valid.' }; }
|
||||
const want = wwSign(payload); if (want.length !== sig.length || !crypto.timingSafeEqual(Buffer.from(want), Buffer.from(sig))) return { error: 'That link is not valid.' };
|
||||
let c; try { c = JSON.parse(payload); } catch (e) { return { error: 'That link is not valid.' }; }
|
||||
if (!c.exp || Date.now() > c.exp) return { error: 'That link has expired. Go back to Warp & Wares and dock again.' };
|
||||
return { ok: true, claims: c };
|
||||
}
|
||||
const wwIsGameUrl = u => [WW_URL()].concat(WW_ALT()).some(o => String(u || '').startsWith(o + '/'));
|
||||
async function wwCallback(cbUrl, receipt) {
|
||||
if (!wwIsGameUrl(cbUrl)) return false;
|
||||
try { const r = await fetch(cbUrl, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ t: receipt }), signal: AbortSignal.timeout(8000) }); return r.ok; } catch (e) { console.warn('warpwares callback', e.message); return false; }
|
||||
}
|
||||
// -- PolyWarriors (2026-10-05): the cyberpunk fighting game at polywarriors.com; its own secret PW_SSO_SECRET (also on the game)
|
||||
const PW_SECRET = () => String(process.env.PW_SSO_SECRET || '').trim();
|
||||
const PW_URL = () => String(process.env.PW_URL || 'https://polywarriors.com').replace(/\/+$/, '');
|
||||
@@ -1959,6 +1984,9 @@ function GAMES() {
|
||||
// POL Miner (2026-10-28): dig down, beat the drill bosses, find the rare Polygon crystals (hidden until gamesLive has 'polminer')
|
||||
{ slug: 'polminer', name: 'POL Miner', tag: 'Mining adventure', blurb: 'Dig down through the layers, haul ore to sell, upgrade your pick, lamp and cart, and beat a drill boss every 30 m. Rare pink Polygon crystals pay POL.',
|
||||
art: 'https://coolify-saasytop.nyc3.cdn.digitaloceanspaces.com/game-banners/polminer/og-polminer-clean.jpg', play: '/api/my/polminer', pays: 'POL for Polygon crystals, first boss wins and depth records' },
|
||||
// Warp & Wares (2026-10-29): the 30-day trading season (hidden until gamesLive has 'warpwares'; gone after the season)
|
||||
{ slug: 'warpwares', name: 'Warp & Wares', tag: 'Season game, 30 days', blurb: 'A shared galaxy of 1,200 sectors for one season. 200 turns a day for everyone: trade three goods between markets, haggle, hold sectors with fighters, build a base, run a team of five. Weekly territory and trader prizes and the season leaderboard pay POL.',
|
||||
art: WW_URL() + '/og-warpwares.jpg', play: '/api/my/warpwares', pays: 'POL for weekly territory and top traders, milestones and the season leaderboard', season: { start: WW_SEASON.start, end: WW_SEASON.end } },
|
||||
]);
|
||||
}
|
||||
// each game's member perk (the $5 welcome offer, 2026-10-05) shown on its card
|
||||
@@ -1973,6 +2001,7 @@ const STRIP = () => ({
|
||||
clutterhunt: { line: 'Search cozy, cluttered rooms for hidden objects. New rooms every season.', open: SEEK_URL() + '/', host: SEEK_URL().replace(/^https?:\/\//, '') },
|
||||
polybreak: { line: 'Break the glass jewel wall, catch the capsules and the purple Polygon gem. First clears pay POL.', open: PB_URL() + '/', host: PB_URL().replace(/^https?:\/\//, '') },
|
||||
polminer: { line: 'Dig deep, beat the drill bosses, find the rare pink Polygon crystals. Crystals pay POL.', open: PM_URL() + '/', host: PM_URL().replace(/^https?:\/\//, '') },
|
||||
warpwares: { line: 'One galaxy, 30 days, 200 turns a day. Trade, hold sectors, build a base. Weekly prizes pay POL.', open: WW_URL() + '/', host: WW_URL().replace(/^https?:\/\//, '') },
|
||||
spellwheel: { line: 'Swipe the letter wheel, fill the grid, solve the daily puzzle. Levels and dailies pay POL.', open: SW_URL() + '/', host: SW_URL().replace(/^https?:\/\//, '') },
|
||||
polywarriors: { line: 'Recruit one-of-a-kind warriors, fight the arena, challenge members. First wins pay POL.', open: PW_URL() + '/', host: PW_URL().replace(/^https?:\/\//, '') },
|
||||
});
|
||||
@@ -2042,6 +2071,8 @@ const GAME_AUTH = {
|
||||
mint: (a, memberId) => pbMint({ memberId: Number(memberId) || 0, email: String(a.email).toLowerCase(), username: a.username || null, wallet: a.address || null, sponsorRef: a.sponsorRef || null }) },
|
||||
polminer: { name: 'POL Miner', frames: false, origins: () => [PM_URL()].concat(PM_ALT()), host: () => PM_URL().replace(/^https?:\/\//, ''),
|
||||
mint: (a, memberId) => pmMint({ memberId: Number(memberId) || 0, email: String(a.email).toLowerCase(), username: a.username || null, wallet: a.address || null, sponsorRef: a.sponsorRef || null }) },
|
||||
warpwares: { name: 'Warp & Wares', frames: false, origins: () => [WW_URL()].concat(WW_ALT()), host: () => WW_URL().replace(/^https?:\/\//, ''),
|
||||
mint: (a, memberId) => wwMint({ memberId: Number(memberId) || 0, email: String(a.email).toLowerCase(), username: a.username || null, wallet: a.address || null, sponsorRef: a.sponsorRef || null }) },
|
||||
spellwheel: { name: 'SpellWheel', origins: () => [SW_URL()].concat(SW_ALT()), host: () => SW_URL().replace(/^https?:\/\//, ''),
|
||||
mint: (a, memberId) => swMint({ memberId: Number(memberId) || 0, email: String(a.email).toLowerCase(), username: a.username || null, wallet: a.address || null }) },
|
||||
polywarriors: { name: 'PolyWarriors', origins: () => [PW_URL()].concat(PW_ALT()), host: () => PW_URL().replace(/^https?:\/\//, ''),
|
||||
@@ -2594,7 +2625,7 @@ const server = http.createServer(async (req, res) => {
|
||||
let memberId = 0;
|
||||
if (r.account.address) { try { memberId = await chain.memberIdByAccount(r.account.address); } catch (err) {} }
|
||||
const token = await auth.mintSession({ email: r.account.email, address: r.account.address, memberId });
|
||||
return json(res, 200, { ok: true, account: r.account, created: !!r.created, next: ({ clutterhunt: '/api/my/clutterhunt', spellwheel: '/api/my/spellwheel', polybreak: '/api/my/polybreak', polminer: '/api/my/polminer', polywarriors: '/api/my/polywarriors', driprunner: '/api/my/driprunner', passivedrip: '/api/my/passivedrip', gemkingdom: '/api/my/gemkingdom', gkshop: '/gk/shop/resume', spookydoors: '/api/my/spookydoors', sdshop: '/sd/shop/resume' })[parseCookies(req)['iap.return']] || null }, { 'Set-Cookie': auth.sessionCookie(token) }); // next: Drip Runner sent them here to sign in (2026-09-30)
|
||||
return json(res, 200, { ok: true, account: r.account, created: !!r.created, next: ({ clutterhunt: '/api/my/clutterhunt', spellwheel: '/api/my/spellwheel', polybreak: '/api/my/polybreak', polminer: '/api/my/polminer', warpwares: '/api/my/warpwares', polywarriors: '/api/my/polywarriors', driprunner: '/api/my/driprunner', passivedrip: '/api/my/passivedrip', gemkingdom: '/api/my/gemkingdom', gkshop: '/gk/shop/resume', spookydoors: '/api/my/spookydoors', sdshop: '/sd/shop/resume' })[parseCookies(req)['iap.return']] || null }, { 'Set-Cookie': auth.sessionCookie(token) }); // next: Drip Runner sent them here to sign in (2026-09-30)
|
||||
}
|
||||
|
||||
// -- in-game sign-in (2026-10-03): see GAME_AUTH. Mirrors /api/auth/email/start + verify, minus cookies.
|
||||
@@ -2793,7 +2824,7 @@ const server = http.createServer(async (req, res) => {
|
||||
if (tankHold) sponsorBlocked = 'tankHold';
|
||||
else if (!sponsorId && memberId !== _defSpon) { sponsorId = _defSpon; sponsorFallback = true; } // orphan fallback → #1 (never self-sponsor)
|
||||
if (memberId && acct && acct.memberId !== memberId) accounts.setMemberId(acct.email, memberId).catch(() => {});
|
||||
const out = { signedIn: true, gkShop: !!parseCookies(req)['iap.gkshop'], sdShop: !!parseCookies(req)['iap.sdshop'], pwMint: !!parseCookies(req)['iap.pwmint'], returnTo: ['polhunter', 'driprunner', 'passivedrip', 'gemkingdom', 'gkshop', 'spookydoors', 'sdshop', 'pwmint', 'polybreak', 'polminer', 'shardsofvalor'].includes(parseCookies(req)['iap.return']) ? parseCookies(req)['iap.return'] : null, sponsorBlocked, sponsorRouted, sponsorName: spdMe.name || null, email: s.email || (acct && acct.email) || null,
|
||||
const out = { signedIn: true, gkShop: !!parseCookies(req)['iap.gkshop'], sdShop: !!parseCookies(req)['iap.sdshop'], pwMint: !!parseCookies(req)['iap.pwmint'], returnTo: ['polhunter', 'driprunner', 'passivedrip', 'gemkingdom', 'gkshop', 'spookydoors', 'sdshop', 'pwmint', 'polybreak', 'polminer', 'warpwares', 'shardsofvalor'].includes(parseCookies(req)['iap.return']) ? parseCookies(req)['iap.return'] : null, sponsorBlocked, sponsorRouted, sponsorName: spdMe.name || null, email: s.email || (acct && acct.email) || null,
|
||||
address: s.address || (acct && acct.address) || null, memberId,
|
||||
username: (acct && acct.username) || null,
|
||||
refCode: (acct && acct.code) || null, sponsorId, tankHold, sponsorFallback,
|
||||
@@ -3697,6 +3728,15 @@ const server = http.createServer(async (req, res) => {
|
||||
res.writeHead(302, { Location: PB_URL() + '/auth?t=' + tok, 'Cache-Control': 'no-store', 'Set-Cookie': gkCookie('iap.return', '', 0) }); return res.end();
|
||||
}
|
||||
// -- POL Miner hand-off (2026-10-28): sign the member across; the game verifies with POLMINER_SSO_SECRET
|
||||
// -- Warp & Wares hand-off (2026-10-29): sign the member across; the game verifies with WW_SSO_SECRET
|
||||
if (p === '/api/my/warpwares' && req.method === 'GET') { gamestats.handoff('warpwares');
|
||||
const s = await auth.fromRequest(req);
|
||||
if (!s || !s.email) { res.writeHead(302, { Location: '/my' + refQ(u), 'Set-Cookie': gkCookie('iap.return', 'warpwares', 1800), 'Cache-Control': 'no-store' }); return res.end(); }
|
||||
if (WW_SECRET().length < 32) return json(res, 503, { error: 'Warp & Wares is not connected yet.' });
|
||||
const acct = await accounts.byEmail(s.email);
|
||||
const tok = wwMint({ memberId: Number((acct && acct.memberId) || s.memberId || 0), email: String(s.email).toLowerCase(), username: (acct && acct.username) || null, wallet: (acct && acct.address) || null, sponsorRef: (acct && acct.sponsorRef) || null });
|
||||
res.writeHead(302, { Location: WW_URL() + '/auth?t=' + tok, 'Cache-Control': 'no-store', 'Set-Cookie': gkCookie('iap.return', '', 0) }); return res.end();
|
||||
}
|
||||
if (p === '/api/my/polminer' && req.method === 'GET') { gamestats.handoff('polminer');
|
||||
const s = await auth.fromRequest(req);
|
||||
if (!s || !s.email) { res.writeHead(302, { Location: '/my' + refQ(u), 'Set-Cookie': gkCookie('iap.return', 'polminer', 1800), 'Cache-Control': 'no-store' }); return res.end(); }
|
||||
@@ -3977,6 +4017,7 @@ const server = http.createServer(async (req, res) => {
|
||||
if (r.error) { const g = swOpen(u.searchParams.get('t')); if (!g.error && g.claims.game === 'spellwheel') { r = g; game = 'spellwheel'; } }
|
||||
if (r.error) { const g = pbOpen(u.searchParams.get('t')); if (!g.error && g.claims.game === 'polybreak') { r = g; game = 'polybreak'; } }
|
||||
if (r.error) { const g = pmOpen(u.searchParams.get('t')); if (!g.error && g.claims.game === 'polminer') { r = g; game = 'polminer'; } }
|
||||
if (r.error) { const g = wwOpen(u.searchParams.get('t')); if (!g.error && g.claims.game === 'warpwares') { r = g; game = 'warpwares'; } }
|
||||
if (r.error) return json(res, 400, { error: r.error });
|
||||
const c = r.claims; if (c.kind !== 'refuel' || !c.nonce || !c.email || !c.ret) return json(res, 400, { error: 'That is not a refuel link.' });
|
||||
if (game === 'gemkingdom' && !String(c.ret).startsWith(GK_URL() + '/')) return json(res, 400, { error: 'That is not a Gem Kingdom link.' });
|
||||
@@ -3984,17 +4025,19 @@ const server = http.createServer(async (req, res) => {
|
||||
if (game === 'spellwheel' && !swIsGameUrl(c.ret)) return json(res, 400, { error: 'That is not a SpellWheel link.' });
|
||||
if (game === 'polybreak' && !pbIsGameUrl(c.ret)) return json(res, 400, { error: 'That is not a PolyBreak link.' });
|
||||
if (game === 'polminer' && !pmIsGameUrl(c.ret)) return json(res, 400, { error: 'That is not a POL Miner link.' });
|
||||
const G = game === 'polminer' ? { game: 'POL Miner', label: 'supply crate' } : game === 'polybreak' ? { game: 'PolyBreak', label: 'one more paddle' } : game === 'gemkingdom' ? { game: 'Gem Kingdom', label: 'continue' } : game === 'seek' ? { game: 'ClutterHunt', label: 'hint' } : game === 'spellwheel' ? { game: 'SpellWheel', label: 'hint' } : { game: 'Drip Runner', label: 'refuel' };
|
||||
if (game === 'warpwares' && !wwIsGameUrl(c.ret)) return json(res, 400, { error: 'That is not a Warp & Wares link.' });
|
||||
const vkind = game === 'warpwares' ? 'dock' : 'refuel'; // a Warp & Wares sponsor dock has its own visit kind and daily cap (ads.js VISIT_KINDS)
|
||||
const G = game === 'warpwares' ? { game: 'Warp & Wares', label: 'sponsor dock' } : game === 'polminer' ? { game: 'POL Miner', label: 'supply crate' } : game === 'polybreak' ? { game: 'PolyBreak', label: 'one more paddle' } : game === 'gemkingdom' ? { game: 'Gem Kingdom', label: 'continue' } : game === 'seek' ? { game: 'ClutterHunt', label: 'hint' } : game === 'spellwheel' ? { game: 'SpellWheel', label: 'hint' } : { game: 'Drip Runner', label: 'refuel' };
|
||||
for (const [n, v] of refuelTokens) if (v.ts + 30 * 60000 < Date.now()) refuelTokens.delete(n);
|
||||
let t = refuelTokens.get(c.nonce);
|
||||
if (t && t.done) return json(res, 200, Object.assign({ done: true, ret: t.doneRet || t.ret }, G));
|
||||
if (!t) {
|
||||
const email = String(c.email).toLowerCase();
|
||||
const status = await ads.visitStatus(email, 'refuel'); // refuels have their own daily allowance
|
||||
const status = await ads.visitStatus(email, vkind); // refuels (and docks) have their own daily allowance
|
||||
if (status.count >= status.cap) return json(res, 200, Object.assign({ none: true, why: 'cap', ret: c.ret }, G));
|
||||
// 2026-10-28 (Marty): a sponsor never seen first, then one seen longest ago after the cooldown (doorRepeatDays), then a
|
||||
// member video, then a house sponsor (one of Marty's programs, never the game the player is in), so the visit is never empty
|
||||
const ad = await ads.serveVisit(email, viewerGeo(req), { kind: 'refuel' });
|
||||
const ad = await ads.serveVisit(email, viewerGeo(req), { kind: vkind });
|
||||
if (ad) t = { kind: 'visit', email, memberId: Number(c.memberId), id: ad.id, title: ad.title, target: ad.target, ts: Date.now(), ret: c.ret, challenge: null, done: false };
|
||||
else { // every visit pack already visited: a member video ad instead (2026-09-30)
|
||||
const v = await ads.serveVideo(Object.assign({ excludeEmail: email, refuel: true }, viewerGeo(req)));
|
||||
@@ -4027,22 +4070,28 @@ const server = http.createServer(async (req, res) => {
|
||||
if (Number(b.answer) !== t.challenge.answer) { t.challenge = null; return json(res, 400, { error: 'Wrong pick.', retry: true }); }
|
||||
let credits;
|
||||
if (t.kind === 'video') {
|
||||
const st = await ads.visitStatus(t.email, 'refuel'); if (st.count >= st.cap) return json(res, 400, { error: 'That is today\u2019s refuels. More at midnight Central.' });
|
||||
if (!(await ads.markRefuelVideo(t.email, t.id))) return json(res, 400, { error: 'You already refuelled on this video. Go back and try again for another.' });
|
||||
const st = await ads.visitStatus(t.email, t.game === 'warpwares' ? 'dock' : 'refuel'); if (st.count >= st.cap) return json(res, 400, { error: t.game === 'warpwares' ? 'That is today\u2019s sponsor docks. More at midnight Central.' : 'That is today\u2019s refuels. More at midnight Central.' });
|
||||
if (!(await ads.markRefuelVideo(t.email, t.id, t.game === 'warpwares' ? 'dock' : undefined))) return json(res, 400, { error: 'You already refuelled on this video. Go back and try again for another.' });
|
||||
const tier = await ads.chargeVideoView(t.id); // the advertiser is charged one view, as on the Watch tab
|
||||
if (!tier) return json(res, 400, { error: 'That video just ran out of budget. Go back and try again.' });
|
||||
await ads.markVideoSeen(t.email, t.id); credits = tier.cost;
|
||||
} else if (t.kind === 'house') { // a house sponsor: no advertiser, no pool income, but it is one of the day's refuels
|
||||
const r = await ads.markHouseVisit(t.email, 'refuel');
|
||||
const r = await ads.markHouseVisit(t.email, t.game === 'warpwares' ? 'dock' : 'refuel');
|
||||
if (r.error) return json(res, 400, { error: r.error });
|
||||
credits = 0;
|
||||
} else {
|
||||
const r = await ads.completeVisit(t.email, t.id, { reward: false, note: t.game === 'polminer' ? 'POL Miner supply crate' : t.game === 'polybreak' ? 'PolyBreak paddle' : t.game === 'gemkingdom' ? 'Gem Kingdom continue' : t.game === 'seek' ? 'ClutterHunt hint' : t.game === 'spellwheel' ? 'SpellWheel hint' : 'Drip Runner refuel' });
|
||||
const r = await ads.completeVisit(t.email, t.id, { reward: false, kind: t.game === 'warpwares' ? 'dock' : undefined, note: t.game === 'warpwares' ? 'Warp & Wares sponsor dock' : t.game === 'polminer' ? 'POL Miner supply crate' : t.game === 'polybreak' ? 'PolyBreak paddle' : t.game === 'gemkingdom' ? 'Gem Kingdom continue' : t.game === 'seek' ? 'ClutterHunt hint' : t.game === 'spellwheel' ? 'SpellWheel hint' : 'Drip Runner refuel' });
|
||||
if (r.error) return json(res, 400, r);
|
||||
credits = ads.rates().visitCostPerVisit || 3;
|
||||
{ const camp = await ads.campaignById(t.id).catch(() => null); if (camp && camp.house) credits = 0; } // a house ad costs nobody anything: no POL pool income (2026-10-03)
|
||||
}
|
||||
t.done = true;
|
||||
if (t.game === 'warpwares') { // Warp & Wares sponsor dock: signed receipt to the game's callback and on the ret page; the game pays bonus turns, never POL
|
||||
const receipt = wwMint({ kind: 'ww-dock', nonce, email: t.email, campaignId: t.id, credits }, 15 * 60000);
|
||||
const posted = await wwCallback(t.cb, receipt);
|
||||
t.doneRet = t.ret + (t.ret.includes('?') ? '&' : '?') + 'ok=1&r=' + encodeURIComponent(receipt);
|
||||
return json(res, 200, { ok: true, posted, ret: t.doneRet, game: 'Warp & Wares', label: 'sponsor dock' });
|
||||
}
|
||||
if (t.game === 'polminer') { // POL Miner supply crate: signed receipt to the game's callback and on the ret page (the crate is a gameplay boost, never POL)
|
||||
const receipt = pmMint({ kind: 'pm-crate', nonce, email: t.email, campaignId: t.id, credits }, 15 * 60000);
|
||||
const posted = await pmCallback(t.cb, receipt);
|
||||
@@ -4167,8 +4216,9 @@ const server = http.createServer(async (req, res) => {
|
||||
const out = [];
|
||||
for (const g of GAMES()) {
|
||||
if (g.season && day >= g.season.end) continue; // a finished season is gone
|
||||
const soon = !!(g.soon && day < g.soon.opens), preSeason = !!(g.season && day < g.season.start);
|
||||
const isLive = !soon && !preSeason && live.has(g.slug);
|
||||
// a seasonal game shows its 'Opens' date only once it is in gamesLive (Turkey Drop's rule, 2026-10-28; Warp & Wares the same)
|
||||
const soon = !!(g.soon && day < g.soon.opens), preSeason = !!(g.season && day < g.season.start && live.has(g.slug));
|
||||
const isLive = !soon && !(g.season && day < g.season.start) && live.has(g.slug);
|
||||
if (!isLive && !soon && !preSeason) continue; // not live and no date: not announced yet
|
||||
out.push({ slug: g.slug, name: g.name, tag: g.tag, blurb: g.blurb, pays: g.pays, art: /^https?:/.test(g.art) ? g.art : 'https://instantadpay.com' + g.art, artPos: g.artPos || 'center', live: isLive, video: isLive && g.video ? g.video : null,
|
||||
opens: soon ? g.soon.label : preSeason ? 'Opens ' + lbl(g.season.start) : null, season: g.season && isLive ? { ends: lbl(g.season.end, true) } : null, open: S[g.slug] ? S[g.slug].open : null, host: S[g.slug] ? S[g.slug].host : null });
|
||||
|
||||
Reference in New Issue
Block a user