Пример #1
0
        /// <summary>
        /// Not implement yet!
        /// Remove a full block of card in the correct order from the table
        /// </summary>
        /// <param name="stack"></param>
        /// <param name="table"></param>
        private static void CleanBlock(Card[] stack, int table)
        {
            //tempoary table variable, inplay variable and while loop control initiziation
            CardPile tempTable  = GetTable(table);
            int      tempInPlay = GetTableCardsInPlay(table);
            bool     allRemoved = false;

            while (!allRemoved)
            {
                //loop each card in the stack and remove it from the table
                for (int i = 0; i < stack.Length; i++)
                {
                    for (int j = 0; j < GetTableCount(table); j++)
                    {
                        if (tempTable.GetCard(j) == stack[i])
                        {
                            tempTable.RemoveCard(j);
                            tempInPlay--;
                            break;
                        }
                    }
                }
                //check if all the cards have been removed from the table
                int count = 0;
                for (int i = 0; i < tempTable.GetCount(); i++)
                {
                    for (int j = 0; j < stack.Length; j++)
                    {
                        if (tempTable.GetCard(i) == stack[j])
                        {
                            count++;
                        }
                    }
                }
                if (count > 0)
                {
                    //reset the temporary table and repeat process
                    tempTable  = GetTable(table);
                    tempInPlay = GetTableCardsInPlay(table);
                }
                else
                {
                    //else kill loop
                    allRemoved = true;
                }
            }
            SetNewTable(tempTable, table, tempInPlay);
        } //end CleanBlock
Пример #2
0
        //Generates an entire tables worth of card graphics
        private PictureBox[] UpdateTableau(CardPile table, int inPlay, int tableNum)
        {
            PictureBox cardImg;

            PictureBox[] tableauImg = new PictureBox[table.GetCount()];
            Card         card;

            //loops through each card
            for (int i = 0; i < table.GetCount(); i++)
            {
                cardImg          = new PictureBox();
                cardImg.SizeMode = PictureBoxSizeMode.AutoSize;
                cardImg.Dock     = DockStyle.Fill;
                card             = table.GetCard(i);
                //if Face up card
                if (i >= (table.GetCount() - inPlay))
                {
                    cardImg.Image        = Images.GetCardImage(card);
                    tableauImg[i]        = cardImg;
                    tableauImg[i].Click += new EventHandler(TableCard_Click);
                    tableauImg[i].Tag    = card;
                    //else face down card
                }
                else
                {
                    tableauImg[i]        = cardImg;
                    tableauImg[i].Click += new EventHandler(CardFlip_Click);
                    tableauImg[i].Tag    = tableNum;
                    cardImg.Image        = Images.GetBackOfCardImage();
                }
            }
            return(tableauImg);
        }
Пример #3
0
        } // end MoveBlock

        /// <summary>
        /// Get the card form a tableau
        /// </summary>
        /// <param name="played">the location of the card need to get</param>
        /// <param name="table"> the table where the card located</param>
        /// <param name="tableNum">Table number of the card</param>
        /// <returns></returns>
        private static Card[] GetCards(Card played, CardPile table, int tableNum)
        {
            //initialize stack to hold the grabed cards and counter varible max
            Card[] stack = new Card[1];
            int    max   = 0;

            for (int i = 0; i < GetTableCount(tableNum); i++)
            {
                if (table.GetCard((GetTableCount(tableNum) - 1) - i) == played)
                {
                    max   = i;
                    stack = new Card[max + 1];
                    break;
                }
            }
            //Grab them from the last card up to the clicked card for redisplaying purposes
            for (int j = max; j > -1; j--)
            {
                stack[max - j] = table.GetCard((table.GetCount() - 1) - j);
            }
            return(stack);
        }