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
git checkout dev
git fetch --all
git pull origin dev
git checkout -b class/discoverhandler
Implement your DiscoverHandler in the discoverhandler.py
git add discoverhandler.py
git commit -m "Your commit message here"
git push origin class/discoverhandler
Create a pull request on github from class/discoverhandler -> dev
Set me or Christian as a reviewer.
Handle any review requests as needed.## Implementation Details:
File:
discoverhandler.py
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.
"""
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.
"""
"""
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.
"""
"""
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.
"""
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
git checkout dev
git fetch --all
git pull origin dev
git checkout -b class/discoverhandler
DiscoverHandler
in thediscoverhandler.py
git add discoverhandler.py
git commit -m "Your commit message here"
git push origin class/discoverhandler
class/discoverhandler -> dev
File:
discoverhandler.py
Imports
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
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:random_select_set(self, select_list : list[tuple[str,str,str]]) -> tuple[str,str,str]
random_select_set
Docstring:random_select_type(self, select_list : list[tuple[str, str, str]]) -> tuple[str,str,str]
random_select_type
Docstring: