feat: footer, auto-pause on no viewers, and Redsys question submissions
- Footer: add site-footer with one-liner + Cloud Host branding linking to cloudhost.es (mobile only, hidden on desktop) - Auto-pause: game pauses automatically after AUTOPAUSE_DELAY_MS (default 60s) with no viewers connected; auto-resumes when first viewer connects; shows "Esperando espectadores…" in the UI - Redsys: new /pregunta page lets viewers pay 1€ via Redsys to submit a fill-in question; submitted questions are used as prompts in the next round instead of AI generation; new redsys.ts implements HMAC_SHA256_V1 signing (3DES key derivation + HMAC-SHA256); notification endpoint at /api/redsys/notificacion handles server-to-server confirmation - db.ts: questions table with createPendingQuestion / markQuestionPaid / getNextPendingQuestion / markQuestionUsed - .env.sample: added AUTOPAUSE_DELAY_MS, PUBLIC_URL, REDSYS_* vars Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
24
game.ts
24
game.ts
@@ -76,6 +76,7 @@ export type GameState = {
|
||||
viewerScores: Record<string, number>;
|
||||
done: boolean;
|
||||
isPaused: boolean;
|
||||
autoPaused: boolean;
|
||||
generation: number;
|
||||
};
|
||||
|
||||
@@ -264,7 +265,7 @@ export async function callVote(
|
||||
return cleaned.startsWith("A") ? "A" : "B";
|
||||
}
|
||||
|
||||
import { saveRound } from "./db.ts";
|
||||
import { saveRound, getNextPendingQuestion, markQuestionUsed } from "./db.ts";
|
||||
|
||||
// ── Game loop ───────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -325,12 +326,21 @@ export async function runGame(
|
||||
|
||||
// ── Prompt phase ──
|
||||
try {
|
||||
const prompt = await withRetry(
|
||||
() => callGeneratePrompt(prompter),
|
||||
(s) => isRealString(s, 10),
|
||||
3,
|
||||
`R${r}:prompt:${prompter.name}`,
|
||||
);
|
||||
// Use a user-submitted question if one is pending, otherwise call AI
|
||||
const pendingQ = getNextPendingQuestion();
|
||||
let prompt: string;
|
||||
if (pendingQ) {
|
||||
markQuestionUsed(pendingQ.id);
|
||||
prompt = pendingQ.text;
|
||||
log("INFO", `R${r}:prompt`, "Using user-submitted question", { id: pendingQ.id });
|
||||
} else {
|
||||
prompt = await withRetry(
|
||||
() => callGeneratePrompt(prompter),
|
||||
(s) => isRealString(s, 10),
|
||||
3,
|
||||
`R${r}:prompt:${prompter.name}`,
|
||||
);
|
||||
}
|
||||
if (state.generation !== roundGeneration) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user