Skip to content

Commit

Permalink
add to hand
Browse files Browse the repository at this point in the history
  • Loading branch information
JollyGrin committed Oct 20, 2024
1 parent 3a939cb commit 842c5f4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/components/organisms/GameBoard/Footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ import { CountersTray } from "./Counters";
/**
* HAND - Drag and Drop tray of all the cards in your hand
* */
export const GameFooter = (props: GameStateActions & PlayerDataProps) => {
export const GameFooter = ({
setHoverCard,
...props
}: GameStateActions &
PlayerDataProps & {
setHoverCard(slug: string): void;
}) => {
const gridIndex = GRIDS.HAND;
const cardsInHand = props.gridItems[gridIndex] ?? [];

Expand Down Expand Up @@ -97,6 +103,7 @@ export const GameFooter = (props: GameStateActions & PlayerDataProps) => {
gridIndex={gridIndex}
cardIndex={index}
gameStateActions={props}
setHoverCard={setHoverCard}
/>
))}
</HStack>
Expand All @@ -112,12 +119,21 @@ const HandCard = ({
gridIndex,
cardIndex: index,
gameStateActions,
...props
}: {
card: GameCard;
gridIndex: number;
cardIndex: number;
gameStateActions: GameStateActions;
setHoverCard(slug?: string): void;
}) => {
function over() {
if (props.setHoverCard) props.setHoverCard(card.img);
}
function out() {
if (props.setHoverCard) props.setHoverCard();
}

const [preview, setPreview] = useState(false);
const deckType = card.type === "site" ? "atlas" : "deck";

Expand All @@ -139,6 +155,8 @@ const HandCard = ({
e.preventDefault();
setPreview(true);
}}
onMouseOver={over}
onMouseOut={out}
style={{
position: "relative",
width: "100%",
Expand Down
1 change: 1 addition & 0 deletions src/components/organisms/GameBoard/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const GameLayout = (
PlayerDataProps & {
isReversed?: boolean;
activeCardSlug?: string;
setHoverCard(slug: string): void;
children: ReactNode;
},
) => {
Expand Down
1 change: 1 addition & 0 deletions src/components/organisms/GameBoard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const GameBoard = ({
setGridItems={setGridItems}
isReversed={isReversed}
activeCardSlug={hoverCard}
setHoverCard={setHoverCard}
{...playerDataProps}
>
{(isReversed
Expand Down

0 comments on commit 842c5f4

Please sign in to comment.