private void ShuffleDecks() { Random random = new Random(Guid.NewGuid().GetHashCode()); List <Card> newDeck1 = new List <Card>(); List <Card> newDeck2 = new List <Card>(); List <Card> newDeck3 = new List <Card>(); int deck1Size = Deck1.Count; int deck2Size = Deck2.Count; int deck3Size = Deck3.Count; for (int i = 0; i < deck1Size; i++) { int max = deck1Size - (i + 1); max = ((max == -1)? 0 : max); int index = random.Next(0, max); newDeck1.Add(Deck1[index]); Deck1.RemoveAt(index); } Deck1 = newDeck1; for (int i = 0; i < deck2Size; i++) { int max = deck2Size - (i + 1); max = ((max == -1) ? 0 : max); int index = random.Next(0, max); newDeck2.Add(Deck2[index]); Deck2.RemoveAt(index); } Deck2 = newDeck2; for (int i = 0; i < deck3Size; i++) { int max = deck3Size - (i + 1); max = ((max == -1) ? 0 : max); int index = random.Next(0, max); newDeck3.Add(Deck3[index]); Deck3.RemoveAt(index); } Deck3 = newDeck3; }
private void initializeDeck() { List <List <int> > intDeck = FileReader.ReadFile(DeckAddress); //Creating Cards and setting them to the decks for (int i = 0; i < intDeck.Count; i++) { Card newCard = new Card(intDeck[i]); if (intDeck[i][1] == 1) { Deck1.Add(newCard); } else if (intDeck[i][1] == 2) { Deck2.Add(newCard); } else if (intDeck[i][1] == 3) { Deck3.Add(newCard); } } //Shuffling Decks ShuffleDecks(); //Turning 4 cards from each deck for (int i = 0; i < 4; i++) { Display1.Add(Deck1[0]); Deck1.RemoveAt(0); Display2.Add(Deck2[0]); Deck2.RemoveAt(0); Display3.Add(Deck3[0]); Deck3.RemoveAt(0); } }
public void replaceDeck1Card(int index) { Display1[index] = Deck1[0]; Deck1.RemoveAt(0); }