feat: gameboard ui
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import axios from "axios";
|
||||
import { getUser } from "../state/connection.js";
|
||||
import { createGame, joinGame, playCard, getGame } from "../state/game.js";
|
||||
|
||||
const API_URL = process.env.API_URL || "http://localhost:8000/api";
|
||||
|
||||
export const handleGameEvents = (io, socket) => {
|
||||
socket.on("create-game", async (data) => {
|
||||
try {
|
||||
const user = getUser(socket.id);
|
||||
const game = createGame(data.type, user);
|
||||
socket.join(`game_${game.match_id}`);
|
||||
|
||||
} catch (error) {
|
||||
console.error("Error creating game:", error);
|
||||
socket.emit("error", { message: "Failed to create game." });
|
||||
}
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user