title: Visual Basic Simple Card Game. Having problems with coding the scoring process - Beginner
body: <ul>
  <li><em>scroll down to issues section to see my question</em> *</li>
  </ul>
  
  <p><strong>What is my goal here?</strong></p>
  
  <p>I am trying to write a program that will keep score for a simple two-player game (52 cards, four of each of 13 possible names, so no jokers). Jack, Queen, King and Ace are my high cards, with them, one of the two players can score points. Deck must be shuffled (so randomly select from list of cards). Player 1 turns one card first, then player B and so on. Once a card is used, it cannot be reused, so once 52 cards are pulled, the game is over. The game is scored as follows:</p>
  
  <ul>
  <li>if a player turns over an ace, with at least 4 cards remaining to be turned over, and none of the next 4 cards is a high card, that player scores 4 points.</li>
  <li>if a player turns over a king, with at least 3 cards remaining to be turned over, and none of the next 3 cards is a high card, that player scores 3 points.</li>
  <li>if a player turns over a queen, with at least 2 cards remaining to be turned over, and none of the next 2 cards is a high card, that player will score 2 points</li>
  <li>if a player turns over a jack, with at least 1 card remaining to be turned over, and the next card is not a high card, that player scores 1 point</li>
  <li>**note: A players own cards can also overturn a previous high card put down by himself. Say Player 1 pulls a Queen and when it's his turn again he pulls an Ace.  Then instead of scoring 2 points he has to follow the rules for when an Ace is pulled.</li>
  </ul>
  
  <p><strong>What does it look like?</strong>
  <a href="http://i.stack.imgur.com/FvndB.jpg" rel="nofollow">When a player button is clicked, a card name will show up in the corresponding listbox (listbox to the left for player 1 and listbox to the right for player 2). Restart button to restart program. Close button to close the program and the scores will be displayed in the bottom left in the corresponding players' label as the game goes on and a player scores.</a></p>
  
  <p>Example of gameplay:</p>
  
  <ul>
  <li>Player 1 pulls a three</li>
  <li>Player 2 pulls a seven</li>
  <li>Player 1 pulls a queen-------High Card Queen (need 2 non high cards to score 2 points)</li>
  <li>Player 2 pulls a eight</li>
  <li>Player 1 pulls a five-----------Player 1 just scored 2 points!  </li>
  </ul>
  
  <p><strong>What code do I have until now?</strong> </p>
  
  <pre><code>Public Class Form1
  
  'Variable (make a list)
  
  Dim cards As New List(Of String) From {"two", "two", "two", "two", "three", "three", "three", "three", "four", "four", "four", "four", "five", _
                           "five", "five", "five", "six", "six", "six", "six", "seven", "seven", "seven", "seven", "eight", "eight", _
                           "eight", "eight", "nine", "nine", "nine", "nine", "ten", "ten", "ten", "ten", "jack", "jack", "jack", _
                           "jack", "queen", "queen", "queen", "queen", "king", "king", "king", "king", "ace", "ace", "ace", "ace"}
  
  
  'What Happens when button 1 is clicked
  
  Private Sub btnPlayer1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPlayer1.Click
      Dim rnd = New Random()                                       'Set rnd as random generator
      If cards.Count &gt; 0 Then                                      'If all cards have been drawn then no more cards can be drawn
          Dim randomcards = cards(rnd.Next(0, cards.Count))        'Set randomcards as one randomly chosen (using rnd) card from cards list
          lstbox1.Items.Add(randomcards)                           'Add 1 randomly chosen card from cards list into lstbox1 each time btnPlayer1 is clicked
          cards.Remove(randomcards)                                'Remove the randomly generated card from cards list to reduce deck size. No card will be picked more than 4 times
      End If
      lstbox1.TopIndex = lstbox1.Items.Count - 1                   'Automatically scroll down lstbox1 each time new item is added so players only see last played card (can still scroll up to see previous cards)
  End Sub
  
  'What happens when button 2 is clicked
  
  Private Sub btnPlayer2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPlayer2.Click
      Dim rnd = New Random()                                       'Set rnd as random generator
      If cards.Count &gt; 0 Then                                      'If all cards have been drawn then no more cards can be drawn
          Dim randomcards = cards(rnd.Next(0, cards.Count))        'Set randomcards as one randomly chosen (using rnd) card from cards list
          lstbox2.Items.Add(randomcards)                           'Add 1 randomly chosen card from cards list into lstbox2 each time btnPlayer2 is clicked
          cards.Remove(randomcards)                                'Remove the randomly generated card from cards list to reduce deck size. No card will be picked more than 4 times
      End If
      lstbox2.TopIndex = lstbox2.Items.Count - 1                   'Automatically scroll down lstbox2 each time new item is added so players only see last played card (can still scroll up to see previous cards)
  End Sub
  
  'Button to restart program
  
  Private Sub btnRestart_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRestart.Click
      Application.Restart()
  End Sub
  
  'Button to close program
  
  Private Sub btnClose_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnClose.Click
      End
  End Sub
  End Class
  </code></pre>
  
  <p><strong>What issues am I having? (edited out previous issues I was able to resolve)</strong></p>
  
  <ul>
  <li>The issue I am left with is the scoring process. Since I have two list boxes where the left one is where player A's cards will and the right one is where player B's cards will go. So my question is:</li>
  </ul>
  
  <p>How can I retrieve the data/order the cards were drawn in from both listboxes (if drawing order goes A B A B, etc...) and then apply my scoring rules to that
     card order? (unless its not from the listboxes I should be getting my data...?)</p>
  
  <p><strong>Just Starting</strong>
  For your info, I literally just started programming three weeks ago. I'm starting with VB and once I get better I'll move on to Python. I really want to be a game creator in the future so all the programs I've been making have been little games like this (super simple for now). For now I start with a game idea, draw out the looks, set the rules I want the game to follow, and then I code it, respecting the rules I set. This is my most challenging game until now and I've hit a wall. Help is greatly appreciated :) Thank you!</p>