Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Commit

Permalink
Merge pull request #134 from NabDev/feat-merge-monster-walks
Browse files Browse the repository at this point in the history
Merge walks around/through into one field
  • Loading branch information
Galarzaa90 committed Oct 1, 2018
2 parents 04dca89 + 3c51e35 commit a9a9aef
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions cogs/tibiawiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,13 +446,19 @@ def get_monster_embed(ctx: NabCtx, monster, long):
TibiaWiki._set_monster_embed_elem_modifiers(embed, monster, TibiaWiki._get_monster_elemental_modifiers())
TibiaWiki._set_monster_embed_bestiary(embed, monster)
TibiaWiki._set_monster_embed_damage(embed, long, monster)
TibiaWiki._set_monster_embed_walks(embed, monster, "Walks Through", "walksthrough")
TibiaWiki._set_monster_embed_walks(embed, monster, "Walks Around", "walksaround")
TibiaWiki._set_monster_embed_walks(embed, monster)
TibiaWiki._set_monster_embed_abilities(embed, monster)
TibiaWiki._set_monster_embed_loot(embed, long, monster)
TibiaWiki._set_monster_embed_more_info(ctx, embed, long, monster)
return embed

@staticmethod
def _set_monster_embed_walks(embed, monster):
content = TibiaWiki._get_content_monster_walks(monster, "Through: ", "walksthrough")
content = TibiaWiki._get_content_monster_walks(monster, "Around: ", "walksaround", content)
if content:
embed.add_field(name="Field Walking", value=content, inline=True)

@staticmethod
def _get_monster_elemental_modifiers():
"""Returns the elemental modifiers available for monsters."""
Expand All @@ -476,11 +482,14 @@ def _set_monster_embed_more_info(ctx, embed, long, monster):
embed.set_footer(text="To see more, PM me{0}.".format(askchannel_string))

@staticmethod
def _set_monster_embed_walks(embed, monster, embed_field_name, attribute_name):
def _get_content_monster_walks(monster, walk_field_name, attribute_name, content=""):
"""Adds the embed field describing which elemnts the monster walks around or through."""
attribute_value = str(monster[attribute_name])
if attribute_value is not None and not attribute_value.lower().__contains__("none"):
content = ""
if content:
content += "\n"
content += walk_field_name

if config.use_elemental_emojis:
walks_elements = []
for element in TibiaWiki._get_elements_monster_walks():
Expand All @@ -491,7 +500,7 @@ def _set_monster_embed_walks(embed, monster, embed_field_name, attribute_name):
content += f"{config.elemental_emojis[element]}"
else:
content += attribute_value
embed.add_field(name=embed_field_name, value=content, inline=True)
return content

@staticmethod
def _set_monster_embed_abilities(embed, monster):
Expand Down

0 comments on commit a9a9aef

Please sign in to comment.