示例#1
0
 public Deck PullOutValues(Values value)
 {
     Deck deckToReturn = new Deck(new Card[] { });
     for (int i = cards.Count - 1; i >= 0; i--)
         if (cards[i].Value == value)
             deckToReturn.Add(Deal(i));
     return deckToReturn;
 }
示例#2
0
        public Deck PullOutValues(Values value)
        {
            Deck deck = new Deck(new Card[] { });

            for (int i = cards.Count - 1; i >= 0; i--)
            {
                if (cards[i].Value == value)
                {
                    deck.Add(Deal(i));
                }
            }
            return(deck);
        }
示例#3
0
        public void AskForACard(IEnumerable <Player> players, int myIndex, Deck stock)
        {
            List <Player> _players = (List <Player>)players;

            // Round is only played if the stock still has cards.
            if (stock.Count > 0)
            {
                // Player asking must have at least one card.'Player asking must have at least one card.
                if (cards.Count == 0)
                {
                    cards.Add(stock.Deal());
                }
                AskForACard(players, myIndex, stock, GetRandomValue());

                // As long as the stock still has cards after the last move, if the human player must have at least one card.
                // This is needed for the next round to be started. Cases of the AIs running out of cards is handled when they are asking for cards, above.
                if (stock.Count > 0 && _players[0].CardCount == 0)
                {
                    _players[0].cards.Add(stock.Deal());
                }
            }
        }
示例#4
0
文件: Deck.cs 项目: Stephani92/GoFish
        public Deck PullOutValue(Values value)
        {
            Deck deckToReturn = new Deck();

            for (int i = cards.Count - 1; i > 0; i--)
            {
                if (cards[i].Value == value)
                {
                    deckToReturn.Add(Deal(i));
                }
            }
            return(deckToReturn);
        }
示例#5
0
        /// <summary>
        /// Procura por qualquer carta com determinado valor e tira-as do baralho.
        /// </summary>
        /// <param name="value">Valor da carta</param>
        /// <returns>Retorna um baralho novo sem aquelas cartas.</returns>
        public Deck PullOutValues(Card.Values value)
        {
            var deckToReturn = new Deck(Array.Empty <Card>());

            for (int i = _cards.Count - 1; i >= 0; i--)
            {
                if (_cards[i].Value == value)
                {
                    deckToReturn.Add(Deal(i));
                }
            }
            return(deckToReturn);
        }
示例#6
0
        /// <summary>
        /// Looks for any card that match the requested value,
        /// pulls them out of the deck and returns a new deck with those cards in it.
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public Deck PullOutValues(Value value)
        {
            Deck deckToReturn = new Deck(new Card[] {});

            for (int i = _cards.Count - 1; i >= 0; i--)
            {
                if (_cards[i].Value == value)
                {
                    deckToReturn.Add(Deal(i));
                }
            }

            return(deckToReturn);
        }
示例#7
0
        public void AskForACard(List <Player> players, int myIndex, Deck stock, Values value)
        {
            game.AddProgress(Name + " asks if anyone has a " + value);
            int totalCardsGiven = 0;

            for (int i = 0; i < players.Count; i++)
            {
                if (i != myIndex)
                {
                    Player player     = players[i];
                    Deck   CardsGiven = player.DoYouHaveAny(value);
                    totalCardsGiven += CardsGiven.Count;
                    while (CardsGiven.Count > 0)
                    {
                        cards.Add(CardsGiven.Deal());
                    }
                }
            }
            if (totalCardsGiven == 0)
            {
                game.AddProgress(Name + " must draw from the stock.");
                cards.Add(stock.Deal());
            }
        }
示例#8
0
        public void AskForACard(List <Player> players, int myIndex, Deck stock, Value value)
        {
            /* Ask the other players for a value.  First add a line to the TextBox: "Joe asks
             * if anyone has a Queen". Then go therough the list of players that was passed in
             * as a parameter and ask each player if he has any of the value (using his
             * DoYouHaveAny() method.  He'll pass you a deck of cards - add them to my deck.
             * Keep track of how many cards were added. If there weren't any, you need to deal
             * yourself a card from the stock (which was also passed as a parameter),
             * and you'll have to add a line to the TextBox: "Joe had to draw from the stock"
             */
            textBoxOnForm.Text += Name + " asks if anyone has a " + value + Environment.NewLine;
            int myCount = cards.Count;

            for (int i = 0; i < players.Count; i++)
            {
                if (i != myIndex)
                {
                    Deck found = players[i].DoYouHaveAny(value);
                    if (found.Count > 0)
                    {
                        for (int j = 0; j < found.Count; j++)
                        {
                            cards.Add(found.Deal());
                        }
                    }
                }
            }
            if (cards.Count == myCount)
            {
                if (stock.Count > 0)
                {
                    cards.Add(stock.Deal());
                    textBoxOnForm.Text += Name + " had to draw a card" + Environment.NewLine;
                }
            }
        }
示例#9
0
文件: Player.cs 项目: haosmark/GoFish
 public void TakeCard(Card card)
 {
     cards.Add(card);
 }
示例#10
0
文件: Deck.cs 项目: robertjorg/Ch8
 public Deck PullOutValues(Value value)
 {
     Deck deckToReturn = new Deck(new Card[] { });
     for (int i = this.cards.Count - 1; i >= 0; i--)
     {
         if (this.cards[i].Value == value)
         {
             deckToReturn.Add(this.Deal(i));
         }
     }
     return deckToReturn;
 }
示例#11
0
 public void takeCard(Cards cards)
 {
     deck.Add(cards);
 }