Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracker: Add starting inventory to trackers and received items table. #3051

Merged
merged 1 commit into from
Mar 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions WebHostLib/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,13 @@ def get_player_received_items(self, team: int, player: int) -> List[NetworkItem]
@_cache_results
def get_player_inventory_counts(self, team: int, player: int) -> collections.Counter:
"""Retrieves a dictionary of all items received by their id and their received count."""
items = self.get_player_received_items(team, player)
received_items = self.get_player_received_items(team, player)
starting_items = self.get_player_starting_inventory(team, player)
inventory = collections.Counter()
for item in items:
for item in received_items:
inventory[item.item] += 1
for item in starting_items:
inventory[item] += 1

return inventory

Expand Down Expand Up @@ -358,10 +361,13 @@ def get_enabled_multiworld_trackers(room: Room) -> Dict[str, Callable]:
def render_generic_tracker(tracker_data: TrackerData, team: int, player: int) -> str:
game = tracker_data.get_player_game(team, player)

# Add received index to all received items, excluding starting inventory.
received_items_in_order = {}
for received_index, network_item in enumerate(tracker_data.get_player_received_items(team, player), start=1):
received_items_in_order[network_item.item] = received_index
starting_inventory = tracker_data.get_player_starting_inventory(team, player)
for index, item in enumerate(starting_inventory):
received_items_in_order[item] = index
for index, network_item in enumerate(tracker_data.get_player_received_items(team, player),
start=len(starting_inventory)):
received_items_in_order[network_item.item] = index

return render_template(
template_name_or_list="genericTracker.html",
Expand Down
Loading