Game testers (env GAMES_TESTERS) see the Play button on a coming-soon game from the Games tab before it opens (Road Agent testers, Marty 2026-10-07)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-07 17:17:33 -05:00
parent b82f63f803
commit 8285e31fbd
+8 -2
View File
@@ -1509,6 +1509,9 @@ function seasonState(season, day, admin) {
if (day < season.start) return admin ? 'preview' : 'hidden';
return 'live';
}
// game testers: GAMES_TESTERS env = comma list of usernames or emails who may play coming-soon / not-yet-live games from the Games tab
const GAME_TESTERS = () => new Set(String(process.env.GAMES_TESTERS || '').split(',').map(x => x.trim().toLowerCase()).filter(Boolean));
const isGameTester = (acct, email) => { const T = GAME_TESTERS(); if (!T.size) return false; return T.has(String((acct && acct.username) || '').toLowerCase()) || T.has(String(email || '').toLowerCase()); };
// -- the games registry (2026-10-01). Add a game here; launch it by adding its slug to site config gamesLive.
function GAMES() {
return withPerks([
@@ -3404,10 +3407,13 @@ const server = http.createServer(async (req, res) => {
const dayLabel = (d, back) => { const t = new Date(d + 'T12:00:00Z'); if (back) t.setUTCDate(t.getUTCDate() - 1); return t.toLocaleDateString('en-US', { month: 'short', day: 'numeric', timeZone: 'UTC' }); };
for (const g of GAMES()) {
// a seasonal game (2026-10-02) shows only while today (Central) is in [start, end); before start the admin sees a preview, after end nobody
if (g.soon && day < g.soon.opens) { out.push(Object.assign({}, g, { live: false, preview: false, soon: g.soon.label, play: null })); continue; } // coming soon: shown to all, not playable
// testers (env GAMES_TESTERS, usernames or emails; Marty 2026-10-07) get the Play button on a coming-soon game before it opens
const tester = isGameTester(acct, s.email);
if (g.soon && day < g.soon.opens && !tester) { out.push(Object.assign({}, g, { live: false, preview: false, soon: g.soon.label, play: null })); continue; } // coming soon: shown to all, not playable
if (g.soon && day < g.soon.opens && tester) { out.push(Object.assign({}, g, { live: false, preview: true, previewNote: 'testing · ' + g.soon.label.toLowerCase() })); continue; }
const ss = seasonState(g.season, day, admin); if (ss === 'hidden') continue;
const seasonPreview = ss === 'preview';
const isLive = live.has(g.slug); if (!isLive && !admin) continue;
const isLive = live.has(g.slug); if (!isLive && !admin && !tester) continue;
const card = Object.assign({}, g, { live: isLive, preview: !isLive || seasonPreview });
if (g.season) { card.season = Object.assign({}, g.season, { opens: dayLabel(g.season.start), ends: dayLabel(g.season.end, true) }); if (seasonPreview) card.previewNote = 'preview, opens ' + card.season.opens; }
if (g.progress && (memberId || g.slug === 'passivedrip')) { try { card.progress = await g.progress(memberId, s.email); } catch (e) {} }