Skip to content

Commit

Permalink
Have get queries return root name
Browse files Browse the repository at this point in the history
  • Loading branch information
ExcaliburZero committed Oct 7, 2023
1 parent 0e6e52e commit 0046bf0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
16 changes: 10 additions & 6 deletions cbpickaxe/hoylake.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,27 +262,31 @@ def get_locales(self) -> Set[str]:
"""
return set(self.__translation_tables.keys())

def get_monster_forms_by_tags(self, tags: Iterable[str]) -> Dict[str, MonsterForm]:
def get_monster_forms_by_tags(
self, tags: Iterable[str]
) -> Dict[str, Tuple[RootName, MonsterForm]]:
"""
Returns all of the monster forms that have any of the given tags.
"""
monster_forms = {}
for tag in tags:
for path, (_, monster_form) in self.__monster_forms.items():
for path, (root_name, monster_form) in self.__monster_forms.items():
if tag in monster_form.move_tags:
monster_forms[f"res://{path}"] = monster_form
monster_forms[f"res://{path}"] = (root_name, monster_form)

return monster_forms

def get_moves_by_tags(self, tags: Iterable[str]) -> Dict[str, Move]:
def get_moves_by_tags(
self, tags: Iterable[str]
) -> Dict[str, Tuple[RootName, Move]]:
"""
Returns all of the moves that have any of the given tags.
"""
moves = {}
for tag in tags:
for path, (_, move) in self.__moves.items():
for path, (root_name, move) in self.__moves.items():
if tag in move.tags:
moves[f"res://{path}"] = move
moves[f"res://{path}"] = (root_name, move)

return moves

Expand Down
2 changes: 1 addition & 1 deletion cbpickaxe_scripts/generate_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def create_monster_form_page(
if move.is_passive_only
else f"{move.cost} AP",
}
for path, move in compatible_moves.items()
for path, (_, move) in compatible_moves.items()
],
key=lambda m: m["name"],
),
Expand Down
7 changes: 5 additions & 2 deletions cbpickaxe_scripts/get_move_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ def main(argv: List[str]) -> int:
for _, move in hoylake.load_moves(moves_path).items():
users = [
hoylake.translate(monster_form.name)
for _, monster_form in sorted(
for _, (_, monster_form) in sorted(
hoylake.get_monster_forms_by_tags(move[1].tags).items(),
key=lambda d: (d[1].bestiary_index, hoylake.translate(d[1].name)),
key=lambda d: (
d[1][1].bestiary_index,
hoylake.translate(d[1][1].name),
),
)
]
writer.writerow(
Expand Down
4 changes: 2 additions & 2 deletions misc_scripts/try_hoylake.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def main(argv: List[str]) -> int:
_ = hoylake.load_monster_forms("res://data/monster_forms_secret/")

move = hoylake.load_move("res://data/battle_moves/carnivore.tres")[1]
for path, monster_form in hoylake.get_monster_forms_by_tags(move.tags).items():
for path, (_, monster_form) in hoylake.get_monster_forms_by_tags(move.tags).items():
print(path, monster_form)

print("==========================")
Expand All @@ -41,7 +41,7 @@ def main(argv: List[str]) -> int:
monster_form = hoylake.load_monster_form(
"res://data/monster_forms/shining_kuneko.tres"
)[1]
for path, move in hoylake.get_moves_by_tags(monster_form.move_tags).items():
for path, (_, move) in hoylake.get_moves_by_tags(monster_form.move_tags).items():
print(path, move)

print(len(hoylake.get_moves_by_tags(monster_form.move_tags + ["any"])))
Expand Down

0 comments on commit 0046bf0

Please sign in to comment.