
from .Game import Game
from ..models import GameModel

class GameManager():
    
    def __init__(self) -> None:
        self._game_list: list[Game] = []
    
    def get(self, game_id: int) -> Game:
        
        if (not GameModel.objects.filter(pk = game_id, finished = False).exists()):
            return None
        
        for game in self._game_list:
            game: Game
            if (game.game_id == game_id):
                return game
        
        game: Game = Game(game_id)
        
        self._game_list.append(game)
        
        return game