Final touches

This commit is contained in:
2026-01-02 22:11:47 +00:00
parent 25d21f7cf8
commit a804f41956
3 changed files with 46 additions and 42 deletions
+22 -29
View File
@@ -2,40 +2,33 @@ import BiscaGame from "../classes/BiscaGame.js";
const activeGames = new Map();
const createGame = (id, type, player1, player2) => {
const existingGame = activeGames.get(id);
if (existingGame) {
console.log(
`[Game State] Game ${id} already exists, returning existing instance`,
);
return existingGame;
}
const game = new BiscaGame(id, type, player1, player2);
export const createGame = (id, type, player1, player2) => {
const existingGame = activeGames.get(id);
if (existingGame) {
console.log(
`[Game State] Game ${id} already exists, returning existing instance`
);
return existingGame;
}
const game = new BiscaGame(id, type, player1, player2);
game.init();
game.init();
activeGames.set(id, game);
activeGames.set(id, game);
console.log(`[Game State] Game created: ${id} (Type: ${type})`);
return game;
console.log(`[Game State] Game created: ${id} (Type: ${type})`);
return game;
};
const getGame = (id) => {
return activeGames.get(id);
export const getGame = (id) => {
return activeGames.get(id);
};
const removeGame = (id) => {
const game = activeGames.get(id);
if (game) {
game.stopTimer();
activeGames.delete(id);
console.log(`[Game State] Game removed: ${id}`);
}
export const removeGame = (id) => {
const game = activeGames.get(id);
if (game) {
game.stopTimer();
activeGames.delete(id);
console.log(`[Game State] Game removed: ${id}`);
}
};
module.exports = {
createGame,
getGame,
removeGame,
};