Skip to content

Commit

Permalink
POK-172 Fix well known battling bugs (#13)
Browse files Browse the repository at this point in the history
* Fix POK-141: 'Never misses' moves always missing
* Fix POK-156: Shadow type pokemon breaking battle
  • Loading branch information
WitherredAway authored Oct 6, 2023
1 parent 35caa1b commit 55ee6a1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
11 changes: 8 additions & 3 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,18 +237,23 @@ def get_moves(instance):
stat_changes = meta_stats.get(row["id"], [])
stat_changes = [models.StatChange(**x) for x in stat_changes]

effect_id = row["effect_id"]
accuracy = row.get("accuracy", None)
if "never misses" in instance.effects[effect_id].description.lower():
accuracy = 100

moves[row["id"]] = models.Move(
id=row["id"],
slug=row["identifier"],
name=names[row["id"]],
power=row.get("power", None),
pp=row["pp"],
accuracy=row.get("accuracy", None),
accuracy=accuracy,
priority=row["priority"],
type_id=row["type_id"],
target_id=row["target_id"],
damage_class_id=row["damage_class_id"],
effect_id=row["effect_id"],
effect_id=effect_id,
effect_chance=row.get("effect_chance", None),
instance=instance,
meta=models.MoveMeta(**mmeta, stat_changes=stat_changes),
Expand All @@ -259,10 +264,10 @@ def get_moves(instance):

class DataManager(models.DataManagerBase):
def __init__(self, assets_base_url=None):
self.effects = get_effects(self)
self.moves = get_moves(self)
self.pokemon = get_pokemon(self)
self.items = get_items(self)
self.effects = get_effects(self)

if assets_base_url is not None:
self.assets_base_url = assets_base_url
Expand Down
5 changes: 4 additions & 1 deletion models.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@ def calculate_turn(self, pokemon, opponent):

typ_mult = 1
for typ in opponent.species.types:
typ_mult *= constants.TYPE_EFFICACY[self.type_id][constants.TYPES.index(typ)]
try:
typ_mult *= constants.TYPE_EFFICACY[self.type_id][constants.TYPES.index(typ)]
except IndexError: # Type does not exist in the TYPE_EFFICACY list. Such as the Shadow type.
pass

damage *= typ_mult
messages = []
Expand Down

0 comments on commit 55ee6a1

Please sign in to comment.