From aa05c62d94329070885aa6fd3c04e0ffcfaf3b4b Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Sat, 28 Sep 2024 00:45:57 -0700 Subject: [PATCH] =?UTF-8?q?fix=F0=9F=8D=8Bhs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mesh_bot.py | 7 +++---- modules/lemonade.py | 4 +--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/mesh_bot.py b/mesh_bot.py index 488d853..f906cdf 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -342,11 +342,10 @@ def handleLemonade(nodeID, message): highScore = getHighScoreLemon() if highScore != 0: if highScore['userID'] != 0: - nodeName = get_name_from_number(highScore['nodeID']) + nodeName = get_name_from_number(highScore['userID']) if nodeName.isnumeric() and interface2_enabled: - nodeName = get_name_from_number(highScore['nodeID'], 'long', 2) - - msg += f" HighScore🥇{nodeName} 💰{high_score['cash']}k with %{high_score['success']}" + nodeName = get_name_from_number(highScore['userID'], 'long', 2) + msg += f" HighScore🥇{nodeName} 💰{highScore['cash']}k with %{highScore['success']}" msg += start_lemonade(nodeID=nodeID, message=message, celsius=False) # wait a second to keep from message collision diff --git a/modules/lemonade.py b/modules/lemonade.py index 3ad2694..0969de6 100644 --- a/modules/lemonade.py +++ b/modules/lemonade.py @@ -38,15 +38,13 @@ def get_sales_amount(potential, unit, price): return math.floor(potential * (unit / (price ** 1.5))) def getHighScoreLemon(): - global high_score + high_score = {"userID": 0, "cash": 0, "success": 0} # Load high score table try: with open('lemonade_hs.pkl', 'rb') as file: high_score = pickle.load(file) except FileNotFoundError: logger.debug("System: Lemonade: No high score table found") - # high score pickle file is a touple of the nodeID and the high score - high_score = ({"userID": 0, "cash": 0, "success": 0}) # write a new high score file if one is not found with open('lemonade_hs.pkl', 'wb') as file: pickle.dump(high_score, file)