Beispiel #1
0
        /// <summary>
        /// Initializes a new deck and shuffles
        /// </summary>
        //public Deck(int numberOfDecks = 1)
        //{
        //    show = new Display();
        //    Initialize(numberOfDecks);
        //}

        public Deck(List <ICard> customDeck, IDisplay disp)
        {
            RemainingCards.Clear();
            PlayedCards.Clear();
            RemainingCards  = customDeck;
            show            = disp;
            usingCustomDeck = true;
            NumberOfDecks   = 1;
        }
Beispiel #2
0
        public void Reset()
        {
            foreach (Card c in PlayedCards)
            {
                c.PeggingRound = 0;
                c.CanBePlayed  = true;
                c.WasPlayed    = false;
                Count          = 0;
            }

            TurnPlayer.Alert     = "";
            PrevTurnPlayer.Alert = "";
            SwapPlayers();
            PlayedCards.Clear();
            PeggingRound = 1;
        }
Beispiel #3
0
        public override PlayedCards PlayTurn(PlayedCards currentMove)
        {
            var cardsToPlay = new PlayedCards(this);

            // display the cards to the player
            DisplayCardList();

            bool valid = false;

            do
            {
                var stillBuildingHand = true;

                do
                {
                    int selectedCardIndex = GetUserSelectedCardIndex();

                    if (selectedCardIndex >= 0)
                    {
                        Card selectedCard = Hand[selectedCardIndex];
                        cardsToPlay.AddCard(selectedCard);
                        valid = true;
                    }

                    if (!ContinueBuildingHandPrompt())
                    {
                        stillBuildingHand = false;
                    }
                } while (stillBuildingHand);


                try
                {
                    // validate the move
                    cardsToPlay.Validate(currentMove);
                }
                catch (Exception ex)
                {
                    cardsToPlay.Clear();
                    Console.WriteLine("Invalid move: " + ex.Message);
                    valid = false;
                }
            } while (valid == false);

            // play the cards);
            return(cardsToPlay);
        }