//Update holded Card
        private void holdcard(ACard cardin)
        {
            hold12.Image = hold11.Image;
            hold11.Image = hold10.Image;
            hold10.Image = hold9.Image;
            hold9.Image  = hold8.Image;
            hold8.Image  = hold7.Image;
            hold7.Image  = hold6.Image;
            hold6.Image  = hold5.Image;
            hold5.Image  = hold4.Image;
            hold4.Image  = hold3.Image;
            hold3.Image  = hold2.Image;
            hold2.Image  = hold1.Image;
            hold1.Image  = Image.FromFile(getAddress(cardin.getRank(), cardin.getSuit()));

            chold12.Image = chold11.Image;
            chold11.Image = chold10.Image;
            chold10.Image = chold9.Image;
            chold9.Image  = chold8.Image;
            chold8.Image  = chold7.Image;
            chold7.Image  = chold6.Image;
            chold6.Image  = chold5.Image;
            chold5.Image  = chold4.Image;
            chold4.Image  = chold3.Image;
            chold3.Image  = chold2.Image;
            chold2.Image  = chold1.Image;
            chold1.Image  = Image.FromFile("back.jpg");
        }
        //Draw Top card from deck
        public ACard getCard()
        {
            ACard tmp = deck[getNumdeck() - 1];

            deck.RemoveAt(getNumdeck() - 1);
            return(tmp);
        }
 private void showPileB(ACard incard)
 {
     lastB3.Image = lastB2.Image;
     lastB2.Image = lastB1.Image;
     lastB1.Image = pileB.Image;
     pileB.Image  = Image.FromFile(getAddress(incard.getRank(), incard.getSuit()));
     tempb        = incard;
 }
 //Show Last Card in pile
 private void showPileA(ACard incard)
 {
     lastA3.Image = lastA2.Image;
     lastA2.Image = lastA1.Image;
     lastA1.Image = pileA.Image;
     pileA.Image  = Image.FromFile(getAddress(incard.getRank(), incard.getSuit()));
     tempa        = incard;
 }
        //Draw Function
        public void Draw()
        {
            clearcard();
            checkFirstCompare   = false;
            checkManyHitCompare = false;
            checkManyHitDraw    = true;

            if (!checkFirstPileA && tempa != pilea) //If last card in pileA called 'pilea' not show as 'tempa', update it.
            {
                if (a.getRank() == b.getRank())
                {
                    showPileA(currB);
                    showPileA(currA);
                }
                showPileA(b);
                showPileA(a);
                if (Player1.getNumpile() > 4)
                {
                    numpileA.Text = "+" + Convert.ToString(Player1.getNumpile() - 4);
                }
            }
            if (!checkFirstPileB && tempb != pileb)
            {
                if (a.getRank() == b.getRank())
                {
                    showPileB(currA);
                    showPileB(currB);
                }
                showPileB(a);
                showPileB(b);
                if (Player2.getNumpile() > 4)
                {
                    numpileB.Text = "+" + Convert.ToString(Player2.getNumpile() - 4);
                }
            }

            a           = Player1.getCard();
            b           = Player2.getCard();
            showA.Image = Image.FromFile(getAddress(a.getRank(), a.getSuit()));
            showB.Image = Image.FromFile("back.jpg");
        }
