track keys
This commit is contained in:
parent
38fe292acb
commit
1a94bcaec5
|
@ -60,22 +60,39 @@
|
|||
</tbody>
|
||||
</table>
|
||||
{% endfor %}
|
||||
|
||||
|
||||
|
||||
{% for team, players in checks_done.items() %}
|
||||
<table class="table table-striped table-bordered table-hover table-sm">
|
||||
<thead class="thead-dark">
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Name</th>
|
||||
<th rowspan="2">#</th>
|
||||
<th rowspan="2">Name</th>
|
||||
{% for area in ordered_areas %}
|
||||
{% set colspan = (3 if area in key_locations else 1) %}
|
||||
{% if area in icons %}
|
||||
<th style="text-align: center"><img height="32" width="32" style="object-fit: contain"
|
||||
<th colspan="{{ colspan }}" style="text-align: center"><img height="32" width="32"
|
||||
style="object-fit: contain"
|
||||
src="{{ icons[area] }}"
|
||||
alt="{{ area }}"></th>
|
||||
{% else %}
|
||||
<th>{{ area }}</th>
|
||||
<th colspan="{{ colspan }}">{{ area }}</th>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<th rowspan="2">Last Activity</th>
|
||||
</tr>
|
||||
<tr>
|
||||
{% for area in ordered_areas %}
|
||||
<th style="text-align: center"><img height="32" width="32" style="object-fit: contain"
|
||||
src="{{ icons["Chest"] }}" alt="Checks"></th>
|
||||
{% if area in key_locations %}
|
||||
<th style="text-align: center"><img height="32" width="32" style="object-fit: contain"
|
||||
src="{{ icons["Small Key"] }}" alt="Small Key"></th>
|
||||
<th style="text-align: center"><img height="32" width="32" style="object-fit: contain"
|
||||
src="{{ icons["Big Key"] }}" alt="Big Key"></th>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<th>Last Activity (UTC)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -92,11 +109,15 @@
|
|||
{% else %}
|
||||
<td style="text-align: center">{{ checks_done }}/{{ checks_total }}</td>
|
||||
{% endif %}
|
||||
{% if area in key_locations %}
|
||||
<td>{{ inventory[team][player][small_key_ids[area]] }}</td>
|
||||
<td>{% if inventory[team][player][big_key_ids[area]] %}✔️{% endif %}</td>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if activity_timers[(team, player)] %}
|
||||
<td class="table-info">{{ activity_timers[(team, player)].isoformat(sep=" ", timespec='minutes') }}</td>
|
||||
<td class="table-info">{{ activity_timers[(team, player)] | render_timedelta }}</td>
|
||||
{% else %}
|
||||
<td class="table-warning">No activity</td>{% endif %}
|
||||
<td class="table-warning">None</td>{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
|
|
@ -69,7 +69,13 @@ icons = {
|
|||
"Magic Mirror":
|
||||
r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/e/e5/ALttP_Magic_Mirror_Sprite.png?version=e035dbc9cbe2a3bd44aa6d047762b0cc",
|
||||
"Triforce":
|
||||
r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/4/4e/TriforceALttPTitle.png?version=dc398e1293177581c16303e4f9d12a48"
|
||||
r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/4/4e/TriforceALttPTitle.png?version=dc398e1293177581c16303e4f9d12a48",
|
||||
"Small Key":
|
||||
r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/f/f1/ALttP_Small_Key_Sprite.png?version=4f35d92842f0de39d969181eea03774e",
|
||||
"Big Key":
|
||||
r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/3/33/ALttP_Big_Key_Sprite.png?version=136dfa418ba76c8b4e270f466fc12f4d",
|
||||
"Chest":
|
||||
r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/7/73/ALttP_Treasure_Chest_Sprite.png?version=5f530ecd98dcb22251e146e8049c0dda"
|
||||
}
|
||||
|
||||
links = {"Bow": "Progressive Bow",
|
||||
|
@ -133,6 +139,11 @@ default_locations = {
|
|||
'Ganons Tower': {60160, 60163, 60166, 60088, 60091, 60094, 60097, 60100, 60103, 60106, 60109, 60112, 60115, 60118,
|
||||
60121, 60124, 60127, 1573217, 60130, 60133, 60136, 60139, 60142, 60145, 60148, 60151, 60157},
|
||||
'Total': set()}
|
||||
|
||||
key_locations = {"Desert Palace", "Eastern Palace", "Hyrule Castle", "Agahnims Tower", "Tower of Hera", "Swamp Palace",
|
||||
"Thieves Town", "Skull Woods", "Ice Palace", "Misery Mire", "Turtle Rock", "Palace of Darkness",
|
||||
"Ganons Tower"}
|
||||
|
||||
location_to_area = {}
|
||||
for area, locations in default_locations.items():
|
||||
for location in locations:
|
||||
|
@ -150,6 +161,17 @@ tracking_ids = []
|
|||
for item in tracking_names:
|
||||
tracking_ids.append(get_id(item))
|
||||
|
||||
small_key_ids = {}
|
||||
big_key_ids = {}
|
||||
|
||||
for item_name, data in Items.item_table.items():
|
||||
if "Key" in item_name:
|
||||
area = item_name.split("(")[1][:-1]
|
||||
if "Small" in item_name:
|
||||
small_key_ids[area] = data[3]
|
||||
else:
|
||||
big_key_ids[area] = data[3]
|
||||
|
||||
from MultiServer import get_item_name_from_id
|
||||
|
||||
|
||||
|
@ -160,6 +182,15 @@ def attribute_item(inventory, team, recipient, item):
|
|||
else:
|
||||
inventory[team][recipient][target_item] += 1
|
||||
|
||||
|
||||
@app.template_filter()
|
||||
def render_timedelta(delta: datetime.timedelta):
|
||||
hours, minutes = divmod(delta.total_seconds() / 60, 60)
|
||||
hours = str(int(hours))
|
||||
minutes = str(int(minutes)).zfill(2)
|
||||
return f"{hours}:{minutes}"
|
||||
|
||||
|
||||
@app.route('/tracker/<int:room>')
|
||||
@cache.memoize(timeout=60) # update every minute
|
||||
def get_tracker(room: int):
|
||||
|
@ -194,13 +225,19 @@ def get_tracker(room: int):
|
|||
inventory[team][player][106] = 1 # Triforce
|
||||
|
||||
activity_timers = {}
|
||||
now = datetime.datetime.utcnow()
|
||||
for (team, player), timestamp in room.multisave.get("client_activity_timers", []):
|
||||
activity_timers[team, player] = datetime.datetime.utcfromtimestamp(timestamp)
|
||||
activity_timers[team, player] = now - datetime.datetime.utcfromtimestamp(timestamp)
|
||||
|
||||
player_names = {}
|
||||
for team, names in enumerate(multidata['names']):
|
||||
for player, name in enumerate(names, 1):
|
||||
player_names[(team, player)] = name
|
||||
|
||||
for team in inventory:
|
||||
for player in inventory[team]:
|
||||
for id, area in small_key_ids.items():
|
||||
logging.info((player, area, inventory[team][player][id]))
|
||||
for (team, player), alias in room.multisave.get("name_aliases", []):
|
||||
player_names[team, player] = alias
|
||||
|
||||
|
@ -208,6 +245,7 @@ def get_tracker(room: int):
|
|||
lookup_id_to_name=Items.lookup_id_to_name, player_names=player_names,
|
||||
tracking_names=tracking_names, tracking_ids=tracking_ids, room=room, icons=icons,
|
||||
multi_items=multi_items, checks_done=checks_done, ordered_areas=ordered_areas,
|
||||
checks_in_area=checks_in_area, activity_timers=activity_timers)
|
||||
checks_in_area=checks_in_area, activity_timers=activity_timers,
|
||||
key_locations=key_locations, small_key_ids=small_key_ids, big_key_ids=big_key_ids)
|
||||
else:
|
||||
return "Tracker disabled for this room."
|
||||
|
|
Loading…
Reference in New Issue