Edgar Vargas

My Portfolio

Python Card Game

Card Class

Created Card class to represent a playing card, which utilizes Pygame. The class contains several key attributes: position, number, suit, rank, and score value. It also includes class level attributes like card_back_image for displaying the card's back. The card's image is updated based on its rank and suit using the update_image method, and its position changes dynamically based on user input.

Deck Creation

Constructs a complete deck of cards, iterating through all possible suits and ranks to instantiate Card objects and adding them to the deck. Dynamically creates card images given a list of ranks and values that then assigns a card image property to the Card object by combining the rank and suit into a filename to load an image of the corresponding card faces from an assets folder. The deal_cards method deals seven cards to the player by popping cards from the deck, positioning them appropriately, updating their table position, and adding them to the game's sprite group for rendering.

Pair Tracking

Used utility methods to implement a dictionary storage method for keeping track of pairs from a given list of cards. The method checks if a current card rank has been seen during a loop and dynamically adds keys for first instances and adds to their values on repeated instances.

Priority List

Implemented a priority list solution where only the highest value hand is returned and displayed to the user, so a three of a kind or pair cant override a full house.

Features

Key functionalities include:

Selection Handling: The card can be selected or deselected by clicking, which moves it to a designated selection area or back to its original position.

Hover Effects: The card moves slightly when the mouse hovers over it to provide a visual indication of interaction.

Image Management: The card's front image is set according to its rank and suit, while the card back image is displayed when appropriate.

Additional Features

Discard Cards: Click the "Discard" button to discard your current hand and draw new cards from the deck.

Submit Hand: Click the "Submit Hand" button to evaluate and score your selected hand.