elysia is the truth
This commit is contained in:
@@ -1,23 +1,8 @@
|
||||
import {
|
||||
Accessor,
|
||||
createContext,
|
||||
createEffect,
|
||||
createResource,
|
||||
JSX,
|
||||
Show,
|
||||
Suspense,
|
||||
} from "solid-js";
|
||||
import Card from "./Card";
|
||||
import { Accessor, createContext, createResource, Show } from "solid-js";
|
||||
import { GameState } from "../../../shared/types/cards";
|
||||
import api from "../api";
|
||||
import Hand from "./Hand";
|
||||
import Pile from "./Pile";
|
||||
import {
|
||||
GameState,
|
||||
newDeck,
|
||||
shuffle,
|
||||
Hand as THand,
|
||||
} from "../../../shared/types/cards";
|
||||
import { createStore, produce, SetStoreFunction, Store } from "solid-js/store";
|
||||
import api from "../api";
|
||||
|
||||
export const GameContext = createContext<{
|
||||
gameState: Accessor<GameState | undefined>;
|
||||
@@ -25,17 +10,18 @@ export const GameContext = createContext<{
|
||||
}>();
|
||||
|
||||
export default (props: { instanceId: number }) => {
|
||||
const [gameState, { refetch }] = createResource<GameState>(() =>
|
||||
api.gameState[":gameId"]
|
||||
.$get({ param: { gameId: props.instanceId.toString() } })
|
||||
.then((res) => res.json())
|
||||
const [gameState, { refetch }] = createResource(() =>
|
||||
api
|
||||
.gameState({ gameId: props.instanceId.toString() })
|
||||
.get()
|
||||
.then((res) => res.data as GameState)
|
||||
);
|
||||
|
||||
const setGameState = (state: GameState) =>
|
||||
api.gameState[":gameId"]
|
||||
.$put({
|
||||
param: { gameId: props.instanceId.toString() },
|
||||
json: state,
|
||||
api
|
||||
.gameState({ gameId: props.instanceId.toString() })
|
||||
.put({
|
||||
gameState: state,
|
||||
})
|
||||
.then(refetch);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user