package com.lona.tictactoe.server;

import java.util.concurrent.ConcurrentHashMap;
import java.util.UUID;

public class GameManager {
    private static final ConcurrentHashMap<String, GameInstance> games = new ConcurrentHashMap<>();

    public static String createGame(ClientHandler creator) {
        String code = UUID.randomUUID().toString().substring(0, 6).toUpperCase();
        GameInstance game = new GameInstance(code, creator);
        games.put(code, game);
        return code;
    }

    public static GameInstance getGame(String code) {
        return games.get(code);
    }

    public static void removeGame(String code) {
        games.remove(code);
    }
}
