Exemplo n.º 1
0
 /*
  * Forced add
  */
 public override void manualAdd(Card toAdd)
 {
     toAdd.x = nextX;
     toAdd.y = nextY;
     this.cards.Add(toAdd);
     toAdd.setOwner(this);
     toAdd.BringToFront();
     toAdd.Refresh();
     updateNext();
 }
Exemplo n.º 2
0
 public void resend(Card card, Deck owner)
 {
     card.BringToFront();
     card.Update();
     card.x = owner.nextX;
     card.y = owner.nextY;
     owner.cards.Add(card);
     owner.updateNext();
     card.cardTravelToPoint(card, card.x, card.y);
 }
Exemplo n.º 3
0
        private void handleMouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            //if clicking on the main deck and the main deck is empty
            if (this.getOwner() == this.deckList[(int)eDeck.Deck_Main] && this.getOwner().size() == 0)
            {
                //remaining 24 cards to the main deck
                for (int i = deckList[(int)eDeck.Deck_Drawn].size(); i > 0; i--)
                {
                    Card toDeal = deckList[(int)eDeck.Deck_Drawn].topCard();
                    toDeal.getOwner().removeTop();
                    toDeal.BringToFront();
                    toDeal.mode = cardsdll.mdFaceDown;
                    deckList[(int)eDeck.Deck_Main].manualAdd(toDeal);
                }
            }

            //If clicked on the main deck, and the clicked card is the top card, draw
            if (this.getOwner() == this.deckList[(int)eDeck.Deck_Main] && this == this.getOwner().topCard())
            {
                Deck lastOwner = this.getOwner();
                this.getOwner().removeTop();
                if (!this.deckList[(int)eDeck.Deck_Drawn].addTo(this))
                {
                    this.getOwner().resend(this, lastOwner);
                }
            }
            else
            {
                //If clicking a deck where we can take the top card, and this card isn't upside down
                if (this.getOwner().canTakeTop() && this.mode == cardsdll.mdFaceUp)
                {
                    //if the clicked card is the top card
                    if (this == this.getOwner().topCard())
                    {
                        this.active = true;
                        this.BringToFront();
                        this.x        = e.X + this.x - width / 2;
                        this.y        = e.Y + this.y - height / 2;
                        this.Location = new Point(x, y);
                    }
                    else                     //This card is face up but is not the top card. Pick up a "stack"
                    {
                        this.active = true;
                        Debug.Print("Make a stack!");
                        this.followerList = this.getOwner().getFrom(this);
                        this.hasFollowers = true;
                        //this.BringToFront();
                        for (int i = 0; i < this.followerList.Count(); i++)
                        {
                            followerList[i].BringToFront();
                        }

                        /*
                         * for(int i = 1; i < stack.Count(); i++)
                         * {
                         *      //stack[i].following = i;
                         *      Debug.Print(stack[i].getRank().ToString() + " of " + stack[i].getSuit().ToString());
                         * }
                         */
                    }
                }
                else
                {
                    //if you can take the top card, and you are clicking on the top card, but the top card is face down, turn it face up
                    if (this.getOwner().canTakeTop() && this == this.getOwner().topCard() && this.mode == cardsdll.mdFaceDown)
                    {
                        this.mode = cardsdll.mdFaceUp;
                        this.Refresh();
                    }
                }
            }
        }
