|
@@ -1,4 +1,4 @@
|
|
|
-import { selector } from "./gameStore";
|
|
|
+import { dispatch } from "./gameStore";
|
|
|
|
|
|
const API_BASE = "https://kirkleon.ddns.net/terrassumptions/api";
|
|
|
|
|
@@ -15,7 +15,7 @@ export const getStatus = async () => {
|
|
|
}
|
|
|
|
|
|
export const createGame = async (timer) => {
|
|
|
- const name = selector.playerName();
|
|
|
+ const name = dispatch.getPlayerName();
|
|
|
const res = await fetch(`${API_BASE}/game`, {
|
|
|
method: "PUT",
|
|
|
headers: {
|
|
@@ -32,7 +32,7 @@ export const createGame = async (timer) => {
|
|
|
}
|
|
|
|
|
|
export const gameInfo = async () => {
|
|
|
- const gameId = selector.gameId();
|
|
|
+ const gameId = dispatch.getGameId();
|
|
|
const res = await fetch(`${API_BASE}/game/${gameId}`);
|
|
|
if (!res.ok) {
|
|
|
throw Error(res.statusText);
|
|
@@ -41,8 +41,8 @@ export const gameInfo = async () => {
|
|
|
}
|
|
|
|
|
|
export const joinGame = async () => {
|
|
|
- const gameId = selector.gameId();
|
|
|
- const name = selector.playerName();
|
|
|
+ const gameId = dispatch.getGameId();
|
|
|
+ const name = dispatch.getPlayerName();
|
|
|
const res = await fetch(`${API_BASE}/game/${gameId}/join`, {
|
|
|
method: "POST",
|
|
|
headers: {
|
|
@@ -55,8 +55,8 @@ export const joinGame = async () => {
|
|
|
}
|
|
|
|
|
|
export const getCurrentRound = async () => {
|
|
|
- const gameId = selector.gameId();
|
|
|
- const name = selector.playerName();
|
|
|
+ const gameId = dispatch.getGameId();
|
|
|
+ const name = dispatch.getPlayerName();
|
|
|
const res = await fetch(`${API_BASE}/game/${gameId}/current`, {
|
|
|
headers: {
|
|
|
"Authorization": `Name ${name}`
|
|
@@ -69,8 +69,8 @@ export const getCurrentRound = async () => {
|
|
|
}
|
|
|
|
|
|
export const sendGuess = async (round, point) => {
|
|
|
- const gameId = selector.gameId();
|
|
|
- const name = selector.playerName();
|
|
|
+ const gameId = dispatch.getGameId();
|
|
|
+ const name = dispatch.getPlayerName();
|
|
|
const res = await fetch(`${API_BASE}/game/${gameId}/guesses/${round}`, {
|
|
|
method: "POST",
|
|
|
headers: {
|