private void buttonPrev_Click(object sender, RoutedEventArgs e)
        {
            if (index >= 0 && index < cards.Count)
            {
                cardToPlay = cards.ElementAt(index);

                image.BeginInit();
                image.Source = new BitmapImage(
                    new Uri(@"pack://*****:*****@"pack://application:,,,/Images/" + cardToPlay.getName() + ".jpg", UriKind.RelativeOrAbsolute));
                image.EndInit();

                index -= 1;
            }
        }
//=================================================================================================================
// Method to take the input card and place it in the next slot on the board
        private void changeCardHelper(Card c, String s, int startIndex, int lengthIndex)
        {
            Canvas g = (Canvas)parent.Children[1];

            for (int i = 0; i < lengthIndex; i++)
            {
                Image  img  = (Image)g.Children[startIndex++];
                String name = ((BitmapImage)img.Source).UriSource.ToString();//parse this to see if slot is empty
                String subs = name.Split(',').Last();
                String last = subs.Split('/').Last();

                //handle both cases of placeholder cards
                String empty = "EmptyCard.png";
                String dark  = "darkPlaceholder.png";

                if (last.Equals(empty, StringComparison.Ordinal) || last.Equals(dark, StringComparison.Ordinal))
                {
                    img.BeginInit();
                    img.Source = new BitmapImage(
                        new Uri(@"pack://application:,,,/Images/" + c.getName() + ".jpg", UriKind.RelativeOrAbsolute));
                    img.EndInit();
                    break;
                }
            }
        }
Example #3
0
        public int calcCommerceIncome(Card playedCard, GameState gs, int playerId)
        {
            PlayerState thePlayer = gs.getPlayerNum(playerId);

            //System.Console.WriteLine(playedCard.getNumber());
            if (!playedCard.getName().StartsWith("CO"))
            {
                return(0);
            }
            if (playedCard.GetType() != typeof(CommerceCard))
            {
                return(0);
            }
            CommerceCard commCard = (CommerceCard)playedCard;

            if (commCard.getCoins() != 0)
            {
                return(commCard.getCoins());
            }
            if ((commCard.getNumber().Equals(77)) ||
                (commCard.getNumber().Equals(78)))
            {
                return(countCardType(1, thePlayer)
                       + countCardType(1, gs.getLeftPlayer(thePlayer))
                       + countCardType(1, gs.getRightPlayer(thePlayer)));
            }
            if ((commCard.getNumber().Equals(80)) ||
                (commCard.getNumber().Equals(79)))
            {
                return(countCardType(2, thePlayer)
                       + countCardType(2, gs.getLeftPlayer(thePlayer))
                       + countCardType(2, gs.getRightPlayer(thePlayer)));
            }
            //Haven
            if ((commCard.getNumber().Equals(119)) ||
                (commCard.getNumber().Equals(120)))
            {
                return(countCardType(1, thePlayer));
            }
            //LightHouse
            if ((commCard.getNumber().Equals(121)) ||
                (commCard.getNumber().Equals(122)))
            {
                return(countCardType(4, thePlayer));
            }
            //Chamber of Commerce
            if ((commCard.getNumber().Equals(123)) ||
                (commCard.getNumber().Equals(124)))
            {
                return(2 * countCardType(2, thePlayer));
            }
            //Arena
            if ((commCard.getNumber().Equals(125)) ||
                (commCard.getNumber().Equals(126)) ||
                (commCard.getNumber().Equals(127)))
            {
                return(3 * thePlayer.getBoard().getCurrentWonderLevel());
            }
            return(0);
        }
Example #4
0
 public int calcCommerceIncome(Card playedCard, GameState gs, int playerId)
 {
     PlayerState thePlayer = gs.getPlayerNum(playerId);
     //System.Console.WriteLine(playedCard.getNumber());
     if (!playedCard.getName().StartsWith("CO"))
     {
         return 0;
     }
     if(playedCard.GetType() != typeof(CommerceCard))
     {
         return 0;
     }
     CommerceCard commCard = (CommerceCard)playedCard;
     if (commCard.getCoins() != 0)
     {
         return commCard.getCoins();
     }
     if ((commCard.getNumber().Equals(77)) ||
         (commCard.getNumber().Equals(78)))
     {
         return countCardType(1, thePlayer) 
             + countCardType(1, gs.getLeftPlayer(thePlayer))
             + countCardType(1, gs.getRightPlayer(thePlayer));
     }
     if ((commCard.getNumber().Equals(80)) ||
         (commCard.getNumber().Equals(79)))
     {
         return countCardType(2, thePlayer)
             + countCardType(2, gs.getLeftPlayer(thePlayer))
             + countCardType(2, gs.getRightPlayer(thePlayer));
     }
     //Haven
     if ((commCard.getNumber().Equals(119)) ||
         (commCard.getNumber().Equals(120)))
     {
         return countCardType(1, thePlayer);
     }
     //LightHouse
     if ((commCard.getNumber().Equals(121)) ||
         (commCard.getNumber().Equals(122)))
     {
         return countCardType(4, thePlayer);
     }
     //Chamber of Commerce
     if ((commCard.getNumber().Equals(123)) ||
         (commCard.getNumber().Equals(124)))
     {
         return 2 * countCardType(2, thePlayer);
     }
     //Arena
     if ((commCard.getNumber().Equals(125)) ||
         (commCard.getNumber().Equals(126)) ||
         (commCard.getNumber().Equals(127)))
     {
         return 3 * thePlayer.getBoard().getCurrentWonderLevel();
     }
     return 0;
 }
        public PlayExtraCardWindow(PlayerState p, Grid g, PlayerGameBoard pgb, Card c)
        {
            player     = p;
            parent     = g;
            view       = pgb;
            cardToPlay = c;

            InitializeComponent();

            image.Source = new BitmapImage(
                new Uri(@"pack://application:,,,/Images/" + cardToPlay.getName() + ".jpg", UriKind.RelativeOrAbsolute));
        }
//=================================================================================================================
// This is a filtering method to determine where in the board the card should be added
        public void changeCard(Card c)
        {
            if (c.getName()[0].Equals('R'))
            {
                changeCardHelper(c, "R", 0, 10);
            }                                                                     //3-12
            if (c.getName()[0].Equals('M'))
            {
                changeCardHelper(c, "M", 10, 10);
            }                                                                     //13-22
            if (c.getName()[0].Equals('S'))
            {
                changeCardHelper(c, "S", 20, 10);
            }                                                                     //23-32
            if (c.getName()[1].Equals('O'))
            {
                changeCardHelper(c, "CO", 30, 10); return;
            }                                                                             //return to not continue
            if (c.getName()[0].Equals('C'))
            {
                changeCardHelper(c, "C", 40, 10);
            }                                                                     //33-42
            if (c.getName()[0].Equals('G'))
            {
                changeCardHelper(c, "G", 50, 6);
            }                                                                    //53-57
        }
Example #7
0
 public void ValidatingCard(PlayerState p, Card c)
 {
     if (Log(p))
     {
         System.Console.WriteLine("\n\n=============================================================================================================");
         System.Console.WriteLine("{0}:: \nValidateCard( Player [{1}] Card [{2}] Coin Cost [{3}] Resource Cost [{4}])"
                                  , _class.GetType().Name
                                  , p.getName()
                                  , c.getName()
                                  , c.getCoinCost()
                                  , c.getTotalResourceCost());
         System.Console.WriteLine("=============================================================================================================");
     }
 }
Example #8
0
        public void CheckCommerceCard(PlayerState p, Card c)
        {
            if (Log(p))
            {
                Console.WriteLine("\n--------------------------------------------------------------------------------------------------------");

                CommerceCard card = (CommerceCard)c;

                int   totalResourceCost = c.getTotalResourceCost();
                int[] costs             = card.getCost();
                int[] collect           = card.getCollect();
                int[] resourceTradable  = card.getResourceTradable();

                Console.WriteLine("[{0}] Commerce Card  [{1}] Total Resource Cost [{2}]", _class.GetType().Name
                                  , c.getName()
                                  , totalResourceCost);

                var resources = Enum.GetValues(typeof(Resource));

                // Get the cost and display it
                Console.WriteLine("[Card.getCost()            ] ");
                foreach (var resource in resources)
                {
                    int index = (int)resource;
                    Console.Write("[{0} : {1}] ", ((Resource)index).ToString(), costs[index]);
                }
                Console.WriteLine();

                //0 = none, 1 = resource card, 2 = manufactured good
                int resourceType = card.getResources();
                Console.WriteLine("[Card.getCollect()] RT [{0}] ] ", resourceType);
                // resources = Enum.GetValues(typeof(Resource));
                for (int index = 0; index < collect.Count(); index++)
                {
                    Console.Write("[{0} : {1}] ", ((Resource)index).ToString(), collect[index]);
                }
                Console.WriteLine();

                // resources = Enum.GetValues(typeof(Resource));
                // Console.WriteLine("[Card.getResourceTradable ({0})] ", card.hasTradableResources());
                for (int index = 0; index < resourceTradable.Count(); index++)
                {
                    Console.Write("[{0} : {1}] ", ((Resource)index).ToString(), resourceTradable[index]);
                }
                Console.WriteLine();
                Console.WriteLine("--------------------------------------------------------------------------------------------------------\n");
            }
        }
Example #9
0
        public void CheckCommerceCard(PlayerState p, Card c)
        {
            if (Log(p))
            {
                Console.WriteLine("\n--------------------------------------------------------------------------------------------------------");

                CommerceCard card = (CommerceCard)c;

                int totalResourceCost = c.getTotalResourceCost();
                int[] costs = card.getCost();
                int[] collect = card.getCollect();
                int[] resourceTradable = card.getResourceTradable();

                Console.WriteLine("[{0}] Commerce Card  [{1}] Total Resource Cost [{2}]", _class.GetType().Name
                                  , c.getName()
                                  , totalResourceCost);

                var resources = Enum.GetValues(typeof(Resource));

                // Get the cost and display it
                Console.WriteLine("[Card.getCost()            ] ");
                foreach (var resource in resources)
                {
                    int index = (int)resource;
                    Console.Write("[{0} : {1}] ", ((Resource)index).ToString(), costs[index]);
                }
                Console.WriteLine();

                //0 = none, 1 = resource card, 2 = manufactured good
                int resourceType = card.getResources();
                Console.WriteLine("[Card.getCollect()] RT [{0}] ] ", resourceType);
                // resources = Enum.GetValues(typeof(Resource));             
                for (int index = 0; index < collect.Count(); index++)
                {
                    Console.Write("[{0} : {1}] ", ((Resource)index).ToString(), collect[index]);
                }
                Console.WriteLine();

                // resources = Enum.GetValues(typeof(Resource));
                // Console.WriteLine("[Card.getResourceTradable ({0})] ", card.hasTradableResources());
                for (int index = 0; index < resourceTradable.Count(); index++)
                {
                    Console.Write("[{0} : {1}] ", ((Resource)index).ToString(), resourceTradable[index]);
                }
                Console.WriteLine();
                Console.WriteLine("--------------------------------------------------------------------------------------------------------\n");
            }
        }
Example #10
0
 public void ValidatingCard(PlayerState p, Card c)
 {
     if (Log(p))
     {
         System.Console.WriteLine("\n\n=============================================================================================================");
         System.Console.WriteLine("{0}:: \nValidateCard( Player [{1}] Card [{2}] Coin Cost [{3}] Resource Cost [{4}])"
                                  , _class.GetType().Name
                                  , p.getName()
                                  , c.getName()
                                  , c.getCoinCost()
                                  , c.getTotalResourceCost());
         System.Console.WriteLine("=============================================================================================================");
     }
 }
Example #11
0
        public void DisplayResourceCost(PlayerState p, Card c)
        {
            if (Log(p))
            {
                int[] cardsResourceCost = c.getCost();

                Console.Write("[{0}] [{1}] Card  [{2}] Costs: ", _class.GetType().Name, c.getName(), c.getCost());

                var resources = Enum.GetValues(typeof(Resource));
                foreach (var resource in resources)
                {
                    int index = (int)resource;
                    Console.Write("[{0} : {1:N2}] ", resource, cardsResourceCost[index]);
                }
                Console.WriteLine();
            }
        }
Example #12
0
        public void DisplayResourceCost(PlayerState p, Card c)
        {
            if (Log(p))
            {
                int[] cardsResourceCost = c.getCost();

                Console.Write("[{0}] [{1}] Card  [{2}] Costs: ", _class.GetType().Name, c.getName(), c.getCost());

                var resources = Enum.GetValues(typeof(Resource));
                foreach (var resource in resources)
                {
                    int index = (int)resource;
                    Console.Write("[{0} : {1:N2}] ", resource, cardsResourceCost[index]);
                }
                Console.WriteLine();
            }
        }
Example #13
0
//=================================================================================================================
// Method to take the input card and place it in the next slot on the board
        private void changeCardHelper(Card c, String s, int startIndex, int lengthIndex)
        {
            Canvas g = (Canvas)parent.Children[1];

            for (int i = 0; i < lengthIndex; i++)
            {
                Image img = (Image)g.Children[startIndex++];
                String name = ((BitmapImage)img.Source).UriSource.ToString();//parse this to see if slot is empty
                String subs = name.Split(',').Last();
                String last = subs.Split('/').Last();
                
                //handle both cases of placeholder cards
                String empty = "EmptyCard.png";
                String dark = "darkPlaceholder.png";
                
                if (last.Equals(empty, StringComparison.Ordinal) || last.Equals(dark, StringComparison.Ordinal))
                {
                    img.BeginInit();
                    img.Source = new BitmapImage(
                        new Uri(@"pack://application:,,,/Images/" + c.getName() + ".jpg", UriKind.RelativeOrAbsolute));
                    img.EndInit();
                    break;
                }
            }
        }
Example #14
0
//=================================================================================================================    
// This is a filtering method to determine where in the board the card should be added
        public void changeCard(Card c)
        {
            if (c.getName()[0].Equals('R')) { changeCardHelper(c, "R",  0,  10); }//3-12
            if (c.getName()[0].Equals('M')) { changeCardHelper(c, "M",  10, 10); }//13-22
            if (c.getName()[0].Equals('S')) { changeCardHelper(c, "S",  20, 10); }//23-32
            if (c.getName()[1].Equals('O')) { changeCardHelper(c, "CO", 30, 10); return; }//return to not continue
            if (c.getName()[0].Equals('C')) { changeCardHelper(c, "C",  40, 10); }//33-42            
            if (c.getName()[0].Equals('G')) { changeCardHelper(c, "G",  50, 6); }//53-57
        }