Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions client/src/board/AvailableMoveDestination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ export const AvailableMoveDestination = styled.div`
width: 100%;
height: 100%;
`;

export const SelectedPieceHighlight = styled.div`
background: #04d09fc1;
width: 100%;
height: 100%;
`;
8 changes: 7 additions & 1 deletion client/src/board/Tile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import styled from "styled-components";
import { useCallback, useContext } from "react";
import { GameClientContext } from "../contexts/GameClientContext";
import { GameEngineContext } from "../contexts/GameEngineContext";
import { AvailableMoveDestination } from "./AvailableMoveDestination";
import { AvailableMoveDestination, SelectedPieceHighlight } from "./AvailableMoveDestination";
import { settings } from "../settings";
import { GameMode } from "../GameMode";

Expand Down Expand Up @@ -48,6 +48,11 @@ export const Tile = ({ piece, tileColor, fileIndex, tileIndex }: TileProps) => {
})
);

const isSelectedPiece =
gameClientContext.selectedPiece &&
gameClientContext.selectedPiece.fileIndex === fileIndex &&
gameClientContext.selectedPiece.tileIndex === tileIndex;

const onClick = useCallback(() => {
if (
gameClientContext.gameMode === GameMode.VS_BOT &&
Expand Down Expand Up @@ -99,6 +104,7 @@ export const Tile = ({ piece, tileColor, fileIndex, tileIndex }: TileProps) => {
></PieceComponent>
)}

{isSelectedPiece && <SelectedPieceHighlight />}
{isAvailableMoveDestinationPosition && <AvailableMoveDestination />}
</TileBackground>
);
Expand Down