Exemplo n.º 1
0
        private void Shuffle()
        {
            foreach (var card in Controls.OfType <Card>())
            {
                card.Hide();
            }

            do
            {
                handsString = ShuffleRandomHand().SouthHand;
            }while
            (!shuffleRestrictions.Match(handsString));

            var left     = 20 * 13;
            var cardDtos = unOrderedCards.OrderBy(x => x.Suit, new GuiSuitComparer()).ThenBy(c => c.Face, new FaceComparer()).ToArray();

            foreach (var cardDto in cardDtos)
            {
                var card = new Card(cardDto.Face, cardDto.Suit, Back.Crosshatch, false, false)
                {
                    Left   = left,
                    Top    = 80,
                    Parent = this
                };
                card.Show();
                left -= 20;
            }
        }
Exemplo n.º 2
0
        private HandsNorthSouth[] GenerateHandStrings(int batchSize)
        {
            hands = new HandsNorthSouth[batchSize];
            var localshuffleRestrictions = new ShuffleRestrictions();

            for (int i = 0; i < batchSize; ++i)
            {
                int hcp;
                do
                {
                    hands[i] = ShuffleRandomHand();
                    var northHand = hands[i].NorthHand;
                    hcp = northHand.Count(x => x == 'A') * 4 + northHand.Count(x => x == 'K') * 3 + northHand.Count(x => x == 'Q') * 2 + northHand.Count(x => x == 'J');
                }while
                (!localshuffleRestrictions.Match(hands[i].SouthHand) || hcp < 16);
            }

            return(hands);
        }