none
Getting to remove a card from an array and rewriting thecards IN ORDER. GO FISH IS THE GAME GO TO ASKING CARD SUB. RRS feed

  • Question

  • 'Got all cards. 
    'next on list - create commands
    
    TextWindow.WriteLine("Getting all Cards")
    Program.Delay(2000)
    Initialize()
    Sub Initialize
      
      deck[1]["name"] = "Ace of Spade"
      deck[2]["name"] = "Ace of Club"
      deck[3]["name"] = "Ace of Diamond"
      deck[4]["name"]= "Ace of Hearts"
      
      deck[5]["name"] = "2 of Spade"
      deck[6]["name"] = "2 of Club"
      deck[7]["name"] = "2 of Diamond"
      deck[8]["name"] = "2 of Hearts"
      
      deck[9]["name"]= "3 of Spade"
      deck[10]["name"] = "3 of Club"
      deck[11]["name"] = "3 of Diamond"
      deck[12]["name"]= "3 of Hearts"
      
      deck[13]["name"]= "4 of Spade"
      deck[14]["name"]= "4 of Club"
      deck[15]["name"] = "4 of Diamond"
      deck[16]["name"] = "4 of Hearts"
      
      deck[17]["name"] = "5 of Spade"
      deck[18]["name"] = "5 of Club"
      deck[19]["name"] = "5 of Diamond"
      deck[20]["name"] = "5 of Hearts"
      
      deck[21]["name"] = "6 of Spade"
      deck[22]["name"] = "6 of Club"
      deck[23]["name"] = "6 of Diamond"
      deck[24]["name"] = "6 of Hearts"
      
      deck[25]["name"] = "7 of Spade"
      deck[26]["name"]= "7 of Club"
      deck[27]["name"] = "7 of Diamond"
      deck[28]["name"]= "7 of Hearts"
      
      deck[29]["name"]= "8 of Spade"
      deck[30]["name"] = "8 of Club"
      deck[31]["name"] = "8 of Diamond"
      deck[32]["name"]= "8 of Hearts"
      
      deck[33]["name"] = "9 of Spade"
      deck[34]["name"] = "9 of Club"
      deck[35]["name"] = "9 of Diamond"
      deck[36]["name"] = "9 of Hearts"
      
      deck[37]["name"]= "10 of Spade"
      deck[38]["name"] = "10 of Club"
      deck[39]["name"] = "10 of Diamond"
      deck[40]["name"] = "10 of Hearts"
      
      
      deck[41]["name"]= "Jack of Spade"
      deck[42]["name"] = "Jack of Club"
      deck[43]["name"]= "Jack of Diamond"
      deck[44]["name"]= "Jack of Hearts"
      
      
      deck[45]["name"] = "Queen of Spade"
      deck[46]["name"] = "Queen of Club"
      deck[47]["name"] = "Queen of Diamond"
      deck[48]["name"] = "Queen of Hearts"
      
      deck[49]["name"] = "King of Spade"
      deck[50]["name"] = "King of Club"
      deck[51]["name"] = "King of Diamond"
      deck[52]["name"]= "King of Hearts"
      For i = 1 To 52 Step 1
        TextWindow.WriteLine(deck[i]["name"])
        'Program.Delay(100)
      EndFor
      
    EndSub
    numberindeck = 52 'number of cards in deck 
    topcard = 1 
    TextWindow.WriteLine("Shuffling Cards...")
    Program.Delay(1000)
    For i = 1 to 52 step 1 
      deck[i]["chosen"] = "False" 'initializer for random
      
    EndFor
    For i = 1 to 52  
      randomize()
      
      
    endfor 
    
    TextWindow.WriteLine("Getting your cards...")
    'getting random cards
    
    
    getcards_player()
    Program.Delay(1000)  
    topcard = 6
    'getting computer card
    TextWindow.WriteLine("Getting computers cards now...")
    TextWindow.WriteLine("")
    getcards_computer()
    Program.Delay(1000)
    While "True"
      askforcard()
      
      
      
      
    endwhile
    
    'now we will display just briefly 
    
    Sub askforcard
      TextWindow.WriteLine("What card would you like to ask for?")
      
      numberofcards = Array.GetItemCount(playerhand)
      For i = 1 To numberofcards Step 1
        TextWindow.WriteLine(playerhand[i]["name"])
      EndFor
      cardwant = TextWindow.ReadNumber()
      
      cardask = playerhand[cardwant]["name"]
      
      For i = 1 To Array.GetItemCount(computerhand) Step 1 'goes through all the computer hand cards
        If cardask = computerhand[i]["name"] Then 'if the card does exist in the computer hand then
          playerhand[inhand+1]["name"] = computerhand[i]["name"] ' add the card to the playerhand
          inhand = inhand+1 'player in hand grows by one
          computerhand[i]["taken"] = "True" 'computer card of that which was chosen is now taken and cant be used
          inhandc = inhandc -1 'computer hand decreases by one
          For checkingcard = 1 To Array.GetItemCount(computerhand) 'this for loops removes the card from the computer...Gives 
            If computerhand[checkingcard]["taken"] = "False" Then
              'add to computerhand
              computerhand[checkingcard]["name"] = computerhand[checkingcard]["name"]
            Else 'if the card is taken then 
              '
            endif
          EndFor
          
          playerhand[inhand+1]["name"] = shuffle[topcard]["name"]
          topcard = topcard +1  
        EndIf
      EndFor 
      
      
    endsub
    
    Sub getcards_player
      endcard = topcard +4
      For topcard = 1 to endcard Step 1
        inhand = topcard
        
        playerhand[inhand]["name"] = shuffle[topcard]["name"]
        TextWindow.WriteLine("Your cards are " +playerhand[inhand]["name"])
        numberindeck = numberindeck - 1
        playerhand[inhand]["taken"] = "False"
        TextWindow.WriteLine("")
      endfor
    EndSub
    
    Sub getcards_computer
      
      endcard = topcard +4 '
      For topcard = topcard To endcard Step 1
        
        inhandc = inhandc+1
        computerhand[inhandc]["name"] = shuffle[topcard]["name"]
        computerhand[inhandc]["taken"] = "False"
        ' TextWindow.WriteLine("computer  cards are " +computerhand[inhandc]["name"])
        ' TextWindow.WriteLine("")
        numberindeck = numberindeck - 1
        
      endfor
    EndSub
    
    
    
    Sub randomize
      
      random_card = Math.GetRandomNumber(52)
      If deck[random_card]["chosen"] = "False" Then
        shuffle[i]["name"] = deck[random_card]["name"] 'first card is the first random card
        deck[random_card]["chosen"] = "True" 'takes out the random card from the list
        TextWindow.WriteLine(shuffle[i]["name"])
        ' Program.Delay(100)
      Else
        randomize()
      endif
      
    endsub

    Monday, February 15, 2016 5:13 PM

