import * as React from 'react';
import { FunctionComponent, useState } from 'react';
import { Hole, Store, Game } from '../mancala';
type Theme = {
background : string,
boardColor: string
storeColor: string
holeColor: string
ballColor: string
}
const theme: Theme = {
background : "#EEEEEE",
boardColor: "#4D606E",
storeColor: "#3FBAC2",
holeColor: "#D3D4D8",
ballColor: "#393E46",
}
const BallView: FunctionComponent<{color : string}> = ({color}) => {
return (
)
}
function range(size: number) {
var ans = [];
for (let i = 0; i < size; i++) {
ans.push(i);
}
return ans;
}
const HoleView: FunctionComponent<{ hole: Hole, color: string, onClick: () => void }> = ({ hole, color, onClick }) => {
const balls = [...range(hole.ballCount)].map((i) => )
return (
{balls}
)
}
const StoreView: FunctionComponent<
{ store: Store, color: string, gridColumn: string, gridRow: string }> = ({ store, color, gridColumn, gridRow }) => {
const balls = [...range(store.ballCount)].map((i) => )
return (
{balls}
)
}
const BoardView: FunctionComponent<{ game?: Game, userKey: string, onHoleSelect: (index: number, hole: Hole) => void }> = ({
game, userKey, onHoleSelect }) => {
const player1Holes = game?.board.player1Holes.map((hole) => (
{
if (game.turn == "player1") onHoleSelect(game.board.player1Holes.indexOf(hole), hole)
}} />
))
const player2Holes = game!!.board.player2Holes.map((hole) => (
{
if (game.turn == "player2") onHoleSelect(game.board.player2Holes.indexOf(hole), hole)
}} />
))
return (
{
game.getPlayerNameByKey(userKey) == "player2" ? (
<>
{player1Holes.reverse()}
{player2Holes}
>
) : (
<>
{player2Holes.reverse()}
{player1Holes}
>
)
}
)
}
export default BoardView