Skip to content

Commit

Permalink
adds a manual collect list that gets collected on update (Archipelago…
Browse files Browse the repository at this point in the history
…MW#6)

* adds a manual collect list that gets collected on update

* add a way to clear manual_items without restarting
  • Loading branch information
qwint authored Jun 5, 2024
1 parent 05d2ba4 commit b9fd46c
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions worlds/tracker/TrackerClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ def _cmd_event_inventory(self):
for event in sorted(events):
logger.info(event)

def _cmd_manually_collect(self, item_name: str):
"""Manually adds an item name to the CollectionState to test"""
self.ctx.manual_items.append(item_name)
updateTracker(self.ctx)
logger.info("Added {item_name} to manually collect")

def _cmd_reset_manually_collect(self):
"""Resets the list of items manually collected by /manually_collect"""
self.ctx.manual_items = []
updateTracker(self.ctx)
logger.info("Reset manually collect")


class TrackerGameContext(CommonContext):
from kvui import GameManager
Expand All @@ -78,6 +90,7 @@ def __init__(self, server_address, password):
self.datapackage = []
self.multiworld: MultiWorld = None
self.player_id = None
self.manual_items = []

def clear_page(self):
if self.tracker_page is not None:
Expand Down Expand Up @@ -424,17 +437,17 @@ def updateTracker(ctx: TrackerGameContext):

callback_list = []

for item in ctx.items_received:
for item_name in [item[0] for item in ctx.items_received] + ctx.manual_items:
try:
world_item = ctx.multiworld.create_item(ctx.multiworld.worlds[ctx.player_id].item_id_to_name[item[0]],
world_item = ctx.multiworld.create_item(ctx.multiworld.worlds[ctx.player_id].item_id_to_name[item_name],
ctx.player_id)
state.collect(world_item, True)
if world_item.classification == ItemClassification.progression or world_item.classification == ItemClassification.progression_skip_balancing:
prog_items[world_item.name] += 1
if world_item.code is not None:
all_items[world_item.name] += 1
except:
ctx.log_to_tab("Item id " + str(item[0]) + " not able to be created", False)
ctx.log_to_tab("Item id " + str(item_name) + " not able to be created", False)
state.sweep_for_events(
locations=(location for location in ctx.multiworld.get_locations() if (not location.address)))

Expand Down

0 comments on commit b9fd46c

Please sign in to comment.