diff --git a/src/routes/api/games/[id]/nudge-image/+server.ts b/src/routes/api/games/[id]/nudge-image/+server.ts index 26a4f89..f7235b5 100644 --- a/src/routes/api/games/[id]/nudge-image/+server.ts +++ b/src/routes/api/games/[id]/nudge-image/+server.ts @@ -2,6 +2,7 @@ import { error } from '@sveltejs/kit'; import type { RequestHandler } from './$types'; import { ensureGameInDb } from '$lib/server/db'; import { resolveDidToHandle, fetchUserProfile } from '$lib/atproto-client'; +import { generateBoardSvg } from '$lib/server/board-svg'; import { renderPng, emojiSvgFragment, @@ -31,6 +32,17 @@ export const GET: RequestHandler = async (event) => { const playerAvatarBase64 = playerProfile?.avatar ? await imageDataUrl(playerProfile.avatar) : null; const opponentAvatarBase64 = opponentProfile?.avatar ? await imageDataUrl(opponentProfile.avatar) : null; + // The board comes from the same walnut renderer as every other card. It + // is empty: a nudge is about the two players, not the position. + const boardSvg = generateBoardSvg( + game.board_size, + Array.from({ length: game.board_size }, () => + Array.from({ length: game.board_size }, () => null) + ), + null, + { size: 300, padding: 30 } + ); + // Generate confrontational Go board image const svg = ` @@ -39,10 +51,6 @@ export const GET: RequestHandler = async (event) => { - - - - @@ -58,23 +66,8 @@ export const GET: RequestHandler = async (event) => { - - - - - ${Array.from({ length: 9 }, (_, i) => { - const xPos = 150 + i * 37.5; - const yPos = 50 + i * 37.5; - return ` - `; - }).join('')} - - - - - - - + + ${boardSvg} diff --git a/src/routes/api/games/[id]/nudge/+server.ts b/src/routes/api/games/[id]/nudge/+server.ts index d6cde42..c846e36 100644 --- a/src/routes/api/games/[id]/nudge/+server.ts +++ b/src/routes/api/games/[id]/nudge/+server.ts @@ -4,6 +4,7 @@ import { getSession, getAgent } from '$lib/server/auth'; import { ensureGameInDb } from '$lib/server/db'; import { resolveDidToHandle, fetchUserProfile } from '$lib/atproto-client'; import { gameTitle } from '$lib/game-titles'; +import { generateBoardSvg } from '$lib/server/board-svg'; import { renderPng, emojiSvgFragment, @@ -57,6 +58,17 @@ export const POST: RequestHandler = async (event) => { const playerAvatarBase64 = playerProfile?.avatar ? await imageDataUrl(playerProfile.avatar) : null; const opponentAvatarBase64 = opponentProfile?.avatar ? await imageDataUrl(opponentProfile.avatar) : null; + // The board comes from the same walnut renderer as every other card. It + // is empty: a nudge is about the two players, not the position. + const boardSvg = generateBoardSvg( + game.board_size, + Array.from({ length: game.board_size }, () => + Array.from({ length: game.board_size }, () => null) + ), + null, + { size: 300, padding: 30 } + ); + // Generate confrontational Go board image const svg = ` @@ -65,10 +77,6 @@ export const POST: RequestHandler = async (event) => { - - - - @@ -84,23 +92,8 @@ export const POST: RequestHandler = async (event) => { - - - - - ${Array.from({ length: 9 }, (_, i) => { - const xPos = 150 + i * 37.5; - const yPos = 50 + i * 37.5; - return ` - `; - }).join('')} - - - - - - - + + ${boardSvg}