Skip to content

Commit

Permalink
Relpace deck gear with egg if level below 5
Browse files Browse the repository at this point in the history
  • Loading branch information
zjosua committed Nov 19, 2023
1 parent 0a05c69 commit a2796e8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/pokemanki/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@
Version information
"""

__version__ = "1.5.0"
__version__ = "1.5.1"
17 changes: 13 additions & 4 deletions src/pokemanki/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,19 @@ def replace_gears(
soup = BeautifulSoup(content.tree, "html.parser")
for tr in soup.select("tr[id]"):
deck_id = int(tr["id"])
name = next((pokemon[0] for pokemon in pokemons if pokemon[1] == deck_id), None)
if name:
tr.select("img.gears")[0]["src"] = f"{pkmnimgfolder}/{name}.png"
tr.select("img.gears")[0]["class"] = "gears pokemon"
name_and_level = next(
((pokemon[0], pokemon[2]) for pokemon in pokemons if pokemon[1] == deck_id),
None,
)
if not name_and_level:
continue
if name_and_level[1] < 5:
tr.select("img.gears")[0]["src"] = f"{pkmnimgfolder}/Egg.png"
else:
tr.select("img.gears")[0][
"src"
] = f"{pkmnimgfolder}/{name_and_level[0]}.png"
tr.select("img.gears")[0]["class"] = "gears pokemon"
style = soup.new_tag("style")
style.string = ".gears.pokemon{filter:none;opacity:1}"
soup.append(style)
Expand Down

0 comments on commit a2796e8

Please sign in to comment.