import { Component, For, useContext } from "solid-js"; import Card from "./Card"; import { Hand } from "../types/cards"; import { GameContext } from "./Game"; import { produce } from "solid-js/store"; export default ((props) => { const { setGameState, gameState } = useContext(GameContext)!; return (
{(card) => ( { const index = gameState()!.hand.indexOf(card); setGameState({ deck: [card, ...gameState()!.deck], hand: [ ...gameState()!.hand.slice(0, index), ...gameState()!.hand.slice(index + 1), ], }); }} /> )}
); }) satisfies Component<{ hand: Hand }>;