示例#1
0
文件: Actions.cs 项目: jonasvdd/T2R
        public static bool PickNormDestinationCard(List <NormDestCard> destinationcard, Player player)
        {
            NormDestCard card = CardMethods <AbstrDestCard> .pickAndRemoveCardsFromDeck(destinationcard);

            player.addCard(card);
            Program.logboek.WriteLine(player.GetName() + " picked:\t" + card.ToString());
            if (!(player is IntelligentPlayer))
            {
                MessageBox.Show(string.Format("You picked:\n\t" + card.ToString()));
            }
            return(true);
        }   // ez done
示例#2
0
文件: Actions.cs 项目: jonasvdd/T2R
        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