Ejemplo n.º 1
0
        public void DrawCards(int numOfCards, Pile playerHand, CardDeck deck)
        {
            Card temp = new Card();

            for (int i = 0; i < numOfCards; i++)
            {
                temp = deck.DealCard();
                playerHand.AddCard(temp);
            }
        }
Ejemplo n.º 2
0
        void LayDownProperty(Card propertyCard, Pile playerHand, List <PropertySet> playerProperties, Player player)
        {
            string wildColor = "";

            if (propertyCard.Color.Contains("|"))
            {
                wildColor = WildColorSelection(propertyCard);
            }

            // assign to wildColor if not blank; otherwise, default card value
            string selectedCardColor = wildColor != "" ?
                                       wildColor :
                                       propertyCard.Color;

            Console.WriteLine($"Laying down this property: {propertyCard.GetCardDescription()}");

            // query for any properties of same color and not full
            bool addedToExisting = false;

            for (int i = 0; i < playerProperties.Count(); i++)
            {
                var propertyQuery = from propertySet in playerProperties[i].CardPile
                                    where playerProperties[i].Color.ToLower() == selectedCardColor.ToLower() &&
                                    playerProperties[i].GetSize() < playerProperties[i].Capacity
                                    select propertySet;
                // if avail, add to existing
                if (propertyQuery.Count() > 0)
                {
                    // add to property set
                    playerProperties[i].AddCard(propertyCard);
                    // remove from hand
                    playerHand.RemoveCard(propertyCard);
                    addedToExisting = true;
                    break;
                }
            }

            // if  not avail, create new property pile
            if (!addedToExisting)
            {
                // create property set
                playerProperties.Add(new PropertySet(player.Name, "Property", selectedCardColor));
                // add to property set
                playerProperties.Last().AddCard(propertyCard);
                // remove from hand
                playerHand.RemoveCard(propertyCard);
            }

            // var reset
            addedToExisting = false;
        }
Ejemplo n.º 3
0
        public void SetupPlayers()
        {
            string countRemind = "Please enter an integer between 2 and 5.";

            string[] players = new string[5];

            do
            {
                Console.WriteLine("How many players?  (2-5 players)");
                try
                {
                    numOfPlayers = Int32.Parse(Console.ReadLine());
                }
                catch (FormatException e)
                {
                    Console.WriteLine($"{e.Message} \n{countRemind}");
                }
                if (numOfPlayers < 2 && numOfPlayers != 0)
                {
                    Console.WriteLine($"You can't play by yourself...\n{countRemind}");
                }
                if (numOfPlayers > 5)
                {
                    Console.WriteLine($"I can't keep track of that many players!\n{countRemind}");
                }
            } while (numOfPlayers < 2 || numOfPlayers > 5);

            for (int i = 0; i < numOfPlayers; i++)
            {
                Console.WriteLine($"Please enter name for player {i + 1}");
                players[i]       = Console.ReadLine();
                playerArray[i]   = new Player(players[i]);
                handArray[i]     = new Pile(playerArray[i].Name, "Hand");
                bankArray[i]     = new Pile(playerArray[i].Name, "Bank");
                propertyArray[i] = new List <PropertySet>();
            }
        }
Ejemplo n.º 4
0
 public Player(string name)
 {
     Name       = name;
     playerHand = new Pile(Name, "Hand");
 }