/// <summary> /// Start the Game with Card Deck Creations and Assignment to the respective players /// </summary> /// <param name="players"></param> public Game(IEnumerable <string> players) { try { // Prepare list of Players with Additional Properties. _listOfPlayers = new ObservableCollection <Player>(); foreach (var player in players) { _listOfPlayers.Add(new Player(player)); } // Task 1: Create a shuffled deck of cards //Returns a shuffled set of cards DeckCreator = new DeckCreator(); var cards = DeckCreator.CreateCards(); var shuffledCards = DeckCreator.Shuffle(cards); var cardDecks = shuffledCards.CreateEqualCardDecks(_listOfPlayers.Count()); var cardDeck = DeckCreator.CreateCards(); var cardDeck1 = DeckCreator.CreateCards(); var test = cardDeck.Equals(cardDeck1); foreach (var player in _listOfPlayers) { if (cardDecks != null) { player.Deal(cardDecks.ToList()[_cardDeckNumber]); } _cardDeckNumber++; } } catch (Exception ex) { throw new Exception(ex.Message); } }
public void Start() { var table = new Dictionary <Card, Player>(); var dealer = new Dealer(); var players = new PlayerListCreator().Players; var deck = new DeckCreator().Deck; dealer.DistributeCards(deck, players); for (int round = 1; round <= _finalRound; round++) { DisplayRound(round); foreach (var player in players) { DisplayName(player); var card = player.PlayCard(); table.Add(card, player); } ShowCurrentWinner(table); RemoveLosers(players); table.Clear(); if (round == _finalRound) { ShowMatchWinner(players); } } Console.ReadKey(); }