Exemple #6
0
        //Compare Function
        public void Compare()
        {
            checkManyHitCompare = true;
            checkManyHitDraw = false;
            showB.Image = Image.FromFile(getAddress(b.getRank(), b.getSuit()));
            int rankA = a.getRank();
            int rankB = b.getRank();

            if (rankA > rankB)
            {
                Player2.addPile(a);
                Player2.addPile(b);
                pileb = b;
                checkFirstPileB = false;
            }
            else if (rankB > rankA)
            {
                Player1.addPile(b);
                Player1.addPile(a);
                pilea = a;
                checkFirstPileA = false;
            }
            else if (!(Player1.getNumdeck() - a.getRank() <= 0))
            {
                MessageBox.Show("Rank is Equal at Rank " + Convert.ToString(a.getRank()));

                holda.Image = Image.FromFile(getAddress(a.getRank(), a.getSuit()));
                holdb.Image = Image.FromFile(getAddress(b.getRank(), b.getSuit()));

                List<ACard> tmp1 = new List<ACard>();
                List<ACard> tmp2 = new List<ACard>();

                int num = a.getRank(), i;

                for (i = 0; i < num; i++)
                {
                    ACard tempcard = Player1.getCard();
                    if (i < num - 1) holdcard(tempcard);
                    tmp1.Add(tempcard);
                    tmp2.Add(Player2.getCard());
                }
                showA.Image = Image.FromFile(getAddress(tmp1[i - 1].getRank(), tmp1[i - 1].getSuit()));
                showB.Image = Image.FromFile(getAddress(tmp2[i - 1].getRank(), tmp2[i - 1].getSuit()));
                if (tmp1[i - 1].getRank() > tmp2[i - 1].getRank())
                {
                    MessageBox.Show("Player2 Win " + (num * 2 + 2) + " Cards!!!");
                    for (i = 0; i < num; i++)
                    {
                        Player2.addPile(tmp1[i]);
                        Player2.addPile(tmp2[i]);
                        pileb = b;
                        checkFirstPileB = false;
                    }
                    currA = tmp1[i - 1];
                    currB = tmp2[i - 1];
                    Player2.addPile(a);
                    Player2.addPile(b);
                }
                else if (tmp1[i - 1].getRank() < tmp2[i - 1].getRank())
                {
                    MessageBox.Show("Player1 Win " + (num * 2 + 2) + " Cards!!!");
                    for (i = 0; i < num; i++)
                    {
                        Player1.addPile(tmp2[i]);
                        Player1.addPile(tmp1[i]);
                        pilea = a;
                        checkFirstPileA = false;
                    }
                    currA = tmp1[i - 1];
                    currB = tmp2[i - 1];
                    Player1.addPile(b);
                    Player1.addPile(a);
                }
                else
                {
                    MessageBox.Show("Equal again!!! Return card to your deck and shuffle");
                    for (i = 0; i < num; i++)
                    {
                        Player1.addDeck(tmp1[i]);
                        Player2.addDeck(tmp2[i]);
                        showA.Image = null;
                        showB.Image = null;
                    }
                    Player1.inDeck(ShuffleList(Player1.getDeck()));
                    Player2.inDeck(ShuffleList(Player2.getDeck()));
                }
            }
            else
            {
                MessageBox.Show("Rank is Equal at Rank " + Convert.ToString(a.getRank()) + "you nust to draw" + Convert.ToString(a.getRank()) + "cards from your deck but we know that it will not enough, So...");
                endprog();
            }
        }
Exemple #7
0
 private void showPileB(ACard incard)
 {
     lastB3.Image = lastB2.Image;
     lastB2.Image = lastB1.Image;
     lastB1.Image = pileB.Image;
     pileB.Image = Image.FromFile(getAddress(incard.getRank(), incard.getSuit()));
     tempb = incard;
 }
Exemple #8
0
 //Show Last Card in pile
 private void showPileA(ACard incard)
 {
     lastA3.Image = lastA2.Image;
     lastA2.Image = lastA1.Image;
     lastA1.Image = pileA.Image;
     pileA.Image = Image.FromFile(getAddress(incard.getRank(), incard.getSuit()));
     tempa = incard;
 }
Exemple #9
0
        //Update holded Card
        private void holdcard(ACard cardin)
        {
            hold12.Image = hold11.Image;
            hold11.Image = hold10.Image;
            hold10.Image = hold9.Image;
            hold9.Image = hold8.Image;
            hold8.Image = hold7.Image;
            hold7.Image = hold6.Image;
            hold6.Image = hold5.Image;
            hold5.Image = hold4.Image;
            hold4.Image = hold3.Image;
            hold3.Image = hold2.Image;
            hold2.Image = hold1.Image;
            hold1.Image = Image.FromFile(getAddress(cardin.getRank(), cardin.getSuit()));

            chold12.Image = chold11.Image;
            chold11.Image = chold10.Image;
            chold10.Image = chold9.Image;
            chold9.Image = chold8.Image;
            chold8.Image = chold7.Image;
            chold7.Image = chold6.Image;
            chold6.Image = chold5.Image;
            chold5.Image = chold4.Image;
            chold4.Image = chold3.Image;
            chold3.Image = chold2.Image;
            chold2.Image = chold1.Image;
            chold1.Image = Image.FromFile("back.jpg");
        }
