Example #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;
 }
Example #2
0
 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;
 }
Example #3
0
 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();
 }
Example #4
0
 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());
     }
 }
Example #5
0
 public void AskForACard(List<Player> players, int myIndex, Deck stock)
 {
     Values randomValue = GetRandomValue();
     AskForACard(players, myIndex, stock, randomValue);
 }