diff --git a/mesh_bot.py b/mesh_bot.py index 0c5c059..fb102a0 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -715,6 +715,7 @@ def handle_llm(message_from_id, channel_number, deviceID, message, publicChannel def handleDopeWars(message, nodeID, rxNode): global dwPlayerTracker global dwHighScore + msg = "" # Find player in tracker player = next((p for p in dwPlayerTracker if p.get('userID') == nodeID), None) @@ -725,7 +726,6 @@ def handleDopeWars(message, nodeID, rxNode): 'userID': nodeID, 'last_played': time.time(), 'cmd': 'new', - # ... add other fields as needed ... } dwPlayerTracker.append(player) msg = 'Welcome to πŸ’ŠDope WarsπŸ’‰ You have ' + str(total_days) + ' days to make as much πŸ’° as possible! ' diff --git a/modules/games/dopewar.py b/modules/games/dopewar.py index 68f61ee..0193181 100644 --- a/modules/games/dopewar.py +++ b/modules/games/dopewar.py @@ -383,14 +383,11 @@ def endGameDw(nodeID): with open('data/dopewar_hs.pkl', 'wb') as file: pickle.dump(dwHighScore, file) msg = "You finished with $" + "{:,}".format(cash) + " and beat the high score!πŸŽ‰πŸ’°" - return msg - if cash > starting_cash: + elif cash > starting_cash: msg = 'You made money! πŸ’΅ Up ' + str((cash/starting_cash).__round__()) + 'x! Well done.' - return msg - if cash == starting_cash: + elif cash == starting_cash: msg = 'You broke even... hope you at least had fun πŸ’‰πŸ’Š' - return msg - if cash < starting_cash: + else: msg = "You lost money, better go get a real job.πŸ’Έ" # remove player from all trackers and databases @@ -503,6 +500,11 @@ def playDopeWars(nodeID, cmd): if dwGameDayDb[i].get('userID') == nodeID: inGame = True + # Allow ending the game from any state while a session is active. + cmd_normalized = str(cmd).strip().lower() + if inGame and cmd_normalized in ['e', 'end', 'quit', 'exit']: + return endGameDw(nodeID) + if not inGame: # initalize player in the database loc = generatelocations() @@ -613,9 +615,6 @@ def playDopeWars(nodeID, cmd): # render_game_screen msg = render_game_screen(nodeID, game_day, total_days, loc_choice, -1, price_list, 0, 'nothing') return msg - elif 'e' in menu_choice: - msg = endGameDw(nodeID) - return msg else: msg = f'example buy:\nb,drug#,qty# or Sell: s,1,10 qty can be (m)ax\n f,p or end' return msg