cooking with sqlite
This commit is contained in:
@@ -5,7 +5,7 @@ import { GameContext } from "./Game";
|
||||
import { produce } from "solid-js/store";
|
||||
|
||||
export default ((props) => {
|
||||
const { setGameState } = useContext(GameContext)!;
|
||||
const { setGameState, gameState } = useContext(GameContext)!;
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -33,20 +33,16 @@ export default ((props) => {
|
||||
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]!
|
||||
);
|
||||
})
|
||||
)
|
||||
}
|
||||
onClick={() => {
|
||||
const index = gameState()!.hand.indexOf(card);
|
||||
setGameState({
|
||||
deck: [card, ...gameState()!.deck],
|
||||
hand: [
|
||||
...gameState()!.hand.slice(0, index),
|
||||
...gameState()!.hand.slice(index + 1),
|
||||
],
|
||||
});
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</For>
|
||||
|
||||
Reference in New Issue
Block a user