diff --git a/package.json b/package.json index 058cd9f..e0b1019 100644 --- a/package.json +++ b/package.json @@ -56,10 +56,7 @@ "eslint --fix" ] }, - "dependencies": { - "styled-components": "^6.1.13", - "vite-plugin-dts": "^4.5.0" - }, + "dependencies": {}, "devDependencies": { "@commitlint/cli": "^19.6.1", "@commitlint/config-conventional": "^19.6.0", @@ -77,6 +74,7 @@ "prettier": "3.4.2", "typescript": "~5.6.2", "typescript-eslint": "^8.13.0", - "vite": "^5.4.10" + "vite": "^5.4.10", + "vite-plugin-dts": "^4.5.0" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ea88d7d..d4d5285 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -17,12 +17,6 @@ importers: react-dom: specifier: ^17.0.0 || ^18.0.0 || ^19.0.0 version: 18.3.1(react@18.3.1) - styled-components: - specifier: ^6.1.13 - version: 6.1.13(react-dom@18.3.1(react@18.3.1))(react@18.3.1) - vite-plugin-dts: - specifier: ^4.5.0 - version: 4.5.0(@types/node@22.10.2)(rollup@4.24.4)(typescript@5.6.3)(vite@5.4.11(@types/node@22.10.2)(terser@5.36.0)) devDependencies: '@commitlint/cli': specifier: ^19.6.1 @@ -75,6 +69,9 @@ importers: vite: specifier: ^5.4.10 version: 5.4.11(@types/node@22.10.2)(terser@5.36.0) + vite-plugin-dts: + specifier: ^4.5.0 + version: 4.5.0(@types/node@22.10.2)(rollup@4.24.4)(typescript@5.6.3)(vite@5.4.11(@types/node@22.10.2)(terser@5.36.0)) packages: @@ -230,15 +227,6 @@ packages: resolution: {integrity: sha512-DSHae2obMSMkAtTBSOulg5X7/z+rGLxcXQIkg3OmWvY6wifojge5uVMydfhUvs7yQj+V7jNmRZ2Xzl8GJyqRgg==} engines: {node: '>=v18'} - '@emotion/is-prop-valid@1.2.2': - resolution: {integrity: sha512-uNsoYd37AFmaCdXlg6EYD1KaPOaRWRByMCYzbKUX4+hhMfrxdVSelShywL4JVaAeM/eHUOSprYBQls+/neX3pw==} - - '@emotion/memoize@0.8.1': - resolution: {integrity: sha512-W2P2c/VRW1/1tLox0mVUalvnWXxavmv/Oum2aPsRcoDJuob75FC3Y8FbpfLwUegRcxINtGUMPq0tFCvYNTBXNA==} - - '@emotion/unitless@0.8.1': - resolution: {integrity: sha512-KOEGMu6dmJZtpadb476IsZBclKvILjopjUii3V+7MnXIQCYh8W3NgNcgwo21n9LXZX6EDIKvqfjYxXebDwxKmQ==} - '@esbuild/aix-ppc64@0.21.5': resolution: {integrity: sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ==} engines: {node: '>=12'} @@ -643,9 +631,6 @@ packages: '@types/react@18.3.12': resolution: {integrity: sha512-D2wOSq/d6Agt28q7rSI3jhU7G6aiuzljDGZ2hTZHIkrTLUI+AF3WMeKkEZ9nN2fkBAlcktT6vcZjDFiIhMYEQw==} - '@types/stylis@4.2.5': - resolution: {integrity: sha512-1Xve+NMN7FWjY14vLoY5tL3BVEQ/n42YLwaqJIPYhotZ9uBHt87VceMwWQpzmdEt2TNXIorIFG+YeCUUW7RInw==} - '@typescript-eslint/eslint-plugin@8.18.1': resolution: {integrity: sha512-Ncvsq5CT3Gvh+uJG0Lwlho6suwDfUXH0HztslDf5I+F2wAFAZMRwYLEorumpKLzmO2suAXZ/td1tBg4NZIi9CQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -871,9 +856,6 @@ packages: resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} engines: {node: '>=6'} - camelize@1.0.1: - resolution: {integrity: sha512-dU+Tx2fsypxTgtLoE36npi3UqcjSSMNYfkqgmoEhtZrraP5VWq0K7FkWVTYa8eMPtnU/G2txVsfdCJTn9uzpuQ==} - caniuse-lite@1.0.30001678: resolution: {integrity: sha512-RR+4U/05gNtps58PEBDZcPWTgEO2MBeoPZ96aQcjmfkBWRIDfN451fW2qyDA9/+HohLLIL5GqiMwA+IB1pWarw==} @@ -963,13 +945,6 @@ packages: resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==} engines: {node: '>= 8'} - css-color-keywords@1.0.0: - resolution: {integrity: sha512-FyyrDHZKEjXDpNJYvVsV960FiqQyXc/LlYmsxl2BcdMb2WPx0OGRVgTg55rPSyLSNMqP52R9r8geSp7apN3Ofg==} - engines: {node: '>=4'} - - css-to-react-native@3.2.0: - resolution: {integrity: sha512-e8RKaLXMOFii+02mOlqwjbD00KSEKqblnpO9e++1aXS1fPQOpS1YoqdVHBqPjHNoxeF2mimzVqawm2KCbEdtHQ==} - csstype@3.1.3: resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==} @@ -1815,13 +1790,6 @@ packages: resolution: {integrity: sha512-d7Uw+eZoloe0EHDIYoe+bQ5WXnGMOpmiZFTuMWCwpjzzkL2nTjcKiAk4hh8TjnGye2TwWOk3UXucZ+3rbmBa8Q==} engines: {node: '>= 0.4'} - postcss-value-parser@4.2.0: - resolution: {integrity: sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==} - - postcss@8.4.38: - resolution: {integrity: sha512-Wglpdk03BSfXkHoQa3b/oulrotAkwrlLDRSOb9D0bN86FdRyE9lppSp33aHNPgBa0JKCoB+drFLZkQoRRYae5A==} - engines: {node: ^10 || ^12 || >=14} - postcss@8.4.49: resolution: {integrity: sha512-OCVPnIObs4N29kxTjzLfUryOkvZEq+pf8jTF0lg8E7uETuWHA+v7j3c/xJmiqpX450191LlmZfUKkXxkTry7nA==} engines: {node: ^10 || ^12 || >=14} @@ -1946,9 +1914,6 @@ packages: resolution: {integrity: sha512-7PGFlmtwsEADb0WYyvCMa1t+yke6daIG4Wirafur5kcf+MhUnPms1UeR0CKQdTZD81yESwMHbtn+TR+dMviakQ==} engines: {node: '>= 0.4'} - shallowequal@1.1.0: - resolution: {integrity: sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ==} - shebang-command@2.0.0: resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} engines: {node: '>=8'} @@ -2050,16 +2015,6 @@ packages: resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==} engines: {node: '>=8'} - styled-components@6.1.13: - resolution: {integrity: sha512-M0+N2xSnAtwcVAQeFEsGWFFxXDftHUD7XrKla06QbpUMmbmtFBMMTcKWvFXtWxuD5qQkB8iU5gk6QASlx2ZRMw==} - engines: {node: '>= 16'} - peerDependencies: - react: '>= 16.8.0' - react-dom: '>= 16.8.0' - - stylis@4.3.2: - resolution: {integrity: sha512-bhtUjWd/z6ltJiQwg0dUfxEJ+W+jdqQd8TbWLWyeIJHlnsqmGLRFFd8e5mA0AZi/zx90smXRlN66YMTcaSFifg==} - supports-color@7.2.0: resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} engines: {node: '>=8'} @@ -2097,9 +2052,6 @@ packages: peerDependencies: typescript: '>=4.2.0' - tslib@2.6.2: - resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} - type-check@0.4.0: resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} engines: {node: '>= 0.8.0'} @@ -2498,14 +2450,6 @@ snapshots: '@types/conventional-commits-parser': 5.0.1 chalk: 5.3.0 - '@emotion/is-prop-valid@1.2.2': - dependencies: - '@emotion/memoize': 0.8.1 - - '@emotion/memoize@0.8.1': {} - - '@emotion/unitless@0.8.1': {} - '@esbuild/aix-ppc64@0.21.5': optional: true @@ -2841,8 +2785,6 @@ snapshots: '@types/prop-types': 15.7.13 csstype: 3.1.3 - '@types/stylis@4.2.5': {} - '@typescript-eslint/eslint-plugin@8.18.1(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@2.4.2))(typescript@5.6.3))(eslint@9.17.0(jiti@2.4.2))(typescript@5.6.3)': dependencies: '@eslint-community/regexpp': 4.12.1 @@ -3150,8 +3092,6 @@ snapshots: callsites@3.1.0: {} - camelize@1.0.1: {} - caniuse-lite@1.0.30001678: {} chalk@4.1.2: @@ -3239,14 +3179,6 @@ snapshots: shebang-command: 2.0.0 which: 2.0.2 - css-color-keywords@1.0.0: {} - - css-to-react-native@3.2.0: - dependencies: - camelize: 1.0.1 - css-color-keywords: 1.0.0 - postcss-value-parser: 4.2.0 - csstype@3.1.3: {} dargs@8.1.0: {} @@ -4167,14 +4099,6 @@ snapshots: possible-typed-array-names@1.0.0: {} - postcss-value-parser@4.2.0: {} - - postcss@8.4.38: - dependencies: - nanoid: 3.3.7 - picocolors: 1.1.1 - source-map-js: 1.2.1 - postcss@8.4.49: dependencies: nanoid: 3.3.7 @@ -4326,8 +4250,6 @@ snapshots: functions-have-names: 1.2.3 has-property-descriptors: 1.0.2 - shallowequal@1.1.0: {} - shebang-command@2.0.0: dependencies: shebang-regex: 3.0.0 @@ -4458,22 +4380,6 @@ snapshots: strip-json-comments@3.1.1: {} - styled-components@6.1.13(react-dom@18.3.1(react@18.3.1))(react@18.3.1): - dependencies: - '@emotion/is-prop-valid': 1.2.2 - '@emotion/unitless': 0.8.1 - '@types/stylis': 4.2.5 - css-to-react-native: 3.2.0 - csstype: 3.1.3 - postcss: 8.4.38 - react: 18.3.1 - react-dom: 18.3.1(react@18.3.1) - shallowequal: 1.1.0 - stylis: 4.3.2 - tslib: 2.6.2 - - stylis@4.3.2: {} - supports-color@7.2.0: dependencies: has-flag: 4.0.0 @@ -4506,8 +4412,6 @@ snapshots: dependencies: typescript: 5.6.3 - tslib@2.6.2: {} - type-check@0.4.0: dependencies: prelude-ls: 1.2.1 diff --git a/src/components/Backgammon.tsx b/src/components/Backgammon.tsx index 0ac7a80..44591b0 100644 --- a/src/components/Backgammon.tsx +++ b/src/components/Backgammon.tsx @@ -1,14 +1,15 @@ "use client"; +import React from "react"; import { DimensionProvider, GameStateProvider, PositionProvider, ThemeProvider, } from "../providers"; -import { BoardStateState } from "../types"; +import { BoardState } from "../types"; import { Board } from "./Board"; -export const Backgammon: React.FC = ({ +export const Backgammon: React.FC = ({ theme, positions, preset, diff --git a/src/components/Board.tsx b/src/components/Board.tsx index c126c11..759f11b 100644 --- a/src/components/Board.tsx +++ b/src/components/Board.tsx @@ -19,13 +19,13 @@ export const Board: React.FC = () => { pointWidth, boardHeight, sidebarWidth, - sidebarRationModifier, + sidebarRatioModifier, } = dimensions; const direction = gameState?.direction ?? "clockwise"; const isClockwise = direction === "clockwise"; - const sidebarRenderedWidth = sidebarWidth * sidebarRationModifier; + const sidebarRenderedWidth = sidebarWidth * sidebarRatioModifier; const mainBoardX = isClockwise ? 0 : sidebarRenderedWidth - borderWidth; const sidebarX = isClockwise ? boardWidth - sidebarRenderedWidth - borderWidth @@ -36,14 +36,14 @@ export const Board: React.FC = () => { key="board" width="100%" height="100%" - viewBox={`0 0 ${boardWidth - borderWidth} ${boardHeight * sidebarRationModifier}`} + viewBox={`0 0 ${boardWidth - borderWidth} ${boardHeight * sidebarRatioModifier}`} xmlns="http://www.w3.org/2000/svg" > diff --git a/src/components/Checker.tsx b/src/components/Checker.tsx index f468686..70ded3e 100644 --- a/src/components/Checker.tsx +++ b/src/components/Checker.tsx @@ -1,34 +1,10 @@ +import React from "react"; import { useDimensions, usePosition, useTheme } from "../providers"; import { PlayerType } from "../types"; +import { NumberRange } from "../type-utils"; type CheckerProps = { - x: - | 0 - | 1 - | 2 - | 3 - | 4 - | 5 - | 6 - | 7 - | 8 - | 9 - | 10 - | 11 - | 12 - | 13 - | 14 - | 15 - | 16 - | 17 - | 18 - | 19 - | 20 - | 21 - | 22 - | 23 - | 24 - | "bar"; + x: NumberRange<25> | "bar"; y: number; playerType: PlayerType; totalOnPoint: number; diff --git a/src/components/Die.tsx b/src/components/Die.tsx index e3811b7..96e498f 100644 --- a/src/components/Die.tsx +++ b/src/components/Die.tsx @@ -1,3 +1,5 @@ +import React from "react"; + import { useDimensions, useTheme } from "../providers"; import { DieValue, PlayerType } from "../types"; @@ -6,7 +8,7 @@ type DieProps = { colorSchema: PlayerType; }; -export const Die: React.FC = ({ value = 2, colorSchema }) => { +export const Die: React.FC = ({ value, colorSchema }) => { const { playerCheckerColor, playerCheckerBorderColor, @@ -57,14 +59,12 @@ export const Die: React.FC = ({ value = 2, colorSchema }) => { r={dieDotSize} fill={dotFillColor} /> - ; - ; ); break; @@ -101,7 +101,6 @@ export const Die: React.FC = ({ value = 2, colorSchema }) => { r={dieDotSize} fill={dotFillColor} /> - ; ); break; @@ -156,7 +155,6 @@ export const Die: React.FC = ({ value = 2, colorSchema }) => { r={dieDotSize} fill={dotFillColor} /> - ; ); break; @@ -206,13 +204,6 @@ export const Die: React.FC = ({ value = 2, colorSchema }) => { fill={dieBackgroundColor} /> {dots} - {/* - - - - - - */} ); diff --git a/src/components/DoublingCube.tsx b/src/components/DoublingCube.tsx index 2ab1745..0c12b28 100644 --- a/src/components/DoublingCube.tsx +++ b/src/components/DoublingCube.tsx @@ -1,3 +1,4 @@ +import React from "react"; import { useDimensions, useTheme } from "../providers"; import type { DoublingCube as DoublingCubeType } from "../types"; @@ -6,7 +7,6 @@ export const DoublingCube: React.FC = ({ owner, value }) => { const { boardHeight, sidebarWidth, cubeWidth, borderWidth } = useDimensions(); const xPos = (sidebarWidth - cubeWidth) / 2; - // const yPos = (boardHeight - cubeWidth) / 2 + (owner === "player" ? cubeWidth / 2 : -(cubeWidth / 2)); const yPos = owner === null ? boardHeight / 2 - cubeWidth / 2 diff --git a/src/components/PipCounter.tsx b/src/components/PipCounter.tsx index 7039984..18b9698 100644 --- a/src/components/PipCounter.tsx +++ b/src/components/PipCounter.tsx @@ -1,3 +1,4 @@ +import React from "react"; import { useDimensions, useGameState, useTheme } from "../providers"; import { PlayerType } from "../types"; diff --git a/src/components/Point.tsx b/src/components/Point.tsx index aa7e4d4..1b91d91 100644 --- a/src/components/Point.tsx +++ b/src/components/Point.tsx @@ -1,3 +1,4 @@ +import React from "react"; import { useDimensions, useTheme } from "../providers"; type PointProps = { @@ -41,7 +42,6 @@ export const Point: React.FC = ({ fill={odd ? pointColor : altPointColor} fillOpacity={odd ? "1" : "0.4"} /> - ; ); }; diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index 5516f2a..2f2725d 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -1,3 +1,4 @@ +import React from "react"; import { useDimensions, useGameState, useTheme } from "../providers"; import { DoublingCube } from "./DoublingCube"; diff --git a/src/helpers/calculate-base-points.ts b/src/helpers/calculate-base-points.ts index 09dcb5a..04af5f8 100644 --- a/src/helpers/calculate-base-points.ts +++ b/src/helpers/calculate-base-points.ts @@ -1,8 +1,9 @@ -import { useDimensions } from "../providers"; import { Direction } from "../types"; +import { Dimensions } from "./dimensions"; + export const calculateBasePoints = ( - dimensions: ReturnType, + dimensions: Dimensions, direction: Direction = "clockwise", ) => { const { diff --git a/src/helpers/dimensions.ts b/src/helpers/dimensions.ts index 2fb6f36..07176d8 100644 --- a/src/helpers/dimensions.ts +++ b/src/helpers/dimensions.ts @@ -53,7 +53,7 @@ export class Dimensions { return this._checkerStroke; } - get sidebarRationModifier() { + get sidebarRatioModifier() { return (this._boardWidth - this.sidebarWidth) / this._boardWidth; } diff --git a/src/index.tsx b/src/index.tsx index d916f88..c62a017 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1 +1,2 @@ export * from "./components/Backgammon"; +export * from "./types"; diff --git a/src/providers/GameStateProvider.tsx b/src/providers/GameStateProvider.tsx index b92dbd1..2772a76 100644 --- a/src/providers/GameStateProvider.tsx +++ b/src/providers/GameStateProvider.tsx @@ -1,11 +1,7 @@ import React, { createContext, useContext } from "react"; -import { BoardStateState } from "../types"; +import { BoardState } from "../types"; -// TODO: validate game state positions: -// - each position value has to be unique -// - opponent cannot be on 0, player cannot be on 25 - -const initialState: BoardStateState = { +const initialState: BoardState = { positions: [ { playerType: "player", position: 24, numberOfCheckers: 2 }, { playerType: "player", position: 13, numberOfCheckers: 5 }, @@ -19,13 +15,13 @@ const initialState: BoardStateState = { ], }; -const GameStateContext = createContext(initialState); +const GameStateContext = createContext(initialState); export const useGameState = () => useContext(GameStateContext); type GameStateProviderProps = { children: React.ReactNode; - gameState?: BoardStateState; + gameState?: BoardState; }; export const GameStateProvider: React.FC = ({ diff --git a/src/type-utils.ts b/src/type-utils.ts new file mode 100644 index 0000000..af4822c --- /dev/null +++ b/src/type-utils.ts @@ -0,0 +1,6 @@ +export type NumberRange< + N extends number, + Acc extends number[] = [], +> = Acc["length"] extends N + ? Acc[number] + : NumberRange; diff --git a/src/types.ts b/src/types.ts index 8cb5bdd..7bac32c 100644 --- a/src/types.ts +++ b/src/types.ts @@ -2,70 +2,34 @@ import { presets } from "./helpers/presets"; export type PlayerType = "player" | "opponent"; -export type DieValue = 1 | 2 | 3 | 4 | 5 | 6; +export type NumberRange< + N extends number, + Acc extends number[] = [], +> = Acc["length"] extends N + ? Acc[number] + : NumberRange; -type Position = { +export type DieValue = Exclude, 0>; + +export type Position = { playerType: PlayerType; - position: - | 0 - | 1 - | 2 - | 3 - | 4 - | 5 - | 6 - | 7 - | 8 - | 9 - | 10 - | 11 - | 12 - | 13 - | 14 - | 15 - | 16 - | 17 - | 18 - | 19 - | 20 - | 21 - | 22 - | 23 - | 24 - | 25 - | "bar"; - numberOfCheckers: - | 1 - | 2 - | 3 - | 4 - | 5 - | 6 - | 7 - | 8 - | 9 - | 10 - | 11 - | 12 - | 13 - | 14 - | 15; + position: NumberRange<26> | "bar"; + numberOfCheckers: Exclude, 0>; }; export type DoublingCube = { - value: 2 | 4 | 8 | 16 | 32; + value: 2 | 4 | 8 | 16 | 32 | 64; owner?: null | PlayerType; }; export type Direction = "clockwise" | "anticlockwise"; -export type BoardStateState = { +export type BoardState = { positions?: Position[]; theme?: Theme; preset?: keyof typeof presets; - options?: Record; doublingCube?: DoublingCube; - dice?: readonly [DieValue, DieValue] | [DieValue] | []; + dice?: readonly [DieValue, DieValue] | readonly [DieValue] | []; direction?: Direction; }; diff --git a/test-harness/editor/Editor.tsx b/test-harness/editor/Editor.tsx index 9f15ba9..77f8667 100644 --- a/test-harness/editor/Editor.tsx +++ b/test-harness/editor/Editor.tsx @@ -3,7 +3,7 @@ import { Backgammon } from "../../src/components/Backgammon"; import { presets } from "../../src/helpers/presets"; import { positionsPresets } from "../tests/presets"; import type { - BoardStateState, + BoardState, DieValue, Direction, DoublingCube, @@ -31,7 +31,7 @@ const EMPTY_POS_STATE: PositionEditorState = { }; function positionsToState( - positions: BoardStateState["positions"], + positions: BoardState["positions"], ): PositionEditorState { const state = structuredClone(EMPTY_POS_STATE); for (const pos of positions ?? []) { @@ -55,10 +55,8 @@ function positionsToState( return state; } -function stateToPositions( - s: PositionEditorState, -): BoardStateState["positions"] { - const result: NonNullable = []; +function stateToPositions(s: PositionEditorState): BoardState["positions"] { + const result: NonNullable = []; s.points.forEach((pt, i) => { if (pt.owner && pt.count > 0) { result.push({ @@ -602,7 +600,7 @@ export function Editor() { const previewRef = useRef(null); - const dice: BoardStateState["dice"] = + const dice: BoardState["dice"] = diceCount === 0 ? [] : diceCount === 1 ? [die1] : [die1, die2]; const positions = stateToPositions(posState); diff --git a/test-harness/tests/presets.ts b/test-harness/tests/presets.ts index a0ee1a5..cf4cea6 100644 --- a/test-harness/tests/presets.ts +++ b/test-harness/tests/presets.ts @@ -1,4 +1,4 @@ -import { BoardStateState, Theme } from "../../src/types"; +import { BoardState, Theme } from "../../src/types"; const randomPositions = () => { const takenByPlayer = new Map(); @@ -51,7 +51,7 @@ const randomPositions = () => { ]; }; -export const positionsPresets: Record = { +export const positionsPresets: Record = { default: [ { position: 1, playerType: "opponent", numberOfCheckers: 2 }, { position: 6, playerType: "player", numberOfCheckers: 5 },