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); }
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 through 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'll need // to deal yourself a card from the stock (which was also passed as a parameter), // add you'll have to add a line to the TextBox: "Joe had to draw from the stock" int TotalCount = 0; //int PlayerIndex = 0; this.textBoxOnForm.Text += this.Name + " asks if anyone has a " + value.ToString() + "\r\n"; foreach (Player PlayerToAsk in players) { if (myIndex != players.IndexOf(PlayerToAsk)) { Deck getCards = PlayerToAsk.DoYouHaveAny(value); if (getCards.Count > 0) { TotalCount += getCards.Count; for (int i = getCards.Count; i > 0; i--) { cards.Add(getCards.Deal(i - 1)); } } } } if (TotalCount == 0) { if (stock.Count > 0) { cards.Add(stock.Deal()); } this.textBoxOnForm.Text += this.Name + " had to draw from the stock" + "\r\n"; } }
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; }