Answers

  • here is the fixed version. 
    'Got all cards. 
    'next on list - create commands
    
    TextWindow.WriteLine("Getting all Cards")
    Program.Delay(2000)
    Initialize()
    Sub Initialize
      
      deck[1]["name"] = "Ace"
      deck[2]["name"] = "Ace"
      deck[3]["name"] = "Ace"
      deck[4]["name"]= "Ace"
      
      deck[5]["name"] = "2"
      deck[6]["name"] = "2"
      deck[7]["name"] = "2"
      deck[8]["name"] = "2"
      
      deck[9]["name"]= "3"
      deck[10]["name"] = "3"
      deck[11]["name"] = "3"
      deck[12]["name"]= "3"
      
      deck[13]["name"]= "4"
      deck[14]["name"]= "4"
      deck[15]["name"] = "4"
      deck[16]["name"] = "4"
      
      deck[17]["name"] = "5"
      deck[18]["name"] = "5"
      deck[19]["name"] = "5"
      deck[20]["name"] = "5"
      
      deck[21]["name"] = "6"
      deck[22]["name"] = "6"
      deck[23]["name"] = "6"
      deck[24]["name"] = "6"
      
      deck[25]["name"] = "7"
      deck[26]["name"]= "7"
      deck[27]["name"] = "7"
      deck[28]["name"]= "7"
      
      deck[29]["name"]= "8"
      deck[30]["name"] = "8"
      deck[31]["name"] = "8"
      deck[32]["name"]= "8"
      
      deck[33]["name"] = "9"
      deck[34]["name"] = "9"
      deck[35]["name"] = "9"
      deck[36]["name"] = "9"
      
      deck[37]["name"]= "10"
      deck[38]["name"] = "10"
      deck[39]["name"] = "10"
      deck[40]["name"] = "10"
        
      deck[41]["name"]= "Jack"
      deck[42]["name"] = "Jack"
      deck[43]["name"]= "Jack"
      deck[44]["name"]= "Jack"
      
      
      deck[45]["name"] = "Queen"
      deck[46]["name"] = "Queen"
      deck[47]["name"] = "Queen"
      deck[48]["name"] = "Queen"
      
      deck[49]["name"] = "King"
      deck[50]["name"] = "King"
      deck[51]["name"] = "King"
      deck[52]["name"]= "King"
      For i = 1 To 52 Step 1
        TextWindow.WriteLine(deck[i]["name"])
        'Program.Delay(100)
      EndFor
      
    EndSub
    numberindeck = 52 'number of cards in deck 
    topcard = 1 
    TextWindow.WriteLine("Shuffling Cards...")
    Program.Delay(1000)
    For i = 1 to 52 step 1 
      deck[i]["chosen"] = "False" 'initializer for random
      
    EndFor
    For i = 1 to 52  
      randomize()
      
      
    endfor 
    
    TextWindow.WriteLine("Getting your cards...")
    'getting random cards
    
    
    getcards_player()
    Program.Delay(1000)  
    topcard = 6
    'getting computer card
    TextWindow.WriteLine("Getting computers cards now...")
    TextWindow.WriteLine("")
    getcards_computer()
    Program.Delay(1000)
    While "True"
      askforcard()
      
      
      
      
    endwhile
    
    'now we will display just briefly 
    
    Sub askforcard
      TextWindow.WriteLine("What card would you like to ask for?")
      
      For i = 1 To inhand Step 1
        TextWindow.WriteLine(playerhand[i]["name"])
      EndFor
      cardwant = TextWindow.ReadNumber()
      
      cardask = playerhand[cardwant]["name"]
      foundcard = "False"
      For i = 1 To Array.GetItemCount(computerhand) Step 1 'goes through all the computer hand cards
        If cardask = computerhand[i]["name"] Then 'if the card does exist in the computer hand then
          foundcard = "True"
          playerhand[inhand+1]["name"] = computerhand[i]["name"] ' add the card to the playerhand
          inhand = inhand+1 'player in hand grows by one
          computerhand[i]["taken"] = "True" 'computer card of that which was chosen is now taken and cant be used
          inhandc = inhandc -1 'computer hand decreases by one 
          
          chosen = 1    
         'reorganizing the comuter hand 
          For checkingcard = 1 to Array.GetItemCount(computerhand) 'this for loop goes through all the cards in the computer hand
            
              If computerhand[checkingcard]["taken"] = "False" Then ' if the checking card is not taken then 
                'add to computerhand
                computerhand[chosen]["name"] = computerhand[checkingcard]["name"]
                chosen =chosen +1
                TextWindow.WriteLine("Computer has " + computerhand[chosen]["name"] + " in its hands")
              Else 'if the card is taken then 
                TextWindow.WriteLine("Computer lost " + computerhand[checkingcard]["name"] + " from its hands")
                'do not add to the gotten card. just interate through the for loop
              endif'ends the checking for taken
          
          EndFor 'ends the checking of the cards  
        EndIf'ends to see if card asked is in computerhand card that is being checked
      endfor   'ends the check through all computer hands
      If foundcard = "False" then
        TextWindow.WriteLine("The card you asked for " + playerhand[cardwant]["name"] + "is not in the computer hand card at this moment, checking other cards in computers hand")
        playerhand[inhand+1]["name"] = shuffle[topcard]["name"]
        topcard = topcard +1
        inhand = inhand +1
      Else 
        TextWindow.WriteLine("Your card that you asked for was found. it was added to your hand already")
        TextWindow.WriteLine("your hand has increased to " + inhand)
      endif
      
      For i = 1 To inhandc Step 1
        TextWindow.WriteLine("computer hand now is " + computerhand[i]["name"])
        endfor
    endsub
    
    Sub getcards_player
      endcard = topcard +4
      For topcard = 1 to endcard Step 1
        inhand = topcard
        
        playerhand[inhand]["name"] = shuffle[topcard]["name"]
        TextWindow.WriteLine("Your cards are " +playerhand[inhand]["name"])
        numberindeck = numberindeck - 1
        playerhand[inhand]["taken"] = "False"
        TextWindow.WriteLine("")
      endfor
      
    EndSub
    
    Sub getcards_computer
      
      endcard = topcard +4 '
      For topcard = topcard To endcard Step 1
        
        inhandc = inhandc+1
        computerhand[inhandc]["name"] = shuffle[topcard]["name"]
        computerhand[inhandc]["taken"] = "False"
        TextWindow.WriteLine("computer  cards are " +computerhand[inhandc]["name"])
        TextWindow.WriteLine("")
        numberindeck = numberindeck - 1
        
      endfor
    EndSub
    
    
    
    Sub randomize
      
      random_card = Math.GetRandomNumber(52)
      If deck[random_card]["chosen"] = "False" Then
        shuffle[i]["name"] = deck[random_card]["name"] 'first card is the first random card
        deck[random_card]["chosen"] = "True" 'takes out the random card from the list
        TextWindow.WriteLine(shuffle[i]["name"])
        ' Program.Delay(100)
      Else
        randomize()
      endif
      
    endsub

    Monday, February 15, 2016 6:07 PM

