Merge remote-tracking branch 'origin/main' into main
This commit is contained in:
		| @@ -126,7 +126,7 @@ def faq(lang): | ||||
|  | ||||
|  | ||||
| @app.route('/seed/<suuid:seed>') | ||||
| def viewSeed(seed: UUID): | ||||
| def view_seed(seed: UUID): | ||||
|     seed = Seed.get(id=seed) | ||||
|     if not seed: | ||||
|         abort(404) | ||||
|   | ||||
| @@ -76,7 +76,7 @@ def generate(race=False): | ||||
|                         handle_generation_failure(e) | ||||
|                         return render_template("seedError.html", seed_error=(e.__class__.__name__ + ": " + str(e))) | ||||
|  | ||||
|                     return redirect(url_for("viewSeed", seed=seed_id)) | ||||
|                     return redirect(url_for("view_seed", seed=seed_id)) | ||||
|  | ||||
|     return render_template("generate.html", race=race) | ||||
|  | ||||
| @@ -143,7 +143,7 @@ def wait_seed(seed: UUID): | ||||
|     seed_id = seed | ||||
|     seed = Seed.get(id=seed_id) | ||||
|     if seed: | ||||
|         return redirect(url_for("viewSeed", seed=seed_id)) | ||||
|         return redirect(url_for("view_seed", seed=seed_id)) | ||||
|     generation = Generation.get(id=seed_id) | ||||
|  | ||||
|     if not generation: | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
|     {% include 'header/grassHeader.html' %} | ||||
|     <div id="host-room"> | ||||
|         {% if room.owner == session["_id"] %} | ||||
|             Room created from <a href="{{ url_for("viewSeed", seed=room.seed.id) }}">Seed #{{ room.seed.id|suuid }}</a> | ||||
|             Room created from <a href="{{ url_for("view_seed", seed=room.seed.id) }}">Seed #{{ room.seed.id|suuid }}</a> | ||||
|             <br> | ||||
|         {% endif %} | ||||
|         {% if room.tracker %} | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| {% macro list_rooms(rooms) -%} | ||||
|     <ul> | ||||
|         {% for room in rooms %} | ||||
|             <li><a href="{{ url_for("hostRoom", room=room.id) }}">Room #{{ room.id|suuid }}</a></li> | ||||
|             <li><a href="{{ url_for("host_room", room=room.id) }}">Room #{{ room.id|suuid }}</a></li> | ||||
|         {% endfor %} | ||||
|         {{ caller() }} | ||||
|     </ul> | ||||
|   | ||||
| @@ -29,8 +29,8 @@ | ||||
|                     <tbody> | ||||
|                         {% for room in rooms %} | ||||
|                             <tr> | ||||
|                                 <td><a href="{{ url_for("viewSeed", seed=room.seed.id) }}">{{ room.seed.id|suuid }}</a></td> | ||||
|                                 <td><a href="{{ url_for("hostRoom", room=room.id) }}">{{ room.id|suuid }}</a></td> | ||||
|                                 <td><a href="{{ url_for("view_seed", seed=room.seed.id) }}">{{ room.seed.id|suuid }}</a></td> | ||||
|                                 <td><a href="{{ url_for("host_room", room=room.id) }}">{{ room.id|suuid }}</a></td> | ||||
|                                 <td>>={{ room.seed.slots|length }}</td> | ||||
|                                 <td>{{ room.creation_time.strftime("%Y-%m-%d %H:%M") }}</td> | ||||
|                                 <td>{{ room.last_activity.strftime("%Y-%m-%d %H:%M") }}</td> | ||||
| @@ -55,7 +55,7 @@ | ||||
|                     <tbody> | ||||
|                         {% for seed in seeds %} | ||||
|                             <tr> | ||||
|                                 <td><a href="{{ url_for("viewSeed", seed=seed.id) }}">{{ seed.id|suuid }}</a></td> | ||||
|                                 <td><a href="{{ url_for("view_seed", seed=seed.id) }}">{{ seed.id|suuid }}</a></td> | ||||
|                                 <td>{% if seed.multidata %}>={{ seed.slots|length }}{% else %}1{% endif %} | ||||
|                                 </td> | ||||
|                                 <td>{{ seed.creation_time.strftime("%Y-%m-%d %H:%M") }}</td> | ||||
|   | ||||
| @@ -1,4 +1,5 @@ | ||||
| import collections | ||||
| import typing | ||||
| from typing import Counter, Optional, Dict, Any, Tuple | ||||
|  | ||||
| from flask import render_template | ||||
| @@ -10,6 +11,7 @@ from worlds.alttp import Items | ||||
| from WebHostLib import app, cache, Room | ||||
| from Utils import restricted_loads | ||||
| from worlds import lookup_any_item_id_to_name, lookup_any_location_id_to_name | ||||
| from MultiServer import get_item_name_from_id, Context | ||||
|  | ||||
| alttp_icons = { | ||||
|     "Blue Shield": r"https://www.zeldadungeon.net/wiki/images/8/85/Fighters-Shield.png", | ||||
| @@ -74,6 +76,7 @@ alttp_icons = { | ||||
|     "Ganons Tower": r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/b/b9/ALttP_Ganon_Sprite.png?version=956f51f054954dfff53c1a9d4f929c74" | ||||
| } | ||||
|  | ||||
|  | ||||
| def get_alttp_id(item_name): | ||||
|     return Items.item_table[item_name][2] | ||||
|  | ||||
| @@ -201,7 +204,10 @@ for item_name, data in Items.item_table.items(): | ||||
|             big_key_ids[area] = data[2] | ||||
|             ids_big_key[data[2]] = area | ||||
|  | ||||
| from MultiServer import get_item_name_from_id, Context | ||||
| # cleanup global namespace | ||||
| del item_name | ||||
| del data | ||||
| del item | ||||
|  | ||||
|  | ||||
| def attribute_item(inventory, team, recipient, item): | ||||
| @@ -268,8 +274,7 @@ def get_static_room_data(room: Room): | ||||
|                                for playernumber in range(1, len(names[0]) + 1)} | ||||
|  | ||||
|     result = locations, names, use_door_tracker, player_checks_in_area, player_location_to_area, \ | ||||
|              multidata["precollected_items"], \ | ||||
|              multidata["games"] | ||||
|              multidata["precollected_items"], multidata["games"] | ||||
|     _multidata_cache[room.seed.id] = result | ||||
|     return result | ||||
|  | ||||
| @@ -318,23 +323,18 @@ def getPlayerTracker(tracker: UUID, tracked_team: int, tracked_player: int): | ||||
|                     if ms_player == tracked_player:  # a check done by the tracked player | ||||
|                         checks_done[location_to_area[location]] += 1 | ||||
|                         checks_done["Total"] += 1 | ||||
|                          | ||||
|     if games[tracked_player] == "A Link to the Past": | ||||
|         return __renderAlttpTracker(multisave, room, locations, inventory, tracked_team, tracked_player, player_name, \ | ||||
|             seed_checks_in_area, checks_done) | ||||
|     elif games[tracked_player] == "Minecraft": | ||||
|         return __renderMinecraftTracker(multisave, room, locations, inventory, tracked_team, tracked_player, player_name) | ||||
|     elif games[tracked_player] == "Ocarina of Time": | ||||
|         return __renderOoTTracker(multisave, room, locations, inventory, tracked_team, tracked_player, player_name) | ||||
|     elif games[tracked_player] == "Timespinner": | ||||
|         return __renderTimespinnerTracker(multisave, room, locations, inventory, tracked_team, tracked_player, player_name) | ||||
|     specific_tracker = game_specific_trackers.get(games[tracked_player], None) | ||||
|     if specific_tracker: | ||||
|         return specific_tracker(multisave, room, locations, inventory, tracked_team, tracked_player, player_name, | ||||
|                                 seed_checks_in_area, checks_done) | ||||
|     else: | ||||
|         return __renderGenericTracker(multisave, room, locations, inventory, tracked_team, tracked_player, player_name) | ||||
|         return __renderGenericTracker(multisave, room, locations, inventory, tracked_team, tracked_player, player_name, | ||||
|                                       seed_checks_in_area, checks_done) | ||||
|  | ||||
|  | ||||
| def __renderAlttpTracker(multisave: Dict[str, Any], room: Room, locations: Dict[int, Dict[int, Tuple[int, int]]], | ||||
|         inventory: Counter, team: int, player: int, playerName: str,  | ||||
|         seed_checks_in_area: Dict[int, Dict[str, int]], checks_done: Dict[str, int]) -> str: | ||||
|                          inventory: Counter, team: int, player: int, player_name: str, | ||||
|                          seed_checks_in_area: Dict[int, Dict[str, int]], checks_done: Dict[str, int]) -> str: | ||||
|  | ||||
|     # Note the presence of the triforce item | ||||
|     game_state = multisave.get("client_game_state", {}).get((team, player), 0) | ||||
| @@ -384,7 +384,7 @@ def __renderAlttpTracker(multisave: Dict[str, Any], room: Room, locations: Dict[ | ||||
|                     player_small_key_locations.add(ids_small_key[item_id]) | ||||
|  | ||||
|     return render_template("lttpTracker.html", inventory=inventory, | ||||
|                             player_name=playerName, room=room, icons=alttp_icons, checks_done=checks_done, | ||||
|                             player_name=player_name, room=room, icons=alttp_icons, checks_done=checks_done, | ||||
|                             checks_in_area=seed_checks_in_area[player], | ||||
|                             acquired_items={lookup_any_item_id_to_name[id] for id in inventory}, | ||||
|                             small_key_ids=small_key_ids, big_key_ids=big_key_ids, sp_areas=sp_areas, | ||||
| @@ -394,7 +394,8 @@ def __renderAlttpTracker(multisave: Dict[str, Any], room: Room, locations: Dict[ | ||||
|  | ||||
|  | ||||
| def __renderMinecraftTracker(multisave: Dict[str, Any], room: Room, locations: Dict[int, Dict[int, Tuple[int, int]]], | ||||
|         inventory: Counter, team: int, player: int, playerName: str) -> str: | ||||
|                              inventory: Counter, team: int, player: int, playerName: str, | ||||
|                              seed_checks_in_area: Dict[int, Dict[str, int]], checks_done: Dict[str, int]) -> str: | ||||
|  | ||||
|     icons = { | ||||
|         "Wooden Pickaxe": "https://static.wikia.nocookie.net/minecraft_gamepedia/images/d/d2/Wooden_Pickaxe_JE3_BE3.png", | ||||
| @@ -494,7 +495,8 @@ def __renderMinecraftTracker(multisave: Dict[str, Any], room: Room, locations: D | ||||
|  | ||||
|  | ||||
| def __renderOoTTracker(multisave: Dict[str, Any], room: Room, locations: Dict[int, Dict[int, Tuple[int, int]]], | ||||
|         inventory: Counter, team: int, player: int, playerName: str) -> str: | ||||
|                        inventory: Counter, team: int, player: int, playerName: str, | ||||
|                        seed_checks_in_area: Dict[int, Dict[str, int]], checks_done: Dict[str, int]) -> str: | ||||
|  | ||||
|     icons = { | ||||
|         "Fairy Ocarina":            "https://static.wikia.nocookie.net/zelda_gamepedia_en/images/9/97/OoT_Fairy_Ocarina_Icon.png", | ||||
| @@ -621,12 +623,14 @@ def __renderOoTTracker(multisave: Dict[str, Any], room: Room, locations: Dict[in | ||||
|         "Gerudo Training Grounds":  (67597, 67635), | ||||
|         "Ganon's Castle":           (67636, 67673), | ||||
|     } | ||||
|  | ||||
|     def lookup_and_trim(id, area): | ||||
|         full_name = lookup_any_location_id_to_name[id] | ||||
|         if id == 67673: | ||||
|             return full_name[13:] # Ganons Tower Boss Key Chest | ||||
|             return full_name[13:]  # Ganons Tower Boss Key Chest | ||||
|         if area != 'Overworld': | ||||
|             return full_name[len(area):] # trim dungeon name. leaves an extra space that doesn't display, or trims fully for DC/Jabu/GC | ||||
|             # trim dungeon name. leaves an extra space that doesn't display, or trims fully for DC/Jabu/GC | ||||
|             return full_name[len(area):] | ||||
|         return full_name | ||||
|  | ||||
|     checked_locations = multisave.get("location_checks", {}).get((team, player), set()).intersection(set(locations[player])) | ||||
| @@ -669,14 +673,16 @@ def __renderOoTTracker(multisave: Dict[str, Any], room: Room, locations: Dict[in | ||||
|     display_data['game_finished'] = game_state == 30 | ||||
|  | ||||
|     return render_template("ootTracker.html", | ||||
|                             inventory=inventory, player=player, team=team, room=room, player_name=playerName, | ||||
|                             icons=icons, acquired_items={lookup_any_item_id_to_name[id] for id in inventory}, | ||||
|                             checks_done=checks_done, checks_in_area=checks_in_area, location_info=location_info, | ||||
|                             small_key_counts=small_key_counts, boss_key_counts=boss_key_counts, | ||||
|                             **display_data) | ||||
|                            inventory=inventory, player=player, team=team, room=room, player_name=playerName, | ||||
|                            icons=icons, acquired_items={lookup_any_item_id_to_name[id] for id in inventory}, | ||||
|                            checks_done=checks_done, checks_in_area=checks_in_area, location_info=location_info, | ||||
|                            small_key_counts=small_key_counts, boss_key_counts=boss_key_counts, | ||||
|                            **display_data) | ||||
|  | ||||
|  | ||||
| def __renderTimespinnerTracker(multisave: Dict[str, Any], room: Room, locations: Dict[int, Dict[int, Tuple[int, int]]], | ||||
|         inventory: Counter, team: int, player: int, playerName: str) -> str: | ||||
|                                inventory: Counter, team: int, player: int, playerName: str, | ||||
|                                seed_checks_in_area: Dict[int, Dict[str, int]], checks_done: Dict[str, int]) -> str: | ||||
|  | ||||
|     icons = { | ||||
|         "Timespinner Wheel":    "https://timespinnerwiki.com/mediawiki/images/7/76/Timespinner_Wheel.png", | ||||
| @@ -760,7 +766,8 @@ def __renderTimespinnerTracker(multisave: Dict[str, Any], room: Room, locations: | ||||
|  | ||||
|  | ||||
| def __renderGenericTracker(multisave: Dict[str, Any], room: Room, locations: Dict[int, Dict[int, Tuple[int, int]]], | ||||
|         inventory: Counter, team: int, player: int, playerName: str) -> str: | ||||
|                            inventory: Counter, team: int, player: int, playerName: str, | ||||
|                            seed_checks_in_area: Dict[int, Dict[str, int]], checks_done: Dict[str, int]) -> str: | ||||
|  | ||||
|     checked_locations = multisave.get("location_checks", {}).get((team, player), set()) | ||||
|     player_received_items = {} | ||||
| @@ -864,3 +871,11 @@ def getTracker(tracker: UUID): | ||||
|                            key_locations=group_key_locations, small_key_ids=small_key_ids, big_key_ids=big_key_ids, | ||||
|                            video=video, big_key_locations=group_big_key_locations, | ||||
|                            hints=hints, long_player_names=long_player_names) | ||||
|  | ||||
|  | ||||
| game_specific_trackers: typing.Dict[str, typing.Callable] = { | ||||
|     "Minecraft": __renderMinecraftTracker, | ||||
|     "Ocarina of Time": __renderOoTTracker, | ||||
|     "Timespinner": __renderTimespinnerTracker, | ||||
|     "A Link to the Past": __renderAlttpTracker | ||||
| } | ||||
| @@ -98,7 +98,7 @@ def uploads(): | ||||
|                         if type(res) == str: | ||||
|                             return res | ||||
|                         elif res: | ||||
|                             return redirect(url_for("viewSeed", seed=res.id)) | ||||
|                             return redirect(url_for("view_seed", seed=res.id)) | ||||
|                 else: | ||||
|                     try: | ||||
|                         multidata = file.read() | ||||
| @@ -109,7 +109,7 @@ def uploads(): | ||||
|                     else: | ||||
|                         seed = Seed(multidata=multidata, owner=session["_id"]) | ||||
|                         flush()  # place into DB and generate ids | ||||
|                         return redirect(url_for("viewSeed", seed=seed.id)) | ||||
|                         return redirect(url_for("view_seed", seed=seed.id)) | ||||
|             else: | ||||
|                 flash("Not recognized file format. Awaiting a .archipelago file or .zip containing one.") | ||||
|     return render_template("hostGame.html") | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 CaitSith2
					CaitSith2