Skip to content

Commit

Permalink
Refactor: Condensed discord message will be the only option (aeon0#687)
Browse files Browse the repository at this point in the history
* Condsensed discord message will be the only option

Condensed message will be default. removed the option from params.

* Update game_stats.py

* Update discord_embeds.py

* Update bot.py

* Update shenk_eld.py

* Update config.py

* removed a line

removed e.set_thumbnail(url=f"{self._psnURL}36L4a4994.png")

* Update README.md
  • Loading branch information
D2RLegit authored Apr 4, 2022
1 parent ac0ac75 commit 4db1fef
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 17 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ run_shenk=0
| difficulty | Set to `normal` `nightmare` or `hell` for game difficulty. |
| message_api_type | Which api to use to send botty messages. Supports "generic_api" (basic discord), or "discord" (discord embeds with images). |
| discord_status_count | Number of games between discord status messages being sent. Leave empty for no status reports.
| discord_status_condensed | Toggles condensed view of Discord status messages. 0 Full text, 1 Condensed text.
| info_screenshots | If `1`, the bot takes a screenshot with timestamp on every stuck / chicken / timeout / inventory full event. This is 1 by Default, so remember to clean up the folder every once in a while. |
| loot_screenshots | If `1`, the bot takes a screenshot with timestamp everytime he presses `show_items` button and saves it to `loot_screenshots` folder. Remember to clear them once in a while... |
| saved_games_folder | [Optional] Defaults to `~\Saved Games\Diablo II Resurrected`. Used to store configuration settings for `f9` / auto settings. |
Expand Down
1 change: 0 additions & 1 deletion config/params.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ difficulty=hell
info_screenshots=1
loot_screenshots=0
discord_status_count=20
discord_status_condensed=1
saved_games_folder=
d2r_path=C:\Program Files (x86)\Diablo II Resurrected
; if you set this field to 1, botty will save the top-most visible character template just after
Expand Down
10 changes: 5 additions & 5 deletions src/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ def _ending_run_helper(self, res: Union[bool, tuple[Location, bool]]):
def on_run_pindle(self):
res = False
self._do_runs["run_pindle"] = False
self._game_stats.update_location("Pin" if Config().general['discord_status_condensed'] else "Pindle")
self._game_stats.update_location("Pin")
self._curr_loc = self._pindle.approach(self._curr_loc)
if self._curr_loc:
set_pause_state(False)
Expand All @@ -491,7 +491,7 @@ def on_run_shenk(self):
def on_run_trav(self):
res = False
self._do_runs["run_trav"] = False
self._game_stats.update_location("Trav" if Config().general['discord_status_condensed'] else "Travincal")
self._game_stats.update_location("Trav")
self._curr_loc = self._trav.approach(self._curr_loc)
if self._curr_loc:
set_pause_state(False)
Expand All @@ -501,7 +501,7 @@ def on_run_trav(self):
def on_run_nihlathak(self):
res = False
self._do_runs["run_nihlathak"] = False
self._game_stats.update_location("Nihl" if Config().general['discord_status_condensed'] else "Nihlathak")
self._game_stats.update_location("Nihl")
self._curr_loc = self._nihlathak.approach(self._curr_loc)
if self._curr_loc:
set_pause_state(False)
Expand All @@ -511,7 +511,7 @@ def on_run_nihlathak(self):
def on_run_arcane(self):
res = False
self._do_runs["run_arcane"] = False
self._game_stats.update_location("Arc" if Config().general['discord_status_condensed'] else "Arcane")
self._game_stats.update_location("Arc")
self._curr_loc = self._arcane.approach(self._curr_loc)
if self._curr_loc:
set_pause_state(False)
Expand All @@ -521,7 +521,7 @@ def on_run_arcane(self):
def on_run_diablo(self):
res = False
self._do_runs["run_diablo"] = False
self._game_stats.update_location("Dia" if Config().general['discord_status_condensed'] else "Diablo")
self._game_stats.update_location("Dia")
self._curr_loc = self._diablo.approach(self._curr_loc)
if self._curr_loc:
set_pause_state(False)
Expand Down
1 change: 0 additions & 1 deletion src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ def load_data(self):
"message_api_type": self._select_val("general", "message_api_type"),
"custom_message_hook": self._select_val("general", "custom_message_hook"),
"discord_status_count": False if not self._select_val("general", "discord_status_count") else int(self._select_val("general", "discord_status_count")),
"discord_status_condensed": bool(int(self._select_val("general", "discord_status_condensed"))),
"info_screenshots": bool(int(self._select_val("general", "info_screenshots"))),
"loot_screenshots": bool(int(self._select_val("general", "loot_screenshots"))),
"d2r_path": _default_iff(self._select_val("general", "d2r_path"), "", "C:\Program Files (x86)\Diablo II Resurrected"),
Expand Down
7 changes: 2 additions & 5 deletions src/game_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,18 +194,15 @@ def _create_msg(self):
table.rows.append([location, len(stats["items"]), stats["chickens"], stats["deaths"], stats["merc_deaths"], stats["failed_runs"]])

table.rows.append([
"T" if Config().general['discord_status_condensed'] else "Total",
"T",
self._location_stats["totals"]["items"],
self._location_stats["totals"]["chickens"],
self._location_stats["totals"]["deaths"],
self._location_stats["totals"]["merc_deaths"],
self._location_stats["totals"]["failed_runs"]
])

if Config().general['discord_status_condensed']:
table.columns.header = ["Run", "I", "C", "D", "MD", "F"]
else:
table.columns.header = ["Run", "Items", "Chicken", "Death", "Merc Death", "Failed Runs"]
table.columns.header = ["Run", "I", "C", "D", "MD", "F"]

msg += f"\n{str(table)}\n"
return msg
Expand Down
2 changes: 0 additions & 2 deletions src/messages/discord_embeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ def send_gold(self):
def send_message(self, msg: str):
msg = f"{Config().general['name']}: {msg}"
e = discord.Embed(title=f"Update:", description=f"```{msg}```", color=Color.dark_teal())
if not Config().general['discord_status_condensed']:
e.set_thumbnail(url=f"{self._psnURL}36L4a4994.png")
self._send_embed(e)

def _send_embed(self, e, file = None):
Expand Down
4 changes: 2 additions & 2 deletions src/run/shenk_eld.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def approach(self, start_loc: Location) -> Union[bool, Location, bool]:

def battle(self, do_shenk: bool, do_pre_buff: bool, game_stats) -> Union[bool, tuple[Location, bool]]:
# Eldritch
game_stats.update_location("Eld" if Config().general['discord_status_condensed'] else "Eldritch")
game_stats.update_location("Eld")
if not TemplateFinder().search_and_wait(["ELDRITCH_0", "ELDRITCH_START"], threshold=0.65, timeout=20).valid:
return False
if do_pre_buff:
Expand All @@ -52,7 +52,7 @@ def battle(self, do_shenk: bool, do_pre_buff: bool, game_stats) -> Union[bool, t
# Shenk
if do_shenk:
Logger.info("Run Shenk")
game_stats.update_location("Shk" if Config().general['discord_status_condensed'] else "Shenk")
game_stats.update_location("Shk")
self._curr_loc = Location.A5_SHENK_START
# No force move, otherwise we might get stuck at stairs!
if not self._pather.traverse_nodes((Location.A5_SHENK_START, Location.A5_SHENK_SAFE_DIST), self._char):
Expand Down

0 comments on commit 4db1fef

Please sign in to comment.