protected override void UpdatePlayerCards(GuiPlayerWrapper wrapper, IEnumerable <Card> cards) { // clear existing cards wrapper.Cards.Clear(); // a counter which counts the number of cards to display int index = 0; if (cards != null) { IEnumerator <Card> enumerator = cards.GetEnumerator(); // make sure only the "hole" cards are displayed while (enumerator.MoveNext() && index < privateCardsCount) { Card card = enumerator.Current; wrapper.Cards.Add(new CardWrapper(card)); ++index; } // Get the player hand and update it Hand hand = Client.GetBestHand(cards); if (hand != null) { wrapper.CurrentHand = hand; Board.SelectExclusiveCards(new List <Card>(hand)); } } }
/// <summary> /// Updates the player cards With the given cards /// </summary> /// <param name="wrapper">The player to update</param> /// <param name="cards">The player new cards</param> protected override void UpdatePlayerCards(GuiPlayerWrapper wrapper, IEnumerable <Card> cards) { // clear old cards wrapper.Cards.Clear(); if (cards != null) { // try getting the player hand Hand hand = Client.GetBestHand(cards); if (hand != null) { // found a hand, upadte the player wrapper.CurrentHand = hand; } // create a wrapper and add it to the cards collection. Add the cards in a sorted order. foreach (Card card in cards.OrderBy((c) => c.CardValue)) { CardWrapper addition = new CardWrapper(card); wrapper.Cards.Add(addition); if (hand != null && hand.Contains(card)) { addition.IsSelected = true; } } } }