Ejemplo n.º 1
0
        /******************************
         * Adding The players
         *******************************/

        public static void addPlayers(List <Player> playerList, List <foto> pics, int realPlayers, int robots, List <City> citylist, List <Railroad> network)
        {
            List <Player>     botPlayer = new List <Player>();
            IntelligentPlayer Emiel     = new IntelligentPlayer("Emile", System.Drawing.Color.Blue, citylist, network); botPlayer.Add(Emiel);
            IntelligentPlayer Dirk      = new IntelligentPlayer("Dirkske", System.Drawing.Color.Red, citylist, network); botPlayer.Add(Dirk);
            IntelligentPlayer Luka      = new IntelligentPlayer("Luka", System.Drawing.Color.Yellow, citylist, network); botPlayer.Add(Luka);
            IntelligentPlayer Jeff      = new IntelligentPlayer("Jeff", System.Drawing.Color.Black, citylist, network); botPlayer.Add(Jeff);

            for (int i = 0; i < robots; i++)
            {
                CardMethods <Player> .swapCardFromDeck(botPlayer, playerList);
            }

            /******************************
             * Ask user here player data
             *******************************/
            for (int i = 0; i < realPlayers; i++)
            {
                PlayerData   data = new PlayerData();
                PlayerDialog form = new PlayerDialog(data, pics);
                while (data.getName() == null || data.getColor() == null)
                {
                    form.ShowDialog();
                }
                Player a = new Player(data.getName(), data.getColor());
                playerList.Add(a);
            }
            Program.logboek.WriteLine(string.Format("{0} players added", playerList.Count));
        }
Ejemplo n.º 2
0
 internal static void CheckSizeOfMainDeck(List <TrainCard> Deck)
 {
     if (Deck.Count < 5)                                      // we add the used cards to the deck and shuffle the deck if the deck gets bigger
     {
         while (usedCardsDeck.Count > 5)
         {
             CardMethods <TrainCard> .swapCardFromDeck(usedCardsDeck, Deck);
         }
         CardMethods <TrainCard> .shuffle(Deck);
     }
 }
Ejemplo n.º 3
0
        /********************
         * wou met events handlers werken en wachten op input wan de console
         * (om zoveel mogelijk de data/ onderliggende objecten af te schermen)
         * maar had hiervoor een asynchrone methode voor nodig en had een beetje tijdtekort,
         * heb me vooral gefocust op intelligentie en een werkend programma
         *********************/

        public Round(Game game, List <foto> gamePics)
        {
            this.gamePics   = gamePics;
            citylist        = game.getcitylist();
            destinationcard = game.getNormDestcard();
            deck            = game.getDeck();
            network         = game.getNetwork();
            playerlist      = game.getPlayers();

            for (int i = 0; i < 5; i++)
            {
                CardMethods <TrainCard> .swapCardFromDeck(deck, visibleTraincards);     // we pick the first 5 cards from the deck and put them in the visible pack
            }
            visibleTraincards.Sort();
            Program.form.refreshVisibleTrainCards(visibleTraincards);
        }
Ejemplo n.º 4
0
        public static bool PickTrainCards(Player player, List <TrainCard> deck, List <TrainCard> visibleDeck,
                                          int roundNumber, List <foto> gamePics, List <TrainCard> favourableCards = null)
        {
            // visibleTraincards = visibleDeck;

            /******************************
             * playerInput
             *******************************/
            int       i = 0, val = 0;
            TrainCard card       = null;
            bool      Locomotive = false;

            while (Locomotive == false && i < 2)
            // de spelers mogen 2 kaarten nemen (tenzij ze een locomotief nemen in de eerste ronde
            {
                Program.logboek.WriteLine("");
                Program.logboek.WriteLine("1.\tPick an invisible card");
                Program.logboek.WriteLine("2.\tPick a visible card");
                val = player.ChoseOption(Possibilities.Traincard);    // geïmplementeerd bij intelligente speler

                switch (val)
                {
                case (int)Cardoptions.Invisible:
                    /******************************
                     * Onzichtbare kaart
                     *******************************/
                    card = CardMethods <TrainCard> .pickAndRemoveCardsFromDeck(deck);

                    player.addCard(card);
                    Program.logboek.WriteLine(string.Format(
                                                  "{0} picked an invisible card, that was a {1} traincard", player.GetName(), card.ToString()));
                    if (!(player is IntelligentPlayer))
                    {
                        MessageBox.Show(string.Format("{0} picked an invisible card, that was a {1} traincard",
                                                      player.GetName(), card.ToString()));
                    }
                    break;

                case (int)Cardoptions.Visible:
                    /******************************
                     * Zichtbare kaart
                     *******************************/
                    Program.logboek.WriteLine("Please type the name of the card you want to pick");
                    bool cardFound = false;
                    while (cardFound == false)
                    {
                        val       = player.ChoseOption(Possibilities.visibleTraincards); // override bij intelligente spelers
                        cardFound = true;

                        if (i == 1 && cardFound)
                        // indien geen geneste if krijg ik een fout omdat het object card --> null (nulreferenceException)
                        {
                            if ((Color)val == Color.Locomotief)
                            // indien het de 2de (sub) beurt is en de gevonden kaart geen locomotief is
                            {
                                Program.logboek.WriteLine("you can't pick an locomotive as a visible card");
                                if (!(player is IntelligentPlayer))
                                {
                                    MessageBox.Show("you can't pick an locomotive as a visible card, in you second turn");
                                    cardFound = false;
                                }
                            }
                        }

                        if (cardFound)
                        {
                            cardFound = false;
                            foreach (TrainCard tCard in visibleDeck)
                            {
                                /******************************
                                 * swapping card form dack
                                 *******************************/
                                if (tCard.getColor() == (Color)val)
                                {
                                    card = CardMethods <TrainCard> .pickAndRemoveCardsFromDeck(visibleDeck, visibleDeck.IndexOf(tCard));

                                    CardMethods <TrainCard> .swapCardFromDeck(deck, visibleDeck);

                                    player.addCard(card);
                                    Program.logboek.WriteLine("valid");
                                    cardFound = true;
                                    Program.form.refreshVisibleTrainCards(visibleDeck);
                                    //Round.Header(visibleDeck, roundNumber, player);
                                    if (tCard.ToString() == Convert.ToString(Color.Locomotief))
                                    {
                                        Locomotive = true;
                                    }
                                    break;     /*sorrynotsorry*/
                                }
                            }
                            if (!cardFound)
                            {
                                Program.logboek.WriteLine("the card you selected isn't available on the visible deck");
                                if (!(player is IntelligentPlayer))
                                {
                                    MessageBox.Show("the card you selected isn't available on the visible deck");
                                }
                            }
                        }
                    }
                    break;
                }
                i++;
            }
            return(true);
        }       // done