Example #1
0
 public static Hand GetUnassignedPlayerHand()
 {
     Hand emptyHand = new Hand();
     emptyHand.Add(Card.GetUnnassignedCard());
     emptyHand.Add(Card.GetUnnassignedCard());
     emptyHand.HighCard = Card.GetUnnassignedCard();
     emptyHand.BestCombination = Combination.Unassigned;
     return emptyHand;
 }
Example #2
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, Newtonsoft.Json.JsonSerializer serializer)
        {
            JObject jsonObject = JObject.Load(reader);

            Hand hand = new Hand();

            Rank rank = (Rank)jsonObject["HighCard"].Value<int>("Rank");
            Suit suit = (Suit)jsonObject["HighCard"].Value<int>("Suit");
            Card highCard = new Card(rank, suit);
            Combination combination = (Combination)jsonObject["BestCombination"].Value<int>();

            hand.BestCombination = combination;
            hand.HighCard = highCard;

            var cards = jsonObject["Cards"].Children();

            foreach (JToken jt in cards)
            {
                Rank r = (Rank)jt["Rank"].Value<int>();
                Suit s = (Suit)jt["Suit"].Value<int>();
                Card c = new Card(r, s);
                hand.Add(c);
            }

            return hand;
        }