solitaire_05.py Diff

solitaire_05.py
--- /home/docs/checkouts/readthedocs.org/user_builds/arcade-library/checkouts/2.6.7/doc/tutorials/card_game/solitaire_04.py
+++ /home/docs/checkouts/readthedocs.org/user_builds/arcade-library/checkouts/2.6.7/doc/tutorials/card_game/solitaire_05.py
@@ -177,6 +177,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 = []