// Renders the badge card artwork (public/badges/.png, 1080x1080) with Playwright, in the game's own // neon style. The bottom plate is left blank: lib/badge.js stamps the player's name and earnings there // with ffmpeg when a card is posted. Run locally: node tools/render-badges.mjs import pkg from 'file:///D:/Projects/MarketingAgent/qa-tester/node_modules/playwright/index.js'; import fs from 'fs'; import path from 'path'; import { fileURLToPath } from 'url'; const { chromium } = pkg; const OUT = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', 'public', 'badges'); fs.mkdirSync(OUT, { recursive: true }); export const BADGES = { magnet: { title: 'Drip Magnet', sub: 'Hangar unlock', kind: 'item', color: '#FFC24B', glyph: 'orb' }, ship: { title: 'Courier Mk II', sub: 'Hangar unlock', kind: 'item', color: '#8FF0FF', glyph: 'ship' }, shield: { title: 'Shield Core', sub: 'Hangar unlock · paid in POL', kind: 'item', color: '#FF6A1A', glyph: 'diamond' }, slow: { title: 'Slow Field', sub: 'Hangar unlock · paid in POL', kind: 'item', color: '#A78BFA', glyph: 'dome' }, ch1: { title: 'First Chapter', sub: 'Chapter 1 cleared', kind: 'chapter', color: '#8FF0FF', glyph: 'hex', n: 1 }, ch3: { title: 'Chapter 3', sub: 'Three chapters deep', kind: 'chapter', color: '#8FF0FF', glyph: 'hex', n: 3 }, ch5: { title: 'Chapter 5', sub: 'Halfway to double digits', kind: 'chapter', color: '#FFC24B', glyph: 'hex', n: 5 }, ch10: { title: 'Chapter 10', sub: 'Double digits', kind: 'chapter', color: '#FFC24B', glyph: 'hex', n: 10 }, ch15: { title: 'Chapter 15', sub: 'Deep in the network', kind: 'chapter', color: '#FF6A1A', glyph: 'hex', n: 15 }, ch20: { title: 'Chapter 20', sub: 'Network legend', kind: 'chapter', color: '#FF6A1A', glyph: 'hex', n: 20 }, refuel5: { title: 'Five Refuels', sub: 'Keeps the run alive', kind: 'refuel', color: '#FF6A1A', glyph: 'fuel' }, refuel25: { title: '25 Refuels', sub: 'Runs on sponsor pages', kind: 'refuel', color: '#FF6A1A', glyph: 'fuel' }, refuel100: { title: '100 Refuels', sub: 'Never restarts', kind: 'refuel', color: '#FFC24B', glyph: 'fuel' }, paid: { title: 'Paid in POL', sub: 'Sent to their wallet', kind: 'paid', color: '#34D399', glyph: 'coin' }, }; function glyph(g, color, n) { const c = color; if (g === 'orb') return `
`; if (g === 'ship') return `
`; if (g === 'diamond') return `
`; if (g === 'dome') return `
`; if (g === 'hex') return `
${n}
`; if (g === 'fuel') return `
`; if (g === 'coin') return `
POL
`; return ''; } function html(id, b) { return `
${b.kind === 'paid' ? 'Payout sent' : 'Achievement unlocked'}
${glyph(b.glyph, b.color, b.n)}
${b.title}
${b.sub}
InstantAdPay members · paid in POL
`; } const browser = await chromium.launch(); const page = await browser.newPage({ viewport: { width: 1080, height: 1080 }, deviceScaleFactor: 1 }); for (const [id, b] of Object.entries(BADGES)) { await page.setContent(html(id, b), { waitUntil: 'networkidle' }); await page.evaluate(() => document.fonts.ready); await page.waitForTimeout(300); await page.screenshot({ path: path.join(OUT, id + '.png'), type: 'png' }); console.log('rendered', id); } await browser.close();