Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented avoided pokemon #508

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
29 changes: 29 additions & 0 deletions modules/encounter.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,25 @@ class EncounterValue(Enum):
RoamerOnBlockList = auto()
CustomFilterMatch = auto()
Trash = auto()
AvoidedPokemon = auto()

def __init__(self, avoid = False):
self._avoid = avoid
orchi marked this conversation as resolved.
Show resolved Hide resolved

@property
def is_of_interest(self):
return self in (EncounterValue.Shiny, EncounterValue.CustomFilterMatch)

@property
def avoid(self):
return self._avoid

@avoid.setter
def avoid(self, avoid: "bool"):
if not isinstance(self,bool):
raise ValueError("avoid must be True or False")
self._avoid = avoid
orchi marked this conversation as resolved.
Show resolved Hide resolved


def judge_encounter(pokemon: "Pokemon") -> EncounterValue:
"""
Expand All @@ -120,6 +134,9 @@ def judge_encounter(pokemon: "Pokemon") -> EncounterValue:
if run_custom_catch_filters(pokemon) is not False:
return EncounterValue.CustomFilterMatch

if pokemon.species.name in context.config.battle.avoided_pokemon:
return EncounterValue.AvoidedPokemon

roamer = get_roamer()
if (
roamer is not None
Expand Down Expand Up @@ -212,6 +229,12 @@ def handle_encounter(
save_pk3(pokemon)
is_of_interest = True

case EncounterValue.AvoidedPokemon:
console.print(f"Attempting to avoid {pokemon.species.name} because it is on avoided list")
EncounterValue.avoid = True
alert = None
is_of_interest = False

orchi marked this conversation as resolved.
Show resolved Hide resolved
case EncounterValue.Roamer:
console.print(f"[pink yellow]Roaming {pokemon.species.name} found![/]")
alert = "Roaming Pokémon found!", f"Encountered a roaming {pokemon.species.name}."
Expand Down Expand Up @@ -261,6 +284,12 @@ def handle_encounter(
else:
context.set_manual_mode()
encounter_info.battle_action = BattleAction.CustomAction

elif EncounterValue.avoid == True:
orchi marked this conversation as resolved.
Show resolved Hide resolved
#I can't get the EncounterValue.avoid to automatically assign itself False, so checking if it is equal to True is necessary
orchi marked this conversation as resolved.
Show resolved Hide resolved
encounter_info.battle_action = BattleAction.RunAway
EncounterValue.avoid = False
orchi marked this conversation as resolved.
Show resolved Hide resolved

elif enable_auto_battle:
encounter_info.battle_action = BattleAction.Fight
else:
Expand Down