Ejemplo n.º 1
0
        // constructor
        public TDeck()
        {
            deckArray = new TCard[DECKSIZE]; // initialise a new deckArray
            rand      = new Random();        // initialise a new Random generator

            // populate deckArray, select the suit, then select the rank
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < HANDSIZE; j++)
                {
                    TCard card = new TCard(i, j); // suit, rank
                    deckArray[(i * HANDSIZE) + j] = card;
                } // end j for loop
            } // end i for loop
        }     // end constructor
Ejemplo n.º 2
0
        Random rand; // random generator

        #endregion Fields

        #region Constructors

        // constructor
        public TDeck()
        {
            deckArray = new TCard[DECKSIZE]; // initialise a new deckArray
            rand = new Random();             // initialise a new Random generator

            // populate deckArray, select the suit, then select the rank
            for (int i = 0; i < 4; i++)
            {
              for (int j = 0; j < HANDSIZE; j++)
              {
            TCard card = new TCard(i, j);  // suit, rank
            deckArray[(i * HANDSIZE) + j] = card;
              } // end j for loop
            } // end i for loop
        }
Ejemplo n.º 3
0
        public void shuffle()
        {
            Random RanNum = new Random();
            int    SwapIndex;

            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < Cards.Length; j++)
                {
                    SwapIndex = RanNum.Next(Cards.Length);
                    TCard Temp = Cards[i];
                    Cards[i]         = Cards[SwapIndex];
                    Cards[SwapIndex] = Temp;
                }
            }
        }
Ejemplo n.º 4
0
        public TDeck()
        {
            Cards = new TCard[TOTALCARDS];
            int Suit      = -1;
            int CardValue = 0;

            for (int i = 0; i < Cards.Length; i++)
            {
                if (i % CARDSPERSUIT == 0)
                {
                    Suit++;
                }
                CardValue = i % CARDSPERSUIT;
                Cards[i]  = new TCard(Suit, CardValue);
            }
        }
Ejemplo n.º 5
0
        public void Deal(THand[] Hands)
        {
            int HandNum = 0;
            int CardNum = 0;

            TCard[] TempHand = new TCard[CARDSPERSUIT];

            for (int i = 0; i < Cards.Length; i++)
            {
                Hands[HandNum].cards[CardNum] = Cards[i];
                CardNum++;
                if ((i + 1) % CARDSPERSUIT == 0)
                {
                    CardNum = 0;
                    HandNum++;
                }
            }
        }
Ejemplo n.º 6
0
        /*
          * pre - takes in an integer
          * post - returns a THand
          */
        // create a handArray from the TCards in the deckArray
        public THand dealHand(int mySeat)
        {
            seat s = seat.NORTH; // default needed for some reason
            THand hand;          // THand handler??
            TCard[] handArray = new TCard[HANDSIZE];

            // determine the seat/position. North, South ,East or West
            switch (mySeat)
            {
              case 0:
            s = seat.NORTH;
            break;

              case 1:
            s = seat.EAST;
            break;

              case 2:
            s = seat.SOUTH;
            break;

              case 3:
                //AJD Changed to WEST from South
            s = seat.WEST;
            break;
            }

            //int blah = (int)seat.North;  // just playing

            // create a new THand
            for (int i = 0; i < HANDSIZE; i++)
            {
              handArray[i] = deckArray[i + (mySeat * HANDSIZE)];
            }
            hand = new THand(handArray, s);
            return hand;
        }
Ejemplo n.º 7
0
        /*
         * pre - takes in an integer
         * post - returns a THand
         */
        // create a handArray from the TCards in the deckArray
        public THand dealHand(int mySeat)
        {
            seat  s = seat.NORTH; // default needed for some reason
            THand hand;           // THand handler??

            TCard[] handArray = new TCard[HANDSIZE];

            // determine the seat/position. North, South ,East or West
            switch (mySeat)
            {
            case 0:
                s = seat.NORTH;
                break;

            case 1:
                s = seat.EAST;
                break;

            case 2:
                s = seat.SOUTH;
                break;

            case 3:
                s = seat.SOUTH;
                break;
            }

            //int blah = (int)seat.North;  // just playing

            // create a new THand
            for (int i = 0; i < HANDSIZE; i++)
            {
                handArray[i] = deckArray[i + (mySeat * HANDSIZE)];
            }
            hand = new THand(handArray, s);
            return(hand);
        } // end dealhand method
Ejemplo n.º 8
0
 // constructor
 public THand(TCard[] startHandArray, seat startSeat)
 {
     this.handArray = startHandArray;
     this.mySeat = startSeat;
 }
Ejemplo n.º 9
0
        public void Deal(THand[] Hands)
        {
            int HandNum = 0;
            int CardNum = 0;
            TCard[] TempHand = new TCard[CARDSPERSUIT];

            for (int i = 0; i < Cards.Length; i++)
            {
                Hands[HandNum].cards[CardNum] = Cards[i];
                CardNum++;
                if ((i + 1) % CARDSPERSUIT == 0)
                {
                    CardNum = 0;
                    HandNum++;
                }
            }
        }
Ejemplo n.º 10
0
        public TDeck()
        {
            Cards = new TCard[TOTALCARDS];
            int Suit = -1;
            int CardValue = 0;

            for (int i = 0; i < Cards.Length; i++)
            {
                if (i % CARDSPERSUIT == 0) Suit++;
                CardValue = i % CARDSPERSUIT;
                Cards[i] = new TCard(Suit, CardValue);
            }
        }