So I have made a simple Windows Form that creates a deck of cards and has a button that shuffles cards and displays them in to 52 text boxes. I am trying to figure out how to assign these cards to a certain player, such as text box 1-13 would be player 1, and then to compare the cards and put them in numerical order. I don't really know how to start doing this as this is my first card game.
In addition to the code I have below, I have:
TextBox[] boxes;
Random r = new Random();
string[] cards (contains all possible values i.e. "A♠" or "3♣")
Here is my current buttonClick:
private void button1_Click(object sender, EventArgs e) { int cardCount = cards.Length; int[] cardIndexList = new int[cardCount]; for (int i = 0; i < cardCount; i++) { cardIndexList[i] = i; } foreach (TextBox box in boxes) { int cardIndex = r.Next(cardCount); string card = cards[cardIndexList[cardIndex]]; cardCount--; cardIndexList[cardIndex] = cardIndexList[cardCount]; box.Text = card; box.ForeColor = (card.Contains("♥") || card.Contains("♦")) ? Color.Red : Color.Black; } }
Also, eventually I will be changing the text boxes to picture boxes. Is there a good time to do that, such as now? How much difficulty is involved in that?