Exemple #10
0
        //Draw Function
        public void Draw()
        {
            clearcard();
            checkFirstCompare = false;
            checkManyHitCompare = false;
            checkManyHitDraw = true;

            if (!checkFirstPileA && tempa != pilea) //If last card in pileA called 'pilea' not show as 'tempa', update it.
            {
                if (a.getRank() == b.getRank())
                {
                    showPileA(currB);
                    showPileA(currA);
                }
                showPileA(b);
                showPileA(a);
                if (Player1.getNumpile() > 4) numpileA.Text = "+" + Convert.ToString(Player1.getNumpile() - 4);
            }
            if (!checkFirstPileB && tempb != pileb)
            {
                if (a.getRank() == b.getRank())
                {
                    showPileB(currA);
                    showPileB(currB);
                }
                showPileB(a);
                showPileB(b);
                if (Player2.getNumpile() > 4) numpileB.Text = "+" + Convert.ToString(Player2.getNumpile() - 4);
            }

            a = Player1.getCard();
            b = Player2.getCard();
            showA.Image = Image.FromFile(getAddress(a.getRank(), a.getSuit()));
            showB.Image = Image.FromFile("back.jpg");
        }
        //Compare Function
        public void Compare()
        {
            checkManyHitCompare = true;
            checkManyHitDraw    = false;
            showB.Image         = Image.FromFile(getAddress(b.getRank(), b.getSuit()));
            int rankA = a.getRank();
            int rankB = b.getRank();

            if (rankA > rankB)
            {
                Player2.addPile(a);
                Player2.addPile(b);
                pileb           = b;
                checkFirstPileB = false;
            }
            else if (rankB > rankA)
            {
                Player1.addPile(b);
                Player1.addPile(a);
                pilea           = a;
                checkFirstPileA = false;
            }
            else if (!(Player1.getNumdeck() - a.getRank() <= 0))
            {
                MessageBox.Show("Rank is Equal at Rank " + Convert.ToString(a.getRank()));

                holda.Image = Image.FromFile(getAddress(a.getRank(), a.getSuit()));
                holdb.Image = Image.FromFile(getAddress(b.getRank(), b.getSuit()));

                List <ACard> tmp1 = new List <ACard>();
                List <ACard> tmp2 = new List <ACard>();

                int num = a.getRank(), i;

                for (i = 0; i < num; i++)
                {
                    ACard tempcard = Player1.getCard();
                    if (i < num - 1)
                    {
                        holdcard(tempcard);
                    }
                    tmp1.Add(tempcard);
                    tmp2.Add(Player2.getCard());
                }
                showA.Image = Image.FromFile(getAddress(tmp1[i - 1].getRank(), tmp1[i - 1].getSuit()));
                showB.Image = Image.FromFile(getAddress(tmp2[i - 1].getRank(), tmp2[i - 1].getSuit()));
                if (tmp1[i - 1].getRank() > tmp2[i - 1].getRank())
                {
                    MessageBox.Show("Player2 Win " + (num * 2 + 2) + " Cards!!!");
                    for (i = 0; i < num; i++)
                    {
                        Player2.addPile(tmp1[i]);
                        Player2.addPile(tmp2[i]);
                        pileb           = b;
                        checkFirstPileB = false;
                    }
                    currA = tmp1[i - 1];
                    currB = tmp2[i - 1];
                    Player2.addPile(a);
                    Player2.addPile(b);
                }
                else if (tmp1[i - 1].getRank() < tmp2[i - 1].getRank())
                {
                    MessageBox.Show("Player1 Win " + (num * 2 + 2) + " Cards!!!");
                    for (i = 0; i < num; i++)
                    {
                        Player1.addPile(tmp2[i]);
                        Player1.addPile(tmp1[i]);
                        pilea           = a;
                        checkFirstPileA = false;
                    }
                    currA = tmp1[i - 1];
                    currB = tmp2[i - 1];
                    Player1.addPile(b);
                    Player1.addPile(a);
                }
                else
                {
                    MessageBox.Show("Equal again!!! Return card to your deck and shuffle");
                    for (i = 0; i < num; i++)
                    {
                        Player1.addDeck(tmp1[i]);
                        Player2.addDeck(tmp2[i]);
                        showA.Image = null;
                        showB.Image = null;
                    }
                    Player1.inDeck(ShuffleList(Player1.getDeck()));
                    Player2.inDeck(ShuffleList(Player2.getDeck()));
                }
            }
            else
            {
                MessageBox.Show("Rank is Equal at Rank " + Convert.ToString(a.getRank()) + " ,you need to draw " + Convert.ToString(a.getRank()) + " cards from your deck but we know that your deck is not have enough cards to draw, So...");
                endprog();
            }
        }
 //Put card at Top of deck
 public void addDeck(ACard cardin)
 {
     deck.Add(cardin);
 }
 //Put card at Top of pile
 public void addPile(ACard cardin)
 {
     pile.Add(cardin);
 }
Exemple #14
0
 //Put card at Top of pile
 public void addPile(ACard cardin)
 {
     pile.Add(cardin);
 }
Exemple #15
0
 //Put card at Top of deck
 public void addDeck(ACard cardin)
 {
     deck.Add(cardin);
 }