import BiscaGame from "../classes/BiscaGame.js";

const activeGames = new Map();

const createGame = (id, type, player1, player2) => {
  const game = new BiscaGame(id, type, player1, player2);

  game.init();

  activeGames.set(id, game);

  console.log(`[Game State] Game created: ${id} (Type: ${type})`);
  return game;
};

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 { createGame, getGame, removeGame };