Exemplo n.º 4
0
        public Form1()
        {
            Imainview refInterface = this;

            InitializeComponent();

            #region " Initializing the Decks "

            deckList.Add(new Deck_Starter(this.Size.Width / 2 - Card.width / 2, this.Size.Height / 2 - Card.height / 2, deckList, refInterface));
            deckList.Add(new Deck_Main(30, 30, deckList, refInterface));
            deckList.Add(new Deck_Drawn(deckList[1].getX() + cardSpacingX, deckList[1].getY(), deckList, refInterface));
            deckList.Add(new Deck_Ace((int)(deckList[1].getX() + cardSpacingX * 3.6), deckList[1].getY(), deckList, refInterface));
            deckList.Add(new Deck_Ace((int)(deckList[1].getX() + cardSpacingX * 4.6), deckList[1].getY(), deckList, refInterface));
            deckList.Add(new Deck_Ace((int)(deckList[1].getX() + cardSpacingX * 5.6), deckList[1].getY(), deckList, refInterface));
            deckList.Add(new Deck_Ace((int)(deckList[1].getX() + cardSpacingX * 6.6), deckList[1].getY(), deckList, refInterface));
            deckList.Add(new Deck_Column((int)(deckList[1].getX() + cardSpacingX * 0.0), deckList[1].getY() + cardSpacingY, deckList, refInterface));
            deckList.Add(new Deck_Column((int)(deckList[1].getX() + cardSpacingX * 1.1), deckList[1].getY() + cardSpacingY, deckList, refInterface));
            deckList.Add(new Deck_Column((int)(deckList[1].getX() + cardSpacingX * 2.2), deckList[1].getY() + cardSpacingY, deckList, refInterface));
            deckList.Add(new Deck_Column((int)(deckList[1].getX() + cardSpacingX * 3.3), deckList[1].getY() + cardSpacingY, deckList, refInterface));
            deckList.Add(new Deck_Column((int)(deckList[1].getX() + cardSpacingX * 4.4), deckList[1].getY() + cardSpacingY, deckList, refInterface));
            deckList.Add(new Deck_Column((int)(deckList[1].getX() + cardSpacingX * 5.5), deckList[1].getY() + cardSpacingY, deckList, refInterface));
            deckList.Add(new Deck_Column((int)(deckList[1].getX() + cardSpacingX * 6.6), deckList[1].getY() + cardSpacingY, deckList, refInterface));

            //Add each deck's default cards to the form
            for (int i = 0; i < deckList.Count(); i++)
            {
                this.Controls.Add(deckList[i].deckDefaultCard);
            }

            //special case to send the starter deck's default card to the back (transparent)
            deckList[(int)eDeck.Deck_Starter].deckDefaultCard.SendToBack();

            //Add cards to the starter deck and shuffle them
            for (int i = (int)eRank.ACE; i <= (int)eRank.KING; i++)
            {
                for (int j = (int)eSUIT.CLUBS; j <= (int)eSUIT.SPADES; j++)
                {
                    Card newCard = new Card(0, 0, (eRank)i, (eSUIT)j, cardsdll.mdFaceUp, mainBackType, deckList[(int)eDeck.Deck_Starter], deckList, refInterface);
                    deckList[(int)eDeck.Deck_Starter].manualAdd(newCard);
                    this.Controls.Add(newCard);
                }
            }

            deckList[(int)eDeck.Deck_Starter].shuffle();

            deckList[(int)eDeck.Deck_Starter].printList();

            #endregion


            #region " Deal the Cards "

            //28 cards among the 7 columns
            for (int i = 0; i < 7; i++)
            {
                for (int j = 0; j <= i; j++)
                {
                    Card toDeal = deckList[(int)eDeck.Deck_Starter].topCard();
                    toDeal.getOwner().removeTop();
                    deckList[(int)eDeck.Deck_Column1 + i].manualAdd(toDeal);
                    toDeal.BringToFront();
                    if (i != j)
                    {
                        toDeal.mode = cardsdll.mdFaceDown;
                    }
                }
            }

            //remaining 24 cards to the main deck
            for (int i = deckList[(int)eDeck.Deck_Starter].size(); i > 0; i--)
            {
                Card toDeal = deckList[(int)eDeck.Deck_Starter].topCard();
                toDeal.getOwner().removeTop();
                toDeal.BringToFront();
                toDeal.mode = cardsdll.mdFaceDown;
                deckList[(int)eDeck.Deck_Main].manualAdd(toDeal);
            }

            #endregion
        }