solitaire_05.py Diff

solitaire_05.py
--- C:\Users\craven\Desktop\WebServer\arcade\doc\tutorials\card_game\solitaire_04.py
+++ C:\Users\craven\Desktop\WebServer\arcade\doc\tutorials\card_game\solitaire_05.py
@@ -175,6 +175,28 @@
         if len(self.held_cards) == 0:
             return
 
+        # Find the closest pile, in case we are in contact with more than one
+        pile, distance = arcade.get_closest_sprite(self.held_cards[0], self.pile_mat_list)
+        reset_position = True
+
+        # See if we are in contact with the closest pile
+        if arcade.check_for_collision(self.held_cards[0], pile):
+
+            # For each held card, move it to the pile we dropped on
+            for i, dropped_card in enumerate(self.held_cards):
+                # Move cards to proper position
+                dropped_card.position = pile.center_x, pile.center_y
+
+            # Success, don't reset position of cards
+            reset_position = False
+
+            # Release on top play pile? And only one card held?
+        if reset_position:
+            # Where-ever we were dropped, it wasn't valid. Reset the each card's position
+            # to its original spot.
+            for pile_index, card in enumerate(self.held_cards):
+                card.position = self.held_cards_original_position[pile_index]
+
         # We are no longer holding cards
         self.held_cards = []