Beispiel #1
0
        // Helper Method for the Constructor to deal each player's starting Deck
        // 7 Copper and 3 Estate here, but assuming it varies by expansion, it's nice to come back and only have to adjust this method
        public void DealStartingCards(Player player)
        {
            // Deal the first 7 Coppers found in BasicCards to player
            for (int i = 0; i < 7; i++)
            {
                Card cardToDeal = BasicCards.FirstOrDefault(c => c.Title == "Copper");
                if (cardToDeal != null)
                {
                    BasicCards.Remove(cardToDeal);
                    player.Deck.Add(cardToDeal);
                }
                else
                {
                    // panic
                }
            }
            // Deal the first 3 Estates found in BasicCards to player
            for (int i = 0; i < 3; i++)
            {
                Card cardToDeal = BasicCards.FirstOrDefault(c => c.Title == "Estate");
                if (cardToDeal != null)
                {
                    BasicCards.Remove(cardToDeal);
                    player.Deck.Add(cardToDeal);
                    player.TotalVP += cardToDeal.VPValue;
                }
                else
                {
                    // panic
                }
            }

            // Need to shuffle the starting deck
            player.Shuffle();

            return;
        }
Beispiel #2
0
        // Helper Method for the Controller to check if Game is finished
        public bool GameFinished()
        {
            /*
             *  CONDITION #1: All Provinces are removed from field
             */
            // Faster method: If there are no more Providences, LINQ returns null, so we use that as the condition
            Card firstProvince = BasicCards.FirstOrDefault(c => c.Title == "Province");

            if (firstProvince == null)
            {
                return(true);
            }

            /*
             *  Condition #2: 3 Kinds of any card are removed from field
             */
            // Make counter dictionary
            Dictionary <string, int> counters = new Dictionary <string, int>();

            counters.Add("Duchy", 0);
            counters.Add("Estate", 0);
            counters.Add("Copper", 0);
            counters.Add("Silver", 0);
            counters.Add("Gold", 0);

            // Build counter dictionary
            foreach (Card card in BasicCards)
            {
                if (card.Title == "Duchy")
                {
                    counters["Duchy"]++;
                }
                if (card.Title == "Estate")
                {
                    counters["Estate"]++;
                }
                if (card.Title == "Copper")
                {
                    counters["Copper"]++;
                }
                if (card.Title == "Silver")
                {
                    counters["Silver"]++;
                }
                if (card.Title == "Gold")
                {
                    counters["Gold"]++;
                }
            }

            // Repeated for Action Cards. When we move to adding more / picking random, add logic to only check for the ones that existed at game start.
            counters.Add("Village", 0);
            counters.Add("Smithy", 0);
            counters.Add("Festival", 0);
            counters.Add("Market", 0);
            foreach (Card card in KingdomCards)
            {
                if (card.Title == "Village")
                {
                    counters["Village"]++;
                }
                if (card.Title == "Smithy")
                {
                    counters["Smithy"]++;
                }
                if (card.Title == "Festival")
                {
                    counters["Festival"]++;
                }
                if (card.Title == "Market")
                {
                    counters["Market"]++;
                }
            }


            // Count the zeros
            int depleted_card_types = 0;

            foreach (KeyValuePair <string, int> item in counters)
            {
                if (item.Value == 0)
                {
                    depleted_card_types++;
                }
                if (depleted_card_types >= 3)
                {
                    return(true);
                }
            }

            return(false);
        }