TelloViz / Card-Collection

Project for CPSC 362 Software Engineering
0 stars 3 forks source link

Create DiscoverHandler Class #128

Closed TelloViz closed 3 weeks ago

TelloViz commented 1 month ago

Create Class called DiscoverHandler

Directions:

Create a class skeleton for the DiscoverHandler class. This class will have a few functions in it so this skeleton will include signatures and docstrings for these functions. The function implementation tasks will be available after this skeleton class task is completed.

Important:

Please follow the details of this document described below.

Git Details

  1. git checkout dev
  2. git fetch --all
  3. git pull origin dev
  4. git checkout -b class/discoverhandler
  5. Implement your DiscoverHandler in the discoverhandler.py
  6. git add discoverhandler.py
  7. git commit -m "Your commit message here"
  8. git push origin class/discoverhandler
  9. Create a pull request on github from class/discoverhandler -> dev
  10. Set me or Christian as a reviewer.
  11. Handle any review requests as needed.## Implementation Details:

File:

discoverhandler.py

Image

Imports

from pokemontcgsdk import Card
from backend import Backend
from cardprocessor import CardProcessor

Note:

We will probably need to import a python RNG library but I will have to look up what to use, I'm sure there is a standard one that is used in python.

Class Docstring

    """
    DiscoverHandler Class:

    Summary:
        The `DiscoverHandler` class provides methods to discover a single random card based on search criteria. 
        The class uses `Backend.fetch_data` to retrieve data and `CardProcessor.process_cards` for data processing.

    Methods:
        handle_discover:
            Returns a single card matching randomized criteria from a list of possible parameters.

        random_select_set:
            Randomly selects a set from the input list of sets.

        random_select_type:
            Randomly selects a type from the input list of types.
    """

Functions:

Please include the following function signatures only.

handle_discover(self, param_list : list[tuple[str,str,str]] -> list[dict[str,str]]

handle_discover Docstring:

    """
    Summary:
        The main function in the `DiscoverHandler` that utilizes the `Backend.fetch_data` function \ 
            `CardProcessor.process_cards` functions, along with its internal `random_select_set` \
            and `random_select_type` functions, in order to return a randomized result back \
            to the calling client in the form of a list[dict[str, str]] \
            that should only contain 1 `Card` object.

    Args:
        self : The self object
        param_list : A list[tuple[str, str, str]] from which to generate a randomized search result.

    Return:
        discover_result : list[dict[str, str]] representing the randomly discovered card. 
            This list actually only has one element  for compatibility purposes it should still be a list.
    """

random_select_set(self, select_list : list[tuple[str,str,str]]) -> tuple[str,str,str]

random_select_set Docstring:

    """
    Summary:
        Randomly selects a set from the provided list of sets.

    Args:
        self : The self object
        select_list : A list[tuple[str, str, str]] representing the available sets to choose from.

    Return:
        A tuple[str, str, str] representing the randomly selected set.
    """

random_select_type(self, select_list : list[tuple[str, str, str]]) -> tuple[str,str,str]

random_select_type Docstring:

    """
    Summary:
        Randomly selects a type from the provided list of types.

    Args:
        self : The self object
        select_list : A list[tuple[str, str, str]] representing the available types to choose from.

    Return:
        A tuple[str, str, str] representing the randomly selected type.
    """