Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            PlayingCards.Deck myDeck = new PlayingCards.Deck();

            PlayingCards.Card topOfDeck = new PlayingCards.Card(PlayingCards.CardSuits.Spade,
            PlayingCards.CardValues.Deuce);

            myDeck.Cards.Add(topOfDeck);

            PlayingCards.Card bottomOfDeck = new PlayingCards.Card(PlayingCards.CardSuits.Heart,
            PlayingCards.CardValues.Queen);

            myDeck.Cards.Add(bottomOfDeck);

            //pictureBox1.Image = myDeck.Cards[1].FaceImage;

            PictureBox pictureBoxCard = new PictureBox();

            pictureBoxCard.Image = myDeck.Cards[0].FaceImage;
            pictureBoxCard.Left = 30;
            pictureBoxCard.Top = 78;
            pictureBoxCard.SizeMode = PictureBoxSizeMode.AutoSize;
            pictureBoxCard.Parent = this;
            pictureBoxCard.Visible = true;

            PictureBox pictureBoxCard2 = new PictureBox();

            pictureBoxCard2.Image = myDeck.Cards[1].FaceImage;
            pictureBoxCard2.Left = 50;
            pictureBoxCard2.Top = 78;
            pictureBoxCard2.SizeMode = PictureBoxSizeMode.AutoSize;
            pictureBoxCard2.Parent = this;
            pictureBoxCard2.Visible = true;
        }
Exemplo n.º 2
0
        public void ReadFirstCard_SuitTest(string result, PlayingCards.Suit cardSuite, PlayingCards.Rank cardRank)
        {
            PlayingCards.Card card = new PlayingCards.Card(cardSuite, cardRank);
            var messages           = Psychic.TranslateCard(card);

            Assert.IsTrue(messages.Contains(result));
        }
Exemplo n.º 3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            foreach (PlayingCards.CardValues a in Enum.GetValues(typeof(PlayingCards.CardValues)))
            {
                PlayingCards.Card clubCard    = new PlayingCards.Card(PlayingCards.CardSuits.Club, a);
                PlayingCards.Card diamondCard = new PlayingCards.Card(PlayingCards.CardSuits.Diamond, a);
                PlayingCards.Card heartCard   = new PlayingCards.Card(PlayingCards.CardSuits.Heart, a);
                PlayingCards.Card spadeCard   = new PlayingCards.Card(PlayingCards.CardSuits.Spade, a);

                myDeck.Cards.Add(clubCard);
                myDeck.Cards.Add(diamondCard);
                myDeck.Cards.Add(heartCard);
                myDeck.Cards.Add(spadeCard);
            }

            int leftRow2  = 0;
            int leftShift = 20;

            for (int i = 0; i <= myDeck.Cards.Count - 1; i++)
            {
                if (i == 26)
                {
                    leftRow2 = 0;
                }
                PictureBox tempPicBox = new PictureBox();
                tempPicBox.SizeMode = PictureBoxSizeMode.StretchImage;
                tempPicBox.Height   = 100;
                tempPicBox.Width    = 80;
                tempPicBox.Parent   = this;
                if (i == 0)
                {
                    tempPicBox.Left = leftShift;
                    tempPicBox.Top  = 50;
                }
                else if (i > 0 && i < 26)
                {
                    tempPicBox.Left = leftShift + (i * 20);
                    tempPicBox.Top  = 50;
                }
                else if (i >= 26)
                {
                    tempPicBox.Left = leftShift + (leftRow2 * 20);
                    tempPicBox.Top  = 180;
                }
                leftRow2++;
            }
        }
