private Game TryGetGame(int gameId)
        {
            if (!Game.ListGameIds().Contains(gameId))
            {
                return(null);
            }

            return(Game.GetGameInstance(gameId));
        }
        public bool LeaveTheGame(int gameId, int playerId)
        {
            var games = Game.ShowGames();

            if (!games.ContainsKey(gameId))
            {
                return(false);
            }
            var successed = Game.GetGameInstance(gameId).RemovePlayer(playerId);

            return(successed);
        }
        public State GetState(int gameId)
        {
            var games = Game.ShowGames();

            if (!games.ContainsKey(gameId))
            {
                return(null);
            }

            var gameState = Game.GetGameInstance(gameId).GetGameState();

            return(gameState);
        }
        public bool SendMessage(int gameId, int playerId, string msg)
        {
            var games = Game.ShowGames();

            if (!games.ContainsKey(gameId))
            {
                return(false);
            }

            var successed = Game.GetGameInstance(gameId).AddMessage(playerId, msg);

            return(successed);
        }
        public int Join(int gameId, string name, int position)
        {
            var games = Game.ShowGames();

            if (!games.ContainsKey(gameId))
            {
                return(-1);
            }

            var playerId = Game.GetGameInstance(gameId).AddPlayer(name, position);

            return(playerId);
        }
        public string CheckCards(int gameId, int playerId)
        {
            var games = Game.ShowGames();

            if (!games.ContainsKey(gameId) || Game.GetGameInstance(gameId).PlayerByID.ContainsKey(playerId))
            {
                return(string.Empty);
            }

            var playerHand = Game.GetGameInstance(gameId).PlayerByID[playerId].Hand;
            var stringHand = string.Format("{0} {1}", playerHand.Item1.GetSimpleRepresentation(), playerHand.Item2.GetSimpleRepresentation());

            return(stringHand);
        }
        public string CheckTableCards(int gameId)
        {
            var game = TryGetGame(gameId);

            if (game is null)
            {
                return(null);
            }

            var tableCards = Game.GetGameInstance(gameId).TableCards;
            var res        = String.Empty;

            foreach (var card in tableCards)
            {
                res += String.Format("{0} ", card.GetSimpleRepresentation());
            }
            res = res.Substring(0, res.Length - 1);
            return(res);
        }