From af1db24cd5d44da257c63ca6c0b99703ca2de548 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Mon, 15 Feb 2021 08:56:41 +0000 Subject: [PATCH] Add a command to drain inv --- bot.py | 1 + game.py | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/bot.py b/bot.py index 482d160..28bbf92 100644 --- a/bot.py +++ b/bot.py @@ -201,6 +201,7 @@ def init(global_state): g.break_time = 0 g.dumping = None + g.draining = False g.item_lock = False g.command_lock = False diff --git a/game.py b/game.py index 5a74011..5ecc8a6 100644 --- a/game.py +++ b/game.py @@ -653,6 +653,10 @@ class Game: else: reply = 'not found' + if command == 'drain': + self.g.draining = True + reply = 'ok' + if command == 'gapple': self.g.job.state = self.g.job.find_gapple if data: @@ -753,6 +757,10 @@ class Game: if command == 'use': self.use_item(0) + if command == 'test': + reply = 'ok' + self.select_next_item() + ################# Authorized commands ########################## if authed: @@ -897,6 +905,15 @@ class Game: else: return False + def select_next_item(self): + # select the next item slot that has an item + for slot, item in self.g.inv.items(): + if item.present: + self.g.game.choose_slot(slot) + self.g.holding = item.item_id + return True + else: # for + return False def drop_stack(self): packet = PlayerDiggingPacket() @@ -1112,5 +1129,12 @@ class Game: else: self.g.dumping = None + if self.g.draining and not self.g.item_lock: + if self.select_next_item(): + self.drop_stack() + self.g.item_lock = True + else: + self.g.draining = False + if not self.g.path: self.g.correction_count = 0