All replies

  • Another IDEA that i have is to move the card taken to the end of the hand and replace the place of where it used to be with the card the taken card took up. EXample. card taken is place 2. move it to the end of the hand. lets say you have 5 cards. the taken card is the fifth card and the card that was in 5 is now the second card. If you have any ideas that would be great
    Monday, February 15, 2016 5:17 PM
  • Fixed the program. Check it. If anyone has any ideas on how do make it better or anyother way to do it plz post the code
    'Got all cards. 
    'next on list - create commands
    
    TextWindow.WriteLine("Getting all Cards")
    Program.Delay(2000)
    Initialize()
    Sub Initialize
      
      deck[1]["name"] = "Ace of Spade"
      deck[2]["name"] = "Ace of Club"
      deck[3]["name"] = "Ace of Diamond"
      deck[4]["name"]= "Ace of Hearts"
      
      deck[5]["name"] = "2 of Spade"
      deck[6]["name"] = "2 of Club"
      deck[7]["name"] = "2 of Diamond"
      deck[8]["name"] = "2 of Hearts"
      
      deck[9]["name"]= "3 of Spade"
      deck[10]["name"] = "3 of Club"
      deck[11]["name"] = "3 of Diamond"
      deck[12]["name"]= "3 of Hearts"
      
      deck[13]["name"]= "4 of Spade"
      deck[14]["name"]= "4 of Club"
      deck[15]["name"] = "4 of Diamond"
      deck[16]["name"] = "4 of Hearts"
      
      deck[17]["name"] = "5 of Spade"
      deck[18]["name"] = "5 of Club"
      deck[19]["name"] = "5 of Diamond"
      deck[20]["name"] = "5 of Hearts"
      
      deck[21]["name"] = "6 of Spade"
      deck[22]["name"] = "6 of Club"
      deck[23]["name"] = "6 of Diamond"
      deck[24]["name"] = "6 of Hearts"
      
      deck[25]["name"] = "7 of Spade"
      deck[26]["name"]= "7 of Club"
      deck[27]["name"] = "7 of Diamond"
      deck[28]["name"]= "7 of Hearts"
      
      deck[29]["name"]= "8 of Spade"
      deck[30]["name"] = "8 of Club"
      deck[31]["name"] = "8 of Diamond"
      deck[32]["name"]= "8 of Hearts"
      
      deck[33]["name"] = "9 of Spade"
      deck[34]["name"] = "9 of Club"
      deck[35]["name"] = "9 of Diamond"
      deck[36]["name"] = "9 of Hearts"
      
      deck[37]["name"]= "10 of Spade"
      deck[38]["name"] = "10 of Club"
      deck[39]["name"] = "10 of Diamond"
      deck[40]["name"] = "10 of Hearts"
      
      
      deck[41]["name"]= "Jack of Spade"
      deck[42]["name"] = "Jack of Club"
      deck[43]["name"]= "Jack of Diamond"
      deck[44]["name"]= "Jack of Hearts"
      
      
      deck[45]["name"] = "Queen of Spade"
      deck[46]["name"] = "Queen of Club"
      deck[47]["name"] = "Queen of Diamond"
      deck[48]["name"] = "Queen of Hearts"
      
      deck[49]["name"] = "King of Spade"
      deck[50]["name"] = "King of Club"
      deck[51]["name"] = "King of Diamond"
      deck[52]["name"]= "King of Hearts"
      For i = 1 To 52 Step 1
        TextWindow.WriteLine(deck[i]["name"])
        'Program.Delay(100)
      EndFor
      
    EndSub
    numberindeck = 52 'number of cards in deck 
    topcard = 1 
    TextWindow.WriteLine("Shuffling Cards...")
    Program.Delay(1000)
    For i = 1 to 52 step 1 
      deck[i]["chosen"] = "False" 'initializer for random
      
    EndFor
    For i = 1 to 52  
      randomize()
      
      
    endfor 
    
    TextWindow.WriteLine("Getting your cards...")
    'getting random cards
    
    
    getcards_player()
    Program.Delay(1000)  
    topcard = 6
    'getting computer card
    TextWindow.WriteLine("Getting computers cards now...")
    TextWindow.WriteLine("")
    getcards_computer()
    Program.Delay(1000)
    While "True"
      askforcard()
      
      
      
      
    endwhile
    
    'now we will display just briefly 
    
    Sub askforcard
      TextWindow.WriteLine("What card would you like to ask for?")
      
      
      For i = 1 To inhand Step 1
        TextWindow.WriteLine(playerhand[i]["name"])
      EndFor
      cardwant = TextWindow.ReadNumber()
      
      cardask = playerhand[cardwant]["name"]
      foundcard = "False"
      For i = 1 To Array.GetItemCount(computerhand) Step 1 'goes through all the computer hand cards
        If cardask = computerhand[i]["name"] Then 'if the card does exist in the computer hand then
          foundcard = "True"
          playerhand[inhand+1]["name"] = computerhand[i]["name"] ' add the card to the playerhand
          inhand = inhand+1 'player in hand grows by one
          computerhand[i]["taken"] = "True" 'computer card of that which was chosen is now taken and cant be used
          inhandc = inhandc -1 'computer hand decreases by one 
          
          chosen = 1    
          
          For checkingcard = 1 to Array.GetItemCount(computerhand) 'this for loop goes through all the cards in the computer hand
            If chosen <> inhandc Then 'if all the gotten cards do not equal the amount needed then go thorugh the checking cards
              If computerhand[checkingcard]["taken"] = "False" Then
                'add to computerhand
                computerhand[chosen]["name"] = computerhand[checkingcard]["name"]
                chosen =chosen +1
              Else 'if the card is taken then 
                'do not add to the gotten card. just interate through the for loop
              endif'ends the checking for taken
            EndIf  'ends the if chosen<>inhandc
          EndFor 'ends the checking of the cards  
        EndIf'ends to see if card asked is in computerhand card that is being checked
      endfor   'ends the check through all computer hands
      If foundcard = "False" then
        TextWindow.WriteLine("The card you asked for " + playerhand[cardwant]["name"] + "is not in the computer hand card at this moment, checking other cards in computers hand")
        playerhand[inhand+1]["name"] = shuffle[topcard]["name"]
        topcard = topcard +1
        inhand = inhand +1
      Else 
        TextWindow.WriteLine("Your card that you asked for was found. it was added to your hand already")
      endif
    endsub
    
    Sub getcards_player
      endcard = topcard +4
      For topcard = 1 to endcard Step 1
        inhand = topcard
        
        playerhand[inhand]["name"] = shuffle[topcard]["name"]
        TextWindow.WriteLine("Your cards are " +playerhand[inhand]["name"])
        numberindeck = numberindeck - 1
        playerhand[inhand]["taken"] = "False"
        TextWindow.WriteLine("")
      endfor
    EndSub
    
    Sub getcards_computer
      
      endcard = topcard +4 '
      For topcard = topcard To endcard Step 1
        
        inhandc = inhandc+1
        computerhand[inhandc]["name"] = shuffle[topcard]["name"]
        computerhand[inhandc]["taken"] = "False"
        TextWindow.WriteLine("computer  cards are " +computerhand[inhandc]["name"])
        TextWindow.WriteLine("")
        numberindeck = numberindeck - 1
        
      endfor
    EndSub
    
    
    
    Sub randomize
      
      random_card = Math.GetRandomNumber(52)
      If deck[random_card]["chosen"] = "False" Then
        shuffle[i]["name"] = deck[random_card]["name"] 'first card is the first random card
        deck[random_card]["chosen"] = "True" 'takes out the random card from the list
        TextWindow.WriteLine(shuffle[i]["name"])
        ' Program.Delay(100)
      Else
        randomize()
      endif
      
    endsub

    Monday, February 15, 2016 5:47 PM
  • fail. im asking for a card number and suit. in go fish suit doesnt matter. gonna fix that really quick.
    Monday, February 15, 2016 5:52 PM
  • here is the fixed version. 
    'Got all cards. 
    'next on list - create commands
    
    TextWindow.WriteLine("Getting all Cards")
    Program.Delay(2000)
    Initialize()
    Sub Initialize
      
      deck[1]["name"] = "Ace"
      deck[2]["name"] = "Ace"
      deck[3]["name"] = "Ace"
      deck[4]["name"]= "Ace"
      
      deck[5]["name"] = "2"
      deck[6]["name"] = "2"
      deck[7]["name"] = "2"
      deck[8]["name"] = "2"
      
      deck[9]["name"]= "3"
      deck[10]["name"] = "3"
      deck[11]["name"] = "3"
      deck[12]["name"]= "3"
      
      deck[13]["name"]= "4"
      deck[14]["name"]= "4"
      deck[15]["name"] = "4"
      deck[16]["name"] = "4"
      
      deck[17]["name"] = "5"
      deck[18]["name"] = "5"
      deck[19]["name"] = "5"
      deck[20]["name"] = "5"
      
      deck[21]["name"] = "6"
      deck[22]["name"] = "6"
      deck[23]["name"] = "6"
      deck[24]["name"] = "6"
      
      deck[25]["name"] = "7"
      deck[26]["name"]= "7"
      deck[27]["name"] = "7"
      deck[28]["name"]= "7"
      
      deck[29]["name"]= "8"
      deck[30]["name"] = "8"
      deck[31]["name"] = "8"
      deck[32]["name"]= "8"
      
      deck[33]["name"] = "9"
      deck[34]["name"] = "9"
      deck[35]["name"] = "9"
      deck[36]["name"] = "9"
      
      deck[37]["name"]= "10"
      deck[38]["name"] = "10"
      deck[39]["name"] = "10"
      deck[40]["name"] = "10"
        
      deck[41]["name"]= "Jack"
      deck[42]["name"] = "Jack"
      deck[43]["name"]= "Jack"
      deck[44]["name"]= "Jack"
      
      
      deck[45]["name"] = "Queen"
      deck[46]["name"] = "Queen"
      deck[47]["name"] = "Queen"
      deck[48]["name"] = "Queen"
      
      deck[49]["name"] = "King"
      deck[50]["name"] = "King"
      deck[51]["name"] = "King"
      deck[52]["name"]= "King"
      For i = 1 To 52 Step 1
        TextWindow.WriteLine(deck[i]["name"])
        'Program.Delay(100)
      EndFor
      
    EndSub
    numberindeck = 52 'number of cards in deck 
    topcard = 1 
    TextWindow.WriteLine("Shuffling Cards...")
    Program.Delay(1000)
    For i = 1 to 52 step 1 
      deck[i]["chosen"] = "False" 'initializer for random
      
    EndFor
    For i = 1 to 52  
      randomize()
      
      
    endfor 
    
    TextWindow.WriteLine("Getting your cards...")
    'getting random cards
    
    
    getcards_player()
    Program.Delay(1000)  
    topcard = 6
    'getting computer card
    TextWindow.WriteLine("Getting computers cards now...")
    TextWindow.WriteLine("")
    getcards_computer()
    Program.Delay(1000)
    While "True"
      askforcard()
      
      
      
      
    endwhile
    
    'now we will display just briefly 
    
    Sub askforcard
      TextWindow.WriteLine("What card would you like to ask for?")
      
      For i = 1 To inhand Step 1
        TextWindow.WriteLine(playerhand[i]["name"])
      EndFor
      cardwant = TextWindow.ReadNumber()
      
      cardask = playerhand[cardwant]["name"]
      foundcard = "False"
      For i = 1 To Array.GetItemCount(computerhand) Step 1 'goes through all the computer hand cards
        If cardask = computerhand[i]["name"] Then 'if the card does exist in the computer hand then
          foundcard = "True"
          playerhand[inhand+1]["name"] = computerhand[i]["name"] ' add the card to the playerhand
          inhand = inhand+1 'player in hand grows by one
          computerhand[i]["taken"] = "True" 'computer card of that which was chosen is now taken and cant be used
          inhandc = inhandc -1 'computer hand decreases by one 
          
          chosen = 1    
         'reorganizing the comuter hand 
          For checkingcard = 1 to Array.GetItemCount(computerhand) 'this for loop goes through all the cards in the computer hand
            
              If computerhand[checkingcard]["taken"] = "False" Then ' if the checking card is not taken then 
                'add to computerhand
                computerhand[chosen]["name"] = computerhand[checkingcard]["name"]
                chosen =chosen +1
                TextWindow.WriteLine("Computer has " + computerhand[chosen]["name"] + " in its hands")
              Else 'if the card is taken then 
                TextWindow.WriteLine("Computer lost " + computerhand[checkingcard]["name"] + " from its hands")
                'do not add to the gotten card. just interate through the for loop
              endif'ends the checking for taken
          
          EndFor 'ends the checking of the cards  
        EndIf'ends to see if card asked is in computerhand card that is being checked
      endfor   'ends the check through all computer hands
      If foundcard = "False" then
        TextWindow.WriteLine("The card you asked for " + playerhand[cardwant]["name"] + "is not in the computer hand card at this moment, checking other cards in computers hand")
        playerhand[inhand+1]["name"] = shuffle[topcard]["name"]
        topcard = topcard +1
        inhand = inhand +1
      Else 
        TextWindow.WriteLine("Your card that you asked for was found. it was added to your hand already")
        TextWindow.WriteLine("your hand has increased to " + inhand)
      endif
      
      For i = 1 To inhandc Step 1
        TextWindow.WriteLine("computer hand now is " + computerhand[i]["name"])
        endfor
    endsub
    
    Sub getcards_player
      endcard = topcard +4
      For topcard = 1 to endcard Step 1
        inhand = topcard
        
        playerhand[inhand]["name"] = shuffle[topcard]["name"]
        TextWindow.WriteLine("Your cards are " +playerhand[inhand]["name"])
        numberindeck = numberindeck - 1
        playerhand[inhand]["taken"] = "False"
        TextWindow.WriteLine("")
      endfor
      
    EndSub
    
    Sub getcards_computer
      
      endcard = topcard +4 '
      For topcard = topcard To endcard Step 1
        
        inhandc = inhandc+1
        computerhand[inhandc]["name"] = shuffle[topcard]["name"]
        computerhand[inhandc]["taken"] = "False"
        TextWindow.WriteLine("computer  cards are " +computerhand[inhandc]["name"])
        TextWindow.WriteLine("")
        numberindeck = numberindeck - 1
        
      endfor
    EndSub
    
    
    
    Sub randomize
      
      random_card = Math.GetRandomNumber(52)
      If deck[random_card]["chosen"] = "False" Then
        shuffle[i]["name"] = deck[random_card]["name"] 'first card is the first random card
        deck[random_card]["chosen"] = "True" 'takes out the random card from the list
        TextWindow.WriteLine(shuffle[i]["name"])
        ' Program.Delay(100)
      Else
        randomize()
      endif
      
    endsub

    Monday, February 15, 2016 6:07 PM