Example #1
0
        private PlayerPosition FindWinner(Trick trick, Trump trump)
        {
            var highestTrump             = trick.Deck.Cards.Where(c => c.Suit.Order == trump.Order).OrderByDescending(c => c.Rank.Score);
            var highestInTrickDealerSuit = trick.Deck.Cards.Where(c => c.Suit.Order == trick.TrickDealerSuit.Order).OrderByDescending(c => c.Rank.Score);

            return(highestTrump.Any()
                       ? highestTrump.First().PlayerPosition
                       : highestInTrickDealerSuit.First().PlayerPosition);
        }
Example #2
0
        public Contract(string contract, PlayerPosition declarer)
        {
            Value          = int.Parse(contract[0].ToString());
            PlayerPosition = declarer;
            var suit = Suit.Suits.FirstOrDefault(x => x.ShortName == new string(contract[1], 1));

            if (suit != null)
            {
                Trump = new Trump(suit);
            }
            else
            {
                Trump = Trump.NoTrump;
            }
        }