From 66629232e93c5b3cf7e574b40c42cb675928ae00 Mon Sep 17 00:00:00 2001 From: Jean-Charles Date: Mon, 5 Feb 2024 14:28:16 +0100 Subject: [PATCH 1/3] fix variable typo --- apps/docs/docs/guide/tictactoe.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/docs/docs/guide/tictactoe.md b/apps/docs/docs/guide/tictactoe.md index 1e02ec47..204d82f3 100644 --- a/apps/docs/docs/guide/tictactoe.md +++ b/apps/docs/docs/guide/tictactoe.md @@ -60,9 +60,9 @@ We don't have to check that it's the current player - it's already done by the g The function could be as simple as this: ```ts -export function move(state: GameState, move: Coord, player: Player) { +export function move(state: GameState, coord: Coord, player: Player) { state.board[coord.x][coord.y] = player; - state.moves.push({ player, coord: move }); + state.moves.push({ player, coord }); return state; } From a0f925a35d9bfd2a701ba98c69df4cdf6f51e0b8 Mon Sep 17 00:00:00 2001 From: Jean-Charles Date: Mon, 5 Feb 2024 15:47:15 +0100 Subject: [PATCH 2/3] bugfix other typos in tictactoe.md ts examples --- apps/docs/docs/guide/tictactoe.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/docs/docs/guide/tictactoe.md b/apps/docs/docs/guide/tictactoe.md index 204d82f3..dd5c7c0e 100644 --- a/apps/docs/docs/guide/tictactoe.md +++ b/apps/docs/docs/guide/tictactoe.md @@ -100,9 +100,9 @@ function winner(board: Board): Player | undefined { Then we add that info in the `move` function: ```ts -export function move(state: GameState, move: Coord, player: Player) { +export function move(state: GameState, coord: Coord, player: Player) { state.board[coord.x][coord.y] = player; - state.moves.push({ player, coord: move }); + state.moves.push({ player, coord }); // Either it stays undefined or is set to the winner state.winner = winner(state.board); @@ -165,7 +165,7 @@ export function currentPlayer(state: GameState): Player { return 0; } - return opponent(state.moves[state.moves.length - 1]); + return opponent(state.moves[state.moves.length - 1].player); } ``` @@ -185,7 +185,7 @@ As such the log length is the number of moves + 1 if there is no winner, and the ```ts export function logLength(state: GameState): number { - return 1 + moves.length + (state.winner !== undefined ? 1 : 0); + return 1 + state.moves.length + (state.winner !== undefined ? 1 : 0); } ``` From 1ade555c20db88cfaa697abcc4e8784412f6bb57 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Sat, 12 Oct 2024 15:04:16 +0200 Subject: [PATCH 3/3] glcanvas for macroquad --- apps/api/app/resources.ts | 41 +++++++++++++------ .../src/components/Game/StartedGame.svelte | 4 +- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/apps/api/app/resources.ts b/apps/api/app/resources.ts index ae89c179..624e0e7e 100644 --- a/apps/api/app/resources.ts +++ b/apps/api/app/resources.ts @@ -33,20 +33,35 @@ router.get("/game/:game_name/:game_version/iframe", async (ctx) => { gameInfo?.viewer?.alternate?.url && ctx.query.alternate === "1" ? gameInfo?.viewer.alternate : gameInfo.viewer; const viewerUrl = ctx.query.customViewerUrl || viewer.url; - ctx.body = ` - - - - ${viewer.dependencies.scripts.map((dep) => `<${"script"} src='${dep}'>`).join("\n")} - <${"script"} src='${viewerUrl}' type='text/javascript'> - ${viewer.dependencies.stylesheets - .map((dep) => ``) - .join("\n")} + const stylesheets = viewer.dependencies.stylesheets + .map((dep) => ``) + .join("\n"); + const scripts = viewer.dependencies.scripts.map((dep) => `<${"script"} src='${dep}'>`).join("\n"); + const viewerScript = `<${"script"} src='${viewerUrl}' type='text/javascript'>`; + + const template = viewer.topLevelVariable === "clash" ? ` + + + ${stylesheets} - -
-
- + + + ${scripts} + ${viewerScript} + ` : ` + + + ${scripts} + ${viewerScript} + ${stylesheets} + + +
+
+ `; + + ctx.body = ` + ${template} <${"script"} type='text/javascript'> const gameObj = window.${viewer.topLevelVariable}.launch('#app'); window.addEventListener('message', event => { diff --git a/apps/web/src/components/Game/StartedGame.svelte b/apps/web/src/components/Game/StartedGame.svelte index 6cfd7e71..2374982a 100644 --- a/apps/web/src/components/Game/StartedGame.svelte +++ b/apps/web/src/components/Game/StartedGame.svelte @@ -217,11 +217,11 @@ ${$game.players.map((pl) => `- ${pl.name} (${pl.score} pts)`).join("\n")}`; {#key gameId}