Exemplo n.º 1
0
        /// <summary>
        /// Draws a domino from the boneyard and adds it to the hand
        /// </summary>
        /// <param name="by"></param>
        ///
        // call the  draw method from the boneyard and then add that to the hand. boom done
        public void Draw(BoneYard by)
        {
            Domino d = new Domino();

            if (by.IsEmpty())
            {
                return; //should probably throw exception.
            }
            else
            {
                handofDominos.Add(by.Draw());
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Hand - Overloaded Constructor - Passes in a boneyard
        /// </summary>
        /// <param name="by">Boneyard - Pass in a Boneyard Object</param>
        /// <param name="numPlayers">Int - The number of players</param>
        public Hand(BoneYard by, int numPlayers)
        {
            // Players 2  3  4   5  6  7 8
            // Draw    16 16 15 14 12 10 9
            int drawDominos = 0;

            if (numPlayers >= 8)
            {
                drawDominos = 9;
            }
            else if (numPlayers >= 7)
            {
                drawDominos = 10;
            }
            else if (numPlayers >= 6)
            {
                drawDominos = 12;
            }
            else if (numPlayers >= 5)
            {
                drawDominos = 14;
            }
            else if (numPlayers >= 4)
            {
                drawDominos = 15;
            }
            else if (numPlayers >= 2)
            {
                drawDominos = 16;
            }
            // Loop thru and draw th cards
            for (int i = 0; i < drawDominos; i++)
            {
                if (!by.IsEmpty())
                {
                    this.Draw(by);
                }
            }
        }