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; }
public Player(String name, Random random, TextBox textBoxOnForm) { this.name = name; this.random = random; this.textBoxOnForm = textBoxOnForm; this.cards = new Deck(new Card[] { }); textBoxOnForm.Text += name + " has just joined the game" + Environment.NewLine; }
public Game(string playerName, IEnumerable<string> opponentNames, TextBox textBoxOnForm) { Random random = new Random(); this.textBoxOnForm = textBoxOnForm; players = new List<Player>(); players.Add(new Player(playerName, random, textBoxOnForm)); foreach (string player in opponentNames) players.Add(new Player(player, random, textBoxOnForm)); books = new Dictionary<Values, Player>(); stock = new Deck(); Deal(); players[0].SortHand(); }
public void AskForACard(List<Player> players, int myIndex, Deck stock, Values value) { textBoxOnForm.Text += Name + " asks if anyone has a " + value + Environment.NewLine; 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) { textBoxOnForm.Text += Name + " must draw from the stock." + Environment.NewLine; cards.Add(stock.Deal()); } }
public void AskForACard(List<Player> players, int myIndex, Deck stock) { Values randomValue = GetRandomValue(); AskForACard(players, myIndex, stock, randomValue); }