-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Command engine rework into master!
- Loading branch information
Showing
19 changed files
with
445 additions
and
468 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ import sys | |
from pokemonterminal.main import main | ||
|
||
|
||
main(sys.argv) | ||
main(sys.argv[1:]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
from argparse import Action | ||
from pokemonterminal.database import Database, Pokemon | ||
|
||
|
||
class Filter(Action): | ||
POKEMON_LIST = Database().get_all() | ||
filtered_list = [p for p in POKEMON_LIST] | ||
FILTERS = [] | ||
EXAMPLE_VAL = None | ||
|
||
def matches(self, pokemon, value): | ||
raise NotImplementedError | ||
|
||
def __init_subclass__(cls, **kwargs): | ||
Filter.FILTERS.append(cls) | ||
|
||
def __call__(self, parser, namespace, value, option_string=None): | ||
Filter.filtered_list = [pkmn for pkmn in Filter.filtered_list | ||
if self.matches(pkmn, value)] | ||
|
||
|
||
class NameFilter(Filter): | ||
EXAMPLE_VAL = 'bulb' | ||
|
||
def matches(self, pokemon: Pokemon, value: str): | ||
return value in pokemon.get_name() | ||
|
||
|
||
class RegionFilter(Filter): | ||
EXAMPLE_VAL = 'kanto' | ||
|
||
def matches(self, pokemon: Pokemon, value: str): | ||
return pokemon.get_region() == value | ||
|
||
|
||
class LightFilter(Filter): | ||
EXAMPLE_VAL = 0.7 | ||
|
||
def matches(self, pokemon: Pokemon, value: float): | ||
return pokemon.get_dark_threshold() > value | ||
|
||
|
||
class DarkFilter(Filter): | ||
EXAMPLE_VAL = 0.4 | ||
|
||
def matches(self, pokemon: Pokemon, value: float): | ||
return pokemon.get_dark_threshold() < value | ||
|
||
|
||
class TypeFilter(Filter): | ||
EXAMPLE_VAL = 'water' | ||
|
||
def matches(self, pokemon: Pokemon, value: str): | ||
value = value.lower() | ||
return value in (pokemon.get_pkmn_type(), | ||
pokemon.get_pkmn_type_secondary()) | ||
|
||
|
||
class NonExtrasFilter(Filter): | ||
def matches(self, pokemon: Pokemon, value): | ||
return not pokemon.is_extra() | ||
|
||
|
||
class ExtrasFilter(Filter): | ||
def matches(self, pokemon: Pokemon, value): | ||
return pokemon.is_extra() |
Oops, something went wrong.