Exemplo n.º 4
0
        // This was my originally really long way of adding the cards to the deck... I kept this to show my own work
        // I got help on the loop in CreateDeck2(), which uses significantly less code.
        public void CreateDeck()
        {
            PlayingCards.Deck theDeck = new PlayingCards.Deck();
            DeckOfCards deckOfCards = new DeckOfCards();

            PlayingCards.Card CA = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[0]);
            PlayingCards.Card C2 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[1]);
            PlayingCards.Card C8 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[2]);
            PlayingCards.Card C5 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[3]);
            PlayingCards.Card C4 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[4]);
            PlayingCards.Card CJ = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[5]);
            PlayingCards.Card CK = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[6]);
            PlayingCards.Card C9 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[7]);
            PlayingCards.Card CQ = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[8]);
            PlayingCards.Card C7 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[9]);
            PlayingCards.Card C6 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[10]);
            PlayingCards.Card C10 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[11]);
            PlayingCards.Card C3 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[12]);

            PlayingCards.Card DA = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[0]);
            PlayingCards.Card D2 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[1]);
            PlayingCards.Card D8 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[2]);
            PlayingCards.Card D5 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[3]);
            PlayingCards.Card D4 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[4]);
            PlayingCards.Card DJ = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[5]);
            PlayingCards.Card DK = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[6]);
            PlayingCards.Card D9 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[7]);
            PlayingCards.Card DQ = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[8]);
            PlayingCards.Card D7 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[9]);
            PlayingCards.Card D6 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[10]);
            PlayingCards.Card D10 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[11]);
            PlayingCards.Card D3 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[12]);

            PlayingCards.Card HA = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[0]);
            PlayingCards.Card H2 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[1]);
            PlayingCards.Card H8 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[2]);
            PlayingCards.Card H5 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[3]);
            PlayingCards.Card H4 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[4]);
            PlayingCards.Card HJ = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[5]);
            PlayingCards.Card HK = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[6]);
            PlayingCards.Card H9 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[7]);
            PlayingCards.Card HQ = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[8]);
            PlayingCards.Card H7 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[9]);
            PlayingCards.Card H6 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[10]);
            PlayingCards.Card H10 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[11]);
            PlayingCards.Card H3 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[12]);

            PlayingCards.Card SA = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[0]);
            PlayingCards.Card S2 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[1]);
            PlayingCards.Card S8 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[2]);
            PlayingCards.Card S5 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[3]);
            PlayingCards.Card S4 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[4]);
            PlayingCards.Card SJ = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[5]);
            PlayingCards.Card SK = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[6]);
            PlayingCards.Card S9 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[7]);
            PlayingCards.Card SQ = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[8]);
            PlayingCards.Card S7 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[9]);
            PlayingCards.Card S6 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[10]);
            PlayingCards.Card S10 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[11]);
            PlayingCards.Card S3 = new PlayingCards.Card(deckOfCards.Face[0], deckOfCards.Values[12]);

            theDeck.Cards.Add(CA);
            theDeck.Cards.Add(C2);
            theDeck.Cards.Add(C8);
            theDeck.Cards.Add(C5);
            theDeck.Cards.Add(C4);
            theDeck.Cards.Add(CJ);
            theDeck.Cards.Add(CK);
            theDeck.Cards.Add(C9);
            theDeck.Cards.Add(CQ);
            theDeck.Cards.Add(C7);
            theDeck.Cards.Add(C6);
            theDeck.Cards.Add(C10);
            theDeck.Cards.Add(C3);

            theDeck.Cards.Add(DA);
            theDeck.Cards.Add(D2);
            theDeck.Cards.Add(D8);
            theDeck.Cards.Add(D5);
            theDeck.Cards.Add(D4);
            theDeck.Cards.Add(DJ);
            theDeck.Cards.Add(DK);
            theDeck.Cards.Add(D9);
            theDeck.Cards.Add(DQ);
            theDeck.Cards.Add(D7);
            theDeck.Cards.Add(D6);
            theDeck.Cards.Add(D10);
            theDeck.Cards.Add(D3);

            theDeck.Cards.Add(HA);
            theDeck.Cards.Add(H2);
            theDeck.Cards.Add(H8);
            theDeck.Cards.Add(H5);
            theDeck.Cards.Add(H4);
            theDeck.Cards.Add(HJ);
            theDeck.Cards.Add(HK);
            theDeck.Cards.Add(H9);
            theDeck.Cards.Add(HQ);
            theDeck.Cards.Add(H7);
            theDeck.Cards.Add(H6);
            theDeck.Cards.Add(H10);
            theDeck.Cards.Add(H3);

            theDeck.Cards.Add(SA);
            theDeck.Cards.Add(S2);
            theDeck.Cards.Add(S8);
            theDeck.Cards.Add(S5);
            theDeck.Cards.Add(S4);
            theDeck.Cards.Add(SJ);
            theDeck.Cards.Add(SK);
            theDeck.Cards.Add(S9);
            theDeck.Cards.Add(SQ);
            theDeck.Cards.Add(S7);
            theDeck.Cards.Add(S6);
            theDeck.Cards.Add(S10);
            theDeck.Cards.Add(S3);

            PictureBox[] cardimg = new PictureBox[52];

            for (var i = 0; i < cardimg.Length; i++)
            {
                PictureBox maincardImg = new PictureBox();
                maincardImg.SizeMode = PictureBoxSizeMode.AutoSize;
                maincardImg.Image = theDeck.Cards[i].FaceImage;
                cardimg[i] = maincardImg;
                maincardImg.Parent = this;
                maincardImg.Visible = true;
                maincardImg.Left = 50 + (i * 20);
                maincardImg.Top = 78;
                maincardImg.BringToFront();

            }

            random = new Random();

            for (int i = 0; i < theDeck.Cards.Count; ++i)
            {
                int second = random.Next(52);
                PlayingCards.Card
                    temp = theDeck.Cards[i];
                theDeck.Cards[i] = theDeck.Cards[second];
                theDeck.Cards[second] = temp;
            }
        }