From 344b844dea52abdae78f937707a37100fb41370c Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 7 Mar 2019 18:14:10 +0100 Subject: [PATCH] Fix brawlhalla rank bug --- statsupdate.py | 10 +++++----- utils/dirty.py | 17 +++++++++++------ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/statsupdate.py b/statsupdate.py index 548976da..c505eec2 100644 --- a/statsupdate.py +++ b/statsupdate.py @@ -133,17 +133,17 @@ def brawlhalla_rank_change(item, change: typing.Tuple[DirtyDelta, Dirty]): try: if solo.delta >= 10: reply_msg(telegram_bot, main_chat_id, strings.STATSUPDATE.BRAWLHALLA.SOLO, - username=item.steam.royal.username, + username=item.steam.royal.telegram.mention(), rating=solo.value, - delta=solo.delta_string()) + delta=solo.difference_string()) if team.is_dirty(): partner = item.best_team_partner if partner is None: - other = "???" + other = "qualcun altro" else: - other = partner.steam.royal.username + other = partner.steam.royal.telegram.mention() reply_msg(telegram_bot, main_chat_id, strings.STATSUPDATE.BRAWLHALLA.TEAM, - username=item.steam.royal.username, + username=item.steam.royal.telegram.mention(), rating=team.value[1], other=other) except Exception: diff --git a/utils/dirty.py b/utils/dirty.py index b709b6e0..42123db1 100644 --- a/utils/dirty.py +++ b/utils/dirty.py @@ -14,8 +14,9 @@ class Dirty: class DirtyDelta(Dirty): + @property - def delta(self): + def difference(self): if self.initial_value is None: initial_value = 0 else: @@ -24,9 +25,13 @@ class DirtyDelta(Dirty): value = 0 else: value = self.value - return abs(value - initial_value) + return value - initial_value - def delta_string(self): - if self.delta > 0: - return f"+{self.delta}" - return self.delta + @property + def delta(self): + return abs(self.difference) + + def difference_string(self): + if self.difference > 0: + return f"+{self.difference}" + return self.difference