diff --git a/src/components/BoardView.tsx b/src/components/BoardView.tsx
index cd2479c..49ce4cc 100644
--- a/src/components/BoardView.tsx
+++ b/src/components/BoardView.tsx
@@ -1,136 +1,192 @@
-import { Bank, MancalaGame, Pit } from 'mancala.js';
-import * as React from 'react';
-import { FunctionComponent, useState } from 'react';
+import { Bank, MancalaGame, Pit } from "mancala.js";
+import * as React from "react";
+import { FunctionComponent, useState } from "react";
type Theme = {
- background : string,
- boardColor: string
- boardColorWhenPlayerTurn: string
- storeColor: string
- storeColorWhenPlayerTurn: string
- holeColor: string
- ballColor: string
-}
+ background: string;
+ boardColor: string;
+ boardColorWhenPlayerTurn: string;
+ storeColor: string;
+ storeColorWhenPlayerTurn: string;
+ holeColor: string;
+ ballColor: string;
+};
const theme: Theme = {
- background : "#EEEEEE",
- boardColor: "#4D606E",
- boardColorWhenPlayerTurn: "#84b8a6",
- storeColor: "#3FBAC2",
- storeColorWhenPlayerTurn: "#6cab94",
- holeColor: "#D3D4D8",
- ballColor: "#393E46",
-}
+ background: "#EEEEEE",
+ boardColor: "#4D606E",
+ boardColorWhenPlayerTurn: "#84b8a6",
+ storeColor: "#3FBAC2",
+ storeColorWhenPlayerTurn: "#6cab94",
+ holeColor: "#D3D4D8",
+ ballColor: "#393E46",
+};
-const BallView: FunctionComponent<{color : string}> = ({color}) => {
-
- return (
= ({ color }) => {
+ return (
+
-
)
-}
+ borderRadius: "10vw",
+ }}
+ >
+ );
+};
function range(size: number) {
- var ans = [];
- for (let i = 0; i < size; i++) {
- ans.push(i);
- }
- return ans;
+ var ans = [];
+ for (let i = 0; i < size; i++) {
+ ans.push(i);
+ }
+ return ans;
}
-const HoleView: FunctionComponent<{ hole: Pit, color: string, onClick: () => void }> = ({ hole, color, onClick }) => {
- const balls = [...range(hole.stoneCount)].map((i) => )
+const HoleView: FunctionComponent<{
+ hole: Pit;
+ color: string;
+ onClick: () => void;
+}> = ({ hole, color, onClick }) => {
+ const balls = [...range(hole.stoneCount)].map((i) => (
+
+ ));
- return (
- {balls}
-
)
-}
+ return (
+
+ {balls}
+
+ );
+};
-const StoreView: FunctionComponent<
- { store: Bank, color: string, gridColumn: string, gridRow: string }> = ({ store, color, gridColumn, gridRow }) => {
- const balls = [...range(store.stoneCount)].map((i) => )
- return (
- {balls}
-
)
- }
+const StoreView: FunctionComponent<{
+ store: Bank;
+ color: string;
+ gridColumn: string;
+ gridRow: string;
+}> = ({ store, color, gridColumn, gridRow }) => {
+ const balls = [...range(store.stoneCount)].map((i) => (
+
+ ));
+ return (
+
+ {balls}
+
+ );
+};
-const BoardView: FunctionComponent<{ game?: MancalaGame, userKey: string, onHoleSelect: (index: number, hole: Pit) => void }> = ({
- game, userKey, onHoleSelect }) => {
-
- const player1Pits = game?.board.player1Pits.map((hole) => (
- {
- if (game.turnPlayerId === game.player1Id) onHoleSelect(game.board.player1Pits.indexOf(hole), hole)
- }} />
- ))
+const BoardView: FunctionComponent<{
+ game?: MancalaGame;
+ userKey: string;
+ onHoleSelect: (index: number, hole: Pit) => void;
+}> = ({ game, userKey, onHoleSelect }) => {
+ const player1Pits = game?.board.player1Pits.map((hole) => (
+ {
+ if (game.turnPlayerId === game.player1Id)
+ onHoleSelect(game.board.player1Pits.indexOf(hole), hole);
+ }}
+ />
+ ));
- const player2Pits = game!!.board.player2Pits.map((hole) => (
- {
- if (game.turnPlayerId === game.player2Id) onHoleSelect(game.board.player2Pits.indexOf(hole), hole)
- }} />
- ))
+ const player2Pits = game!!.board.player2Pits.map((hole) => (
+ {
+ if (game.turnPlayerId === game.player2Id)
+ onHoleSelect(game.board.player2Pits.indexOf(hole), hole);
+ }}
+ />
+ ));
- const isUserTurn = game.checkIsPlayerTurn(userKey)
+ const isUserTurn = game.checkIsPlayerTurn(userKey);
- const storeColor = isUserTurn ? theme.storeColor : theme.storeColorWhenPlayerTurn;
+ const storeColor = isUserTurn
+ ? theme.storeColor
+ : theme.storeColorWhenPlayerTurn;
- return (
-
- {
- userKey === game.player2Id ? (
- <>
-
-
- {player1Pits.reverse()}
- {player2Pits}
- >
- ) : (
- <>
-
-
- {player2Pits.reverse()}
- {player1Pits}
- >
- )
- }
+ return (
+
+ {userKey === game.player2Id ? (
+ <>
+
+
+ {player1Pits.reverse()}
+ {player2Pits}
+ >
+ ) : (
+ <>
+
+
+ {player2Pits.reverse()}
+ {player1Pits}
+ >
+ )}
+
+ );
+};
-
- )
-}
-
-export default BoardView
\ No newline at end of file
+export default BoardView;