Skip to content

Commit

Permalink
Have moves link to wiki page
Browse files Browse the repository at this point in the history
  • Loading branch information
ExcaliburZero committed Oct 7, 2023
1 parent 729a308 commit 61566dc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
21 changes: 17 additions & 4 deletions cbpickaxe_scripts/generate_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
TEMPLATES_DIR = SOURCE_DIR / "templates"
MONSTER_FORM_TEMPLATE = TEMPLATES_DIR / "monster_form.html.template"

OFFICIAL_ROOT_NAME = "cassette_beasts"
OFFICIAL_MONSTER_FORM_PATHS = [
"res://data/monster_forms/",
"res://data/monster_forms_secret/",
Expand Down Expand Up @@ -90,8 +91,8 @@ def from_dict(d: Dict[str, Any]) -> "Config":
assert isinstance(monster_forms_entry, dict)
assert isinstance(moves_entry, dict)

if "cassette_beasts" not in roots:
logging.error('roots must contain "cassette_beasts"')
if OFFICIAL_ROOT_NAME not in roots:
logging.error(f'roots must contain "{OFFICIAL_ROOT_NAME}"')
raise ValueError()

monster_forms = MonsterForms.from_dict(monster_forms_entry)
Expand Down Expand Up @@ -149,7 +150,10 @@ def main(argv: List[str]) -> int:
monster_form_images_dir.mkdir()

for monster_path, (root_name, monster_form) in monster_forms.items():
if not config.monster_forms.include_official and root_name == "cassette_beasts":
if (
not config.monster_forms.include_official
and root_name == OFFICIAL_ROOT_NAME
):
continue

monster_page_filepath = monster_forms_dir / (
Expand All @@ -169,6 +173,14 @@ def main(argv: List[str]) -> int:
return SUCCESS


def get_move_link(hoylake: cbp.Hoylake, root_name: str, move: cbp.Move) -> str:
if root_name == OFFICIAL_ROOT_NAME:
move_name = hoylake.translate(move.name)
return f"https://wiki.cassettebeasts.com/wiki/{move_name.replace(' ', '_')}"

raise NotImplementedError()


def create_monster_form_page(
path: str,
monster_form: cbp.MonsterForm,
Expand Down Expand Up @@ -227,8 +239,9 @@ def create_monster_form_page(
"cost": "Passive"
if move.is_passive_only
else f"{move.cost} AP",
"link": get_move_link(hoylake, move_root, move),
}
for path, (_, move) in compatible_moves.items()
for path, (move_root, move) in compatible_moves.items()
],
key=lambda m: m["name"],
),
Expand Down
2 changes: 1 addition & 1 deletion cbpickaxe_scripts/templates/monster_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ <h2>Moves</h2>
<tbody>
{% for move in compatible_moves %}
<tr>
<td style="white-space: nowrap;">{{ move.name }}</td>
<td style="white-space: nowrap;"><a href="{{ move.link }}">{{ move.name }}</a></td>
<td style="white-space: nowrap;">{{ move.type }}</td>
<td style="white-space: nowrap;">{{ move.category }}</td>
<td style="white-space: nowrap;">{{ move.power }}</td>
Expand Down

0 comments on commit 61566dc

Please sign in to comment.