Exemplo n.º 1
0
 public Game GetByTableId(int tableId)
 {
     if (tableId == 0)
     {
         throw new ArgumentException();
     }
     else
     {
         Game game = GameConverter.ConvertFromGameModelToGame(gameCtrl.GetByTableId(tableId));
         return(game);
     }
 }
        public Game StartGame(GameTable gameTable)
        {
            Game game = null;

            GameModel gameModel = gameDB.GetByTableId(gameTable.Id);

            if (gameModel != null)
            {
                game = GameConverter.ConvertFromGameModelToGame(gameModel);
            }
            if (game == null)
            {
                foreach (CGUser user in gameTable.Users)
                {
                    userManagement.DeleteHand(user);
                    user.cards.Clear();
                }
                gameTable.Deck = ShuffleDeck(gameTable.Deck);
                DealCards(gameTable.Deck, gameTable.Users);
                game = new Game(gameTable);
                CreateGame(game);
            }
            return(game);
        }