On 8/2/2013 10:24 PM, kevin4f...@gmail.com wrote:

Looking at this again, I believe you actually had the structure almost right before. You want to look through *all* of the target players cards and if *none* of them match, (ie the search fails), you want to draw 1 card. What you were missing before is break or return

def player_0_hitman(hit):
     for card in pHands[target_player]:
         if target_card[0] == card[0]:
             count = pHands[target_player].count(card)
             pHands[0].append(card)
             pHands[target_player].remove(card)
             ShowMessage("HIT: " + str(count) + " card(s) transferred")
             return True

      # else: needed if just break above, but not with return
                
      top_card = GetTopCard(sDeck)
      pHands[0].append(top_card)
      if top_card[0] == target_card[0]:
ShowMessage("HIT: LUCKILY Player 0 has fished up a rank <" + str(top_card[0]) + ">!!!")
          return True
       else:
ShowMessage("MISS: You fished up the rank <" + str(top_card[0]) + ">")
           hit = hit - 1
           return False

The returns are based on what I remember of the rules from decades ago, that a hit either in the hand or the draw allowed another turn by the player.

--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to