Ejemplo n.º 1
0
        private void CreateDestinationCards()
        {
            DestinationCards.Add(new DestinationCard(City.NewYork, City.Atlanta, 6));
            DestinationCards.Add(new DestinationCard(City.Winnipeg, City.LittleRock, 11));
            DestinationCards.Add(new DestinationCard(City.Boston, City.Miami, 12));
            DestinationCards.Add(new DestinationCard(City.LosAngeles, City.Chicago, 16));
            DestinationCards.Add(new DestinationCard(City.Montreal, City.Atlanta, 9));
            DestinationCards.Add(new DestinationCard(City.Seattle, City.LosAngeles, 9));
            DestinationCards.Add(new DestinationCard(City.KansasCity, City.Houston, 5));
            DestinationCards.Add(new DestinationCard(City.Chicago, City.NewOrleans, 7));
            DestinationCards.Add(new DestinationCard(City.Seattle, City.NewYork, 22));
            DestinationCards.Add(new DestinationCard(City.Portland, City.Nashville, 17));
            DestinationCards.Add(new DestinationCard(City.SaultSaintMarie, City.OklahomaCity, 9));
            DestinationCards.Add(new DestinationCard(City.Vancouver, City.SantaFe, 13));
            DestinationCards.Add(new DestinationCard(City.SanFrancisco, City.Atlanta, 17));
            DestinationCards.Add(new DestinationCard(City.Vancouver, City.Montreal, 20));
            DestinationCards.Add(new DestinationCard(City.Montreal, City.NewOrleans, 13));
            DestinationCards.Add(new DestinationCard(City.LosAngeles, City.NewYork, 21));
            DestinationCards.Add(new DestinationCard(City.Calgary, City.SaltLakeCity, 7));
            DestinationCards.Add(new DestinationCard(City.Denver, City.Pittsburgh, 11));
            DestinationCards.Add(new DestinationCard(City.Helena, City.LosAngeles, 8));
            DestinationCards.Add(new DestinationCard(City.Calgary, City.Phoenix, 13));
            DestinationCards.Add(new DestinationCard(City.Chicago, City.SantaFe, 9));
            DestinationCards.Add(new DestinationCard(City.Toronto, City.Miami, 10));;
            DestinationCards.Add(new DestinationCard(City.Dallas, City.NewYork, 11));
            DestinationCards.Add(new DestinationCard(City.Duluth, City.Houston, 8));
            DestinationCards.Add(new DestinationCard(City.SaultSaintMarie, City.Nashville, 8));
            DestinationCards.Add(new DestinationCard(City.Duluth, City.ElPaso, 10));
            DestinationCards.Add(new DestinationCard(City.Winnipeg, City.Houston, 12));
            DestinationCards.Add(new DestinationCard(City.Denver, City.ElPaso, 4));
            DestinationCards.Add(new DestinationCard(City.LosAngeles, City.Miami, 20));
            DestinationCards.Add(new DestinationCard(City.Portland, City.Phoenix, 11));

            DestinationCards = DestinationCards.Shuffle();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creating app start data
        /// </summary>
        public void CreateApp()
        {
            for (int i = 1; i < (NumberOfCards + 1); i++)
            {
                DestinationCards.Add(i);
                SourceCards.Add(i);
            }
            ;
            DestinationCards.Shuffle();
            SourceCards.Shuffle();

            SaveFile(this);
        }
Ejemplo n.º 3
0
        private void DrawDestinationCards()
        {
            var tempDestinationCards = (Board.DestinationCards.Pop(3)).OrderByDescending(x => x.PointValue);

            // For each of these cards, keep only the one that's either complete or is completable

            List <DestinationCard> discardCards = new List <DestinationCard>();
            List <DestinationCard> keptCards    = new List <DestinationCard>();

            foreach (var card in tempDestinationCards)
            {
                // Keep cads that are already connected
                if (Board.Routes.IsAlreadyConnected(card.Origin, card.Destination, Color))
                {
                    keptCards.Add(card);
                    continue;
                }

                Board.Routes.AlreadyCheckedCities.Clear();

                var possibleRoutes = CalculateTargetedRoutes(card);

                if (!possibleRoutes.Any())
                {
                    discardCards.Add(card);
                }
                else
                {
                    keptCards.Add(card);
                }
            }

            // If there are no kept cards, the player must keep at least one, so keep the one with the lowest point value
            if (!keptCards.Any())
            {
                discardCards = discardCards.OrderBy(x => x.PointValue).ToList();
                keptCards.AddRange(discardCards.Pop(1));
            }

            // Return the discarded cards to the destination cards deck
            if (discardCards.Any())
            {
                // Return the discarded cards to the destination card pile
                Board.DestinationCards.AddRange(discardCards);
            }

            // Add kept cards to the player's collection
            DestinationCards.AddRange(keptCards);

            Console.WriteLine(Name + " draws new destination cards!");
        }
        public void CalculateTargetedRoutes()
        {
            var allRoutes = new List <BoardRoute>();

            var highestCards = DestinationCards.OrderBy(x => x.PointValue).ToList();

            foreach (var destCard in highestCards)
            {
                var matchingRoutes = CalculateTargetedRoutes(destCard);
                if (matchingRoutes.Any())
                {
                    allRoutes.AddRange(matchingRoutes);
                    break;
                }
            }

            TargetedRoutes = allRoutes.GroupBy(x => new { x.Origin, x.Destination, x.Color, x.Length })
                             .Select(group => new
            {
                Metric = group.Key,
                Count  = group.Count()
            }).OrderByDescending(x => x.Count)
                             .ThenByDescending(x => x.Metric.Length)
                             .Take(5)
                             .Select(x => new BoardRoute(x.Metric.Origin, x.Metric.Destination, x.Metric.Color, x.Metric.Length))
                             .ToList();


            DesiredColors = TargetedRoutes.Select(x => x.Color)
                            .Distinct()
                            .ToList();

            if (!DesiredColors.Any() && Hand.Any())
            {
                //The player should target what they have the most of

                var color = Hand.GroupBy(x => x.Color)
                            .Select(group =>
                                    new
                {
                    Color = group.Key,
                    Count = group.Count()
                })
                            .OrderByDescending(x => x.Count)
                            .Select(x => x.Color)
                            .First();

                DesiredColors.Add(color);
            }
        }
        private void CreateDestinationCards()
        {
            DestinationCards.Add(City.Athina, City.Angora, 5);
            DestinationCards.Add(City.Budapest, City.Sofia, 5);
            DestinationCards.Add(City.Frankfurt, City.Kobenhavn, 5);
            DestinationCards.Add(City.Rostov, City.Erzurum, 5);
            DestinationCards.Add(City.Sofia, City.Smyrna, 5);
            DestinationCards.Add(City.Kyiv, City.Petrograd, 5);
            DestinationCards.Add(City.Zurich, City.Brindisi, 6);
            DestinationCards.Add(City.Zurich, City.Budapest, 6);
            DestinationCards.Add(City.Warzawa, City.Smolensk, 6);
            DestinationCards.Add(City.Zagrab, City.Brindisi, 6);
            DestinationCards.Add(City.Paris, City.Zagrab, 7);
            DestinationCards.Add(City.Brest, City.Marseille, 7);
            DestinationCards.Add(City.London, City.Berlin, 7);
            DestinationCards.Add(City.Edinburgh, City.Paris, 7);
            DestinationCards.Add(City.Amsterdam, City.Pamplona, 7);
            DestinationCards.Add(City.Roma, City.Smyrna, 8);
            DestinationCards.Add(City.Palermo, City.Constantinople, 8);
            DestinationCards.Add(City.Sarajevo, City.Sevastapol, 8);
            DestinationCards.Add(City.Madrid, City.Dieppe, 8);
            DestinationCards.Add(City.Barcelona, City.Bruxelles, 8);
            DestinationCards.Add(City.Paris, City.Wien, 8);
            DestinationCards.Add(City.Barcelona, City.Munchen, 8);
            DestinationCards.Add(City.Brest, City.Venezia, 8);
            DestinationCards.Add(City.Smolensk, City.Rostov, 8);
            DestinationCards.Add(City.Marseille, City.Essen, 8);
            DestinationCards.Add(City.Kyiv, City.Sochi, 8);
            DestinationCards.Add(City.Madrid, City.Zurich, 8);
            DestinationCards.Add(City.Berlin, City.Bucuresti, 8);
            DestinationCards.Add(City.Berlin, City.Roma, 9);
            DestinationCards.Add(City.Bruxelles, City.Danzig, 9);
            DestinationCards.Add(City.Angora, City.Kharkov, 10);
            DestinationCards.Add(City.Riga, City.Bucuresti, 10);
            DestinationCards.Add(City.Essen, City.Kyiv, 10);
            DestinationCards.Add(City.Venezia, City.Constantinople, 10);
            DestinationCards.Add(City.London, City.Wien, 10);
            DestinationCards.Add(City.Athina, City.Wilno, 11);
            DestinationCards.Add(City.Stockholm, City.Wien, 11);
            DestinationCards.Add(City.Berlin, City.Moskva, 12);
            DestinationCards.Add(City.Amsterdam, City.Wilno, 12);
            DestinationCards.Add(City.Frankfurt, City.Smolensk, 13);

            DestinationCards = DestinationCards.Shuffle();
        }