From 48df6882facb563bb021e69bb3c2e532ea354578 Mon Sep 17 00:00:00 2001 From: Sandra Date: Mon, 7 Oct 2024 18:21:11 +1100 Subject: [PATCH 1/8] Added /next_progression command, which tells the player what items can be sent that will immediately unlock new locations. --- worlds/tracker/TrackerClient.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/worlds/tracker/TrackerClient.py b/worlds/tracker/TrackerClient.py index 26b375754db0..08387d1b5a90 100644 --- a/worlds/tracker/TrackerClient.py +++ b/worlds/tracker/TrackerClient.py @@ -150,6 +150,23 @@ def _cmd_reset_ignored(self): self.ctx.ignored_locations.clear() updateTracker(self.ctx) logger.info("Reset ignored locations.") + def _cmd_next_progression(self): + """Finds all items that will unlock a check immediately when collected, and how many new checks they will unlock.""" + prev_manual_items = self.ctx.manual_items + self.ctx.manual_items = [] + updateTracker(self.ctx) + baseLocs = self.ctx.locations_available + counter = Counter() + for item in self.ctx.multiworld.get_items(): + if item.classification == ItemClassification.progression or item.classification == ItemClassification.progression_skip_balancing: + self.ctx.manual_items.append(item.name) + updateTracker(self.ctx) + newlocs = set(self.ctx.locations_available) - set(baseLocs) + if len(newlocs) != 0: + counter[item.name] = len(newlocs) + self.ctx.manual_items = [] + logger.info(counter) + self.ctx.manual_items = prev_manual_items class TrackerGameContext(CommonContext): From fc5c85e69bfbd6373e0ccea86f16a777c6cc60a0 Mon Sep 17 00:00:00 2001 From: Sandra Date: Mon, 7 Oct 2024 19:37:01 +1100 Subject: [PATCH 2/8] Fixed the final progression item added being falsely kept until the tracker updates. --- worlds/tracker/TrackerClient.py | 1 + 1 file changed, 1 insertion(+) diff --git a/worlds/tracker/TrackerClient.py b/worlds/tracker/TrackerClient.py index 08387d1b5a90..c89f20500923 100644 --- a/worlds/tracker/TrackerClient.py +++ b/worlds/tracker/TrackerClient.py @@ -167,6 +167,7 @@ def _cmd_next_progression(self): self.ctx.manual_items = [] logger.info(counter) self.ctx.manual_items = prev_manual_items + updateTracker(self.ctx) class TrackerGameContext(CommonContext): From 78c40ced25ff91329b6393cecd5d5a470dbd63bb Mon Sep 17 00:00:00 2001 From: Sandra Date: Mon, 7 Oct 2024 19:52:04 +1100 Subject: [PATCH 3/8] Changed /next_progression so it now takes manually collected items into account. --- worlds/tracker/TrackerClient.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/worlds/tracker/TrackerClient.py b/worlds/tracker/TrackerClient.py index c89f20500923..076dd56ba6a4 100644 --- a/worlds/tracker/TrackerClient.py +++ b/worlds/tracker/TrackerClient.py @@ -153,8 +153,6 @@ def _cmd_reset_ignored(self): def _cmd_next_progression(self): """Finds all items that will unlock a check immediately when collected, and how many new checks they will unlock.""" prev_manual_items = self.ctx.manual_items - self.ctx.manual_items = [] - updateTracker(self.ctx) baseLocs = self.ctx.locations_available counter = Counter() for item in self.ctx.multiworld.get_items(): @@ -164,7 +162,7 @@ def _cmd_next_progression(self): newlocs = set(self.ctx.locations_available) - set(baseLocs) if len(newlocs) != 0: counter[item.name] = len(newlocs) - self.ctx.manual_items = [] + self.ctx.manual_items = prev_manual_items logger.info(counter) self.ctx.manual_items = prev_manual_items updateTracker(self.ctx) From 7c5c3dcfc954b10cd20395eccc51358461f37ded Mon Sep 17 00:00:00 2001 From: Sandra Date: Mon, 7 Oct 2024 20:17:43 +1100 Subject: [PATCH 4/8] Fixed /next_progression so it now actually works, and filters just for items belonging to the actual game in use rather than adding items belonging to all games in the multiworld. This also fixes a latent bug where it would reset the manually collected items forcibly as it did not copy the manually collected list. --- worlds/tracker/TrackerClient.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/worlds/tracker/TrackerClient.py b/worlds/tracker/TrackerClient.py index 076dd56ba6a4..1fbc208d11f2 100644 --- a/worlds/tracker/TrackerClient.py +++ b/worlds/tracker/TrackerClient.py @@ -152,17 +152,18 @@ def _cmd_reset_ignored(self): logger.info("Reset ignored locations.") def _cmd_next_progression(self): """Finds all items that will unlock a check immediately when collected, and how many new checks they will unlock.""" - prev_manual_items = self.ctx.manual_items + prev_manual_items = self.ctx.manual_items.copy() + updateTracker(self.ctx) baseLocs = self.ctx.locations_available counter = Counter() for item in self.ctx.multiworld.get_items(): - if item.classification == ItemClassification.progression or item.classification == ItemClassification.progression_skip_balancing: + if item.game == self.ctx.game and (item.classification == ItemClassification.progression or item.classification == ItemClassification.progression_skip_balancing): self.ctx.manual_items.append(item.name) updateTracker(self.ctx) newlocs = set(self.ctx.locations_available) - set(baseLocs) if len(newlocs) != 0: counter[item.name] = len(newlocs) - self.ctx.manual_items = prev_manual_items + self.ctx.manual_items = prev_manual_items.copy() logger.info(counter) self.ctx.manual_items = prev_manual_items updateTracker(self.ctx) From 34f233f50f1fef8f5e01d9becd27581d718dac1d Mon Sep 17 00:00:00 2001 From: Sandra Date: Mon, 7 Oct 2024 21:45:27 +1100 Subject: [PATCH 5/8] Cleaned up /next_progression's output messages. --- worlds/tracker/TrackerClient.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/worlds/tracker/TrackerClient.py b/worlds/tracker/TrackerClient.py index 1fbc208d11f2..4b6969252ef2 100644 --- a/worlds/tracker/TrackerClient.py +++ b/worlds/tracker/TrackerClient.py @@ -164,7 +164,9 @@ def _cmd_next_progression(self): if len(newlocs) != 0: counter[item.name] = len(newlocs) self.ctx.manual_items = prev_manual_items.copy() - logger.info(counter) + + for (item, count) in counter.most_common(): + logger.info(f"{item} unlocks {count} checks.") self.ctx.manual_items = prev_manual_items updateTracker(self.ctx) From 593759ff45b3e5461d2b9764c5a6198b96003729 Mon Sep 17 00:00:00 2001 From: Sandra Date: Tue, 8 Oct 2024 08:04:15 +1100 Subject: [PATCH 6/8] Apply suggestions from code review Co-authored-by: SunCat Co-authored-by: Exempt-Medic <60412657+Exempt-Medic@users.noreply.github.com> --- worlds/tracker/TrackerClient.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/worlds/tracker/TrackerClient.py b/worlds/tracker/TrackerClient.py index 4b6969252ef2..b538e5adf5ee 100644 --- a/worlds/tracker/TrackerClient.py +++ b/worlds/tracker/TrackerClient.py @@ -151,17 +151,17 @@ def _cmd_reset_ignored(self): updateTracker(self.ctx) logger.info("Reset ignored locations.") def _cmd_next_progression(self): - """Finds all items that will unlock a check immediately when collected, and how many new checks they will unlock.""" + """Finds all items that will unlock a check immediately when collected, and a best guess of how many new checks they will unlock.""" prev_manual_items = self.ctx.manual_items.copy() updateTracker(self.ctx) baseLocs = self.ctx.locations_available counter = Counter() for item in self.ctx.multiworld.get_items(): - if item.game == self.ctx.game and (item.classification == ItemClassification.progression or item.classification == ItemClassification.progression_skip_balancing): + if item.game == self.ctx.game and ItemClassification.progression in item.classification: self.ctx.manual_items.append(item.name) updateTracker(self.ctx) newlocs = set(self.ctx.locations_available) - set(baseLocs) - if len(newlocs) != 0: + if newlocs: counter[item.name] = len(newlocs) self.ctx.manual_items = prev_manual_items.copy() From b14c4fcae63f7bbb9136d863952b41c6c83b527a Mon Sep 17 00:00:00 2001 From: Sandra Date: Tue, 8 Oct 2024 08:54:46 +1100 Subject: [PATCH 7/8] Replaced manual item list copies with popping the end off. Additionally, preprocesses the item list to remove duplicates. --- worlds/tracker/TrackerClient.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/worlds/tracker/TrackerClient.py b/worlds/tracker/TrackerClient.py index b538e5adf5ee..21e035191430 100644 --- a/worlds/tracker/TrackerClient.py +++ b/worlds/tracker/TrackerClient.py @@ -152,22 +152,20 @@ def _cmd_reset_ignored(self): logger.info("Reset ignored locations.") def _cmd_next_progression(self): """Finds all items that will unlock a check immediately when collected, and a best guess of how many new checks they will unlock.""" - prev_manual_items = self.ctx.manual_items.copy() updateTracker(self.ctx) - baseLocs = self.ctx.locations_available + baseLocs = len(self.ctx.locations_available) counter = Counter() - for item in self.ctx.multiworld.get_items(): - if item.game == self.ctx.game and ItemClassification.progression in item.classification: - self.ctx.manual_items.append(item.name) - updateTracker(self.ctx) - newlocs = set(self.ctx.locations_available) - set(baseLocs) - if newlocs: - counter[item.name] = len(newlocs) - self.ctx.manual_items = prev_manual_items.copy() + items_to_check = {item.name for item in self.ctx.multiworld.get_items() if item.game == self.ctx.game and ItemClassification.progression in item.classification} + for item in items_to_check: + self.ctx.manual_items.append(item) + updateTracker(self.ctx) + newlocs = len(self.ctx.locations_available) - baseLocs + if newlocs: + counter[item] = newlocs + self.ctx.manual_items.pop() for (item, count) in counter.most_common(): logger.info(f"{item} unlocks {count} checks.") - self.ctx.manual_items = prev_manual_items updateTracker(self.ctx) From 177aef7076906124eb844eefdb9b8794f67637e5 Mon Sep 17 00:00:00 2001 From: Sandra Date: Wed, 9 Oct 2024 11:32:50 +1100 Subject: [PATCH 8/8] Adds a message if there are no results in /next_progression. --- worlds/tracker/TrackerClient.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/worlds/tracker/TrackerClient.py b/worlds/tracker/TrackerClient.py index 21e035191430..bc87df1c7442 100644 --- a/worlds/tracker/TrackerClient.py +++ b/worlds/tracker/TrackerClient.py @@ -163,7 +163,8 @@ def _cmd_next_progression(self): if newlocs: counter[item] = newlocs self.ctx.manual_items.pop() - + if not counter: + logger.info("No item will unlock any checks right now.") for (item, count) in counter.most_common(): logger.info(f"{item} unlocks {count} checks.") updateTracker(self.ctx)