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 } = useContext(GameContext)!; return (
{(card) => ( setGameState( produce((state) => { const index = state.hand.indexOf(card); console.log(index); state.deck.push( state.hand.splice( props.hand.indexOf(card), 1 )[0]! ); }) ) } /> )}
); }) satisfies Component<{ hand: Hand }>;