fixed build
This commit is contained in:
parent
ebbc8d0f29
commit
3a14766563
|
|
@ -17,6 +17,7 @@ describe("Game", () => {
|
||||||
|
|
||||||
it("should convert server to client game", () => {
|
it("should convert server to client game", () => {
|
||||||
const serverGame: ServerGame = {
|
const serverGame: ServerGame = {
|
||||||
|
theme: "default",
|
||||||
mines: [
|
mines: [
|
||||||
[false, false, true, true, true],
|
[false, false, true, true, true],
|
||||||
[true, false, true, false, true],
|
[true, false, true, false, true],
|
||||||
|
|
@ -52,6 +53,7 @@ describe("Game", () => {
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
expect(serverToClientGame(serverGame)).toEqual({
|
expect(serverToClientGame(serverGame)).toEqual({
|
||||||
|
theme: "default",
|
||||||
minesCount: 4,
|
minesCount: 4,
|
||||||
isRevealed: [
|
isRevealed: [
|
||||||
[false, false, true, false, true],
|
[false, false, true, false, true],
|
||||||
|
|
|
||||||
|
|
@ -39,5 +39,6 @@ export const serverToClientGame = (game: ServerGame): ClientGame => {
|
||||||
lastClick: game.lastClick,
|
lastClick: game.lastClick,
|
||||||
started: game.started,
|
started: game.started,
|
||||||
stage: game.stage,
|
stage: game.stage,
|
||||||
|
theme: game.theme,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ const rotate = (arr: boolean[][]) => {
|
||||||
return arr[0].map((_, colIndex) => arr.map((row) => row[colIndex]));
|
return arr[0].map((_, colIndex) => arr.map((row) => row[colIndex]));
|
||||||
};
|
};
|
||||||
|
|
||||||
export const testBoard: ServerGame = {
|
export const testBoard: (theme: string) => ServerGame = (theme: string) => ({
|
||||||
user: "TestUser",
|
user: "TestUser",
|
||||||
uuid: "C270D7CD-AF97-42CE-A6C9-CB765102CA17",
|
uuid: "C270D7CD-AF97-42CE-A6C9-CB765102CA17",
|
||||||
width: 11,
|
width: 11,
|
||||||
|
|
@ -38,4 +38,5 @@ export const testBoard: ServerGame = {
|
||||||
[...Array<boolean>(11).fill(false)],
|
[...Array<boolean>(11).fill(false)],
|
||||||
[...Array<boolean>(11).fill(false)],
|
[...Array<boolean>(11).fill(false)],
|
||||||
]),
|
]),
|
||||||
};
|
theme,
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -36,10 +36,10 @@ import "@pixi/canvas-renderer";
|
||||||
import "@pixi/canvas-sprite-tiling";
|
import "@pixi/canvas-sprite-tiling";
|
||||||
import "@pixi/canvas-sprite";
|
import "@pixi/canvas-sprite";
|
||||||
import "@pixi/canvas-text";
|
import "@pixi/canvas-text";
|
||||||
|
import { themes } from "../themes";
|
||||||
|
|
||||||
interface BoardProps {
|
interface BoardProps {
|
||||||
className?: string;
|
className?: string;
|
||||||
theme: Theme;
|
|
||||||
game: ServerGame | ClientGame;
|
game: ServerGame | ClientGame;
|
||||||
onLeftClick: (x: number, y: number) => void;
|
onLeftClick: (x: number, y: number) => void;
|
||||||
onRightClick: (x: number, y: number) => void;
|
onRightClick: (x: number, y: number) => void;
|
||||||
|
|
@ -120,7 +120,10 @@ const Board: React.FC<BoardProps> = (props) => {
|
||||||
resizeObserver.observe(ref.current);
|
resizeObserver.observe(ref.current);
|
||||||
return () => resizeObserver.disconnect();
|
return () => resizeObserver.disconnect();
|
||||||
}, [onViewportChange]);
|
}, [onViewportChange]);
|
||||||
const theme = useTheme(props.theme);
|
const theme = useTheme(
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
themes.find((t) => t.id === (game.theme as any))!.theme,
|
||||||
|
);
|
||||||
const boardWidth = game.width * (theme?.size || 0);
|
const boardWidth = game.width * (theme?.size || 0);
|
||||||
const boardHeight = game.height * (theme?.size || 0);
|
const boardHeight = game.height * (theme?.size || 0);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ interface ThemeEntry {
|
||||||
tags: string[];
|
tags: string[];
|
||||||
/** dont't ever change this! */
|
/** dont't ever change this! */
|
||||||
id: string;
|
id: string;
|
||||||
theme: Theme;
|
theme: Readonly<Theme>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const themes = [
|
export const themes = [
|
||||||
|
|
|
||||||
|
|
@ -68,8 +68,7 @@ const Collection = () => {
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
</div>
|
</div>
|
||||||
<Board
|
<Board
|
||||||
game={testBoard}
|
game={testBoard(theme.id)}
|
||||||
theme={theme.theme}
|
|
||||||
onLeftClick={() => {}}
|
onLeftClick={() => {}}
|
||||||
restartGame={() => {}}
|
restartGame={() => {}}
|
||||||
onRightClick={() => {}}
|
onRightClick={() => {}}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
import { defaultTheme } from "../../themes/default";
|
|
||||||
import Board from "../../components/Board";
|
import Board from "../../components/Board";
|
||||||
import { useWSMutation, useWSQuery } from "../../hooks";
|
import { useWSMutation, useWSQuery } from "../../hooks";
|
||||||
import { useAtom } from "jotai";
|
import { useAtom } from "jotai";
|
||||||
|
|
@ -46,7 +45,6 @@ const Endless: React.FC<EndlessProps> = (props) => {
|
||||||
<LeaderboardButton label="View Leaderboard" />
|
<LeaderboardButton label="View Leaderboard" />
|
||||||
</div>
|
</div>
|
||||||
<Board
|
<Board
|
||||||
theme={defaultTheme}
|
|
||||||
game={game}
|
game={game}
|
||||||
restartGame={async () => {
|
restartGame={async () => {
|
||||||
const gameId = await startGame.mutateAsync(null);
|
const gameId = await startGame.mutateAsync(null);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue