Beispiel #1
0
        /// <summary>
        /// a
        /// </summary>
        /// <returns></returns>
        public static ActionResult UserDrawCard()
        {
            if (IsPlaying == false)
            {
                throw new System.ArgumentException("This game is not start!");
            }
            if (IsUserTurn == false)
            {
                throw new System.ArgumentException("This is not your turn!");
            }


            if (TopDiscard.GetFaceValue() == FaceValue.Eight)
            {
                return(ActionResult.CannotDraw);
            }

            foreach (Card c in UserHand)
            {
                if (c.GetFaceValue() == TopDiscard.GetFaceValue() || c.GetSuit() == TopDiscard.GetSuit())
                {
                    return(ActionResult.CannotDraw);
                }
            }

            if (_drawPile.GetCount() == 0)
            {
                _discardPile.Reverse();
                while (_discardPile.GetCount() > 1)
                {
                    _drawPile.AddCard(_discardPile.DealOneCard());
                }
                return(ActionResult.FlippedDeck);
            }

            Card drawCard = _drawPile.DealOneCard();

            UserHand.AddCard(drawCard);

            if (drawCard.GetFaceValue() == TopDiscard.GetFaceValue() || drawCard.GetSuit() == TopDiscard.GetSuit())
            {
                return(ActionResult.DrewPlayableCard);
            }
            else
            {
                if (UserHand.GetCount() == 13)
                {
                    IsUserTurn = false;
                    if (ComputerHand.GetCount() == 13)
                    {
                        return(ActionResult.DrewAndResetPiles);
                    }
                    else
                    {
                        return(ActionResult.DrewAndNoMovePossible);
                    }
                }
                else
                {
                    return(ActionResult.DrewUnplayableCard);
                }
            }
        }