public void ResetDeck(int DeckNum) { if (DeckNum == 1) { int deck1count = deck1.Count; for (int i = deck1count-1; i >= 0; i--) deck1.Deal(i); Deck decktoDeal; List<Card> cardsofDeck1 = new List<Card>(); decktoDeal = new Deck(); Random random = new Random(); int Deck1Count = random.Next(1, 11); for (int i = 0; i < Deck1Count; i++) cardsofDeck1.Add(decktoDeal.Deal(random.Next(decktoDeal.Count))); deck1 = new Deck(cardsofDeck1); deck1.Sort(); RedrawDeck(1); } else { int deck2count = deck2.Count; for (int deck2index = deck2count - 1; deck2index >= 0; deck2index--) deck2.Deal(deck2index); deck2 = new Deck(); deck2.Sort(); RedrawDeck(2); } }
public Form1() { Deck decktoDeal; List<Card> cardsofDeck1 = new List<Card>(); decktoDeal = new Deck(); Random random = new Random(); int Deck1Count = random.Next(1,11); for (int i = 0; i < Deck1Count; i++) cardsofDeck1.Add(decktoDeal.Deal(random.Next(decktoDeal.Count))); deck1 = new Deck(cardsofDeck1); deck1.Sort(); //RedrawDeck(1); deck2 = new Deck(); deck2.Sort(); //RedrawDeck(2); InitializeComponent(); foreach (string cardName in deck1.GetCardName()) listBox1.Items.Add(cardName); label1.Text = "Deck #1(" + deck1.Count + " cards)"; foreach (string cardName in deck2.GetCardName()) listBox2.Items.Add(cardName); label2.Text = "Deck #2(" + deck2.Count + " cards)"; listBox1.SelectedIndex = 0; listBox2.SelectedIndex = 0; }
public void ResetDeck(int DeckNum) { if (DeckNum == 1) { int deck1count = deck1.Count; for (int i = deck1count - 1; i >= 0; i--) { deck1.Deal(i); } Deck decktoDeal; List <Card> cardsofDeck1 = new List <Card>(); decktoDeal = new Deck(); Random random = new Random(); int Deck1Count = random.Next(1, 11); for (int i = 0; i < Deck1Count; i++) { cardsofDeck1.Add(decktoDeal.Deal(random.Next(decktoDeal.Count))); } deck1 = new Deck(cardsofDeck1); deck1.Sort(); RedrawDeck(1); } else { int deck2count = deck2.Count; for (int deck2index = deck2count - 1; deck2index >= 0; deck2index--) { deck2.Deal(deck2index); } deck2 = new Deck(); deck2.Sort(); RedrawDeck(2); } }
private void Button_MoveToDeck2_Click(object sender, EventArgs e) { deck2.Add(deck1.Deal(listBox1.SelectedIndex)); RedrawDeck(1); RedrawDeck(2); }