can put them back

This commit is contained in:
2025-08-03 22:16:19 -04:00
parent 5f05eb4adf
commit 0dc0a9ce62
7 changed files with 94 additions and 30 deletions

View File

@@ -1,11 +1,19 @@
import { Component, For } from "solid-js";
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 (
<div
class="hand"
style={{
"min-width": "100px",
width: "fit-content",
"max-width": "80%",
border: "2px dashed white",
"border-radius": "12px",
margin: "10px",
@@ -18,7 +26,30 @@ export default ((props) => {
gap: "5px",
}}
>
<For each={props.hand}>{(card) => <Card card={card} />}</For>
<For each={props.hand}>
{(card) => (
<Card
card={card}
style={{
cursor: "pointer",
}}
onClick={() =>
setGameState(
produce((state) => {
const index = state.hand.indexOf(card);
console.log(index);
state.deck.push(
state.hand.splice(
props.hand.indexOf(card),
1
)[0]!
);
})
)
}
/>
)}
</For>
</div>
);
}) satisfies Component<{ hand: Hand }>;