| 
									
										
										
										
											2020-06-22 20:25:24 +02:00
										 |  |  | import collections | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | from flask import render_template | 
					
						
							|  |  |  | from werkzeug.exceptions import abort | 
					
						
							| 
									
										
										
										
											2020-06-23 14:37:41 +02:00
										 |  |  | import datetime | 
					
						
							| 
									
										
										
										
											2020-06-26 19:29:33 +02:00
										 |  |  | from uuid import UUID | 
					
						
							| 
									
										
										
										
											2020-06-22 20:25:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-19 21:55:18 +02:00
										 |  |  | from worlds.alttp import Items | 
					
						
							| 
									
										
										
										
											2020-07-11 16:59:37 +02:00
										 |  |  | from WebHostLib import app, cache, Room | 
					
						
							| 
									
										
										
										
											2021-04-04 03:18:19 +02:00
										 |  |  | from Utils import restricted_loads | 
					
						
							| 
									
										
										
										
											2021-05-14 01:25:41 +02:00
										 |  |  | from worlds import lookup_any_item_id_to_name, lookup_any_location_id_to_name | 
					
						
							| 
									
										
										
										
											2020-06-22 20:25:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-14 14:38:23 +02:00
										 |  |  | def get_alttp_id(item_name): | 
					
						
							| 
									
										
										
										
											2021-02-01 01:57:44 +01:00
										 |  |  |     return Items.item_table[item_name][2] | 
					
						
							| 
									
										
										
										
											2020-06-22 20:25:24 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-14 01:25:41 +02:00
										 |  |  | app.jinja_env.filters["location_name"] = lambda location: lookup_any_location_id_to_name.get(location, location) | 
					
						
							|  |  |  | app.jinja_env.filters['item_name'] = lambda id: lookup_any_item_id_to_name.get(id, id) | 
					
						
							| 
									
										
										
										
											2020-07-27 19:30:31 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-22 20:25:24 +02:00
										 |  |  | icons = { | 
					
						
							| 
									
										
										
										
											2021-02-25 01:16:22 -05:00
										 |  |  |     "Blue Shield": r"https://www.zeldadungeon.net/wiki/images/8/85/Fighters-Shield.png", | 
					
						
							|  |  |  |     "Red Shield": r"https://www.zeldadungeon.net/wiki/images/5/55/Fire-Shield.png", | 
					
						
							|  |  |  |     "Mirror Shield": r"https://www.zeldadungeon.net/wiki/images/8/84/Mirror-Shield.png", | 
					
						
							| 
									
										
										
										
											2021-02-23 19:34:35 -05:00
										 |  |  |     "Fighter Sword": r"https://oyster.ignimgs.com/mediawiki/apis.ign.com/the-legend-of-zelda-a-link-to-the-past/4/40/SFighterSword.png?width=1920", | 
					
						
							|  |  |  |     "Master Sword": r"https://oyster.ignimgs.com/mediawiki/apis.ign.com/the-legend-of-zelda-a-link-to-the-past/6/65/SMasterSword.png?width=1920", | 
					
						
							|  |  |  |     "Tempered Sword": r"https://oyster.ignimgs.com/mediawiki/apis.ign.com/the-legend-of-zelda-a-link-to-the-past/9/92/STemperedSword.png?width=1920", | 
					
						
							|  |  |  |     "Golden Sword": r"https://oyster.ignimgs.com/mediawiki/apis.ign.com/the-legend-of-zelda-a-link-to-the-past/2/28/SGoldenSword.png?width=1920", | 
					
						
							| 
									
										
										
										
											2021-02-23 22:43:40 -05:00
										 |  |  |     "Bow": r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/b/bc/ALttP_Bow_%26_Arrows_Sprite.png?version=5f85a70e6366bf473544ef93b274f74c", | 
					
						
							|  |  |  |     "Silver Bow": r"https://oyster.ignimgs.com/mediawiki/apis.ign.com/the-legend-of-zelda-a-link-to-the-past/6/65/Bow.png?width=1920", | 
					
						
							| 
									
										
										
										
											2021-02-23 19:34:35 -05:00
										 |  |  |     "Green Mail": r"https://oyster.ignimgs.com/mediawiki/apis.ign.com/the-legend-of-zelda-a-link-to-the-past/c/c9/SGreenTunic.png?width=1920", | 
					
						
							|  |  |  |     "Blue Mail": r"https://oyster.ignimgs.com/mediawiki/apis.ign.com/the-legend-of-zelda-a-link-to-the-past/9/98/SBlueTunic.png?width=1920", | 
					
						
							|  |  |  |     "Red Mail": r"https://oyster.ignimgs.com/mediawiki/apis.ign.com/the-legend-of-zelda-a-link-to-the-past/7/74/SRedTunic.png?width=1920", | 
					
						
							|  |  |  |     "Power Glove": r"https://oyster.ignimgs.com/mediawiki/apis.ign.com/the-legend-of-zelda-a-link-to-the-past/f/f5/SPowerGlove.png?width=1920", | 
					
						
							|  |  |  |     "Titan Mitts": r"https://oyster.ignimgs.com/mediawiki/apis.ign.com/the-legend-of-zelda-a-link-to-the-past/c/c1/STitanMitt.png?width=1920", | 
					
						
							| 
									
										
										
										
											2020-06-22 20:25:24 +02:00
										 |  |  |     "Progressive Sword": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/c/cc/ALttP_Master_Sword_Sprite.png?version=55869db2a20e157cd3b5c8f556097725", | 
					
						
							|  |  |  |     "Pegasus Boots": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/e/ed/ALttP_Pegasus_Shoes_Sprite.png?version=405f42f97240c9dcd2b71ffc4bebc7f9", | 
					
						
							|  |  |  |     "Progressive Glove": | 
					
						
							| 
									
										
										
										
											2021-02-23 19:34:35 -05:00
										 |  |  |         r"https://oyster.ignimgs.com/mediawiki/apis.ign.com/the-legend-of-zelda-a-link-to-the-past/c/c1/STitanMitt.png?width=1920", | 
					
						
							| 
									
										
										
										
											2020-06-22 20:25:24 +02:00
										 |  |  |     "Flippers": | 
					
						
							| 
									
										
										
										
											2021-02-23 19:34:35 -05:00
										 |  |  |         r"https://oyster.ignimgs.com/mediawiki/apis.ign.com/the-legend-of-zelda-a-link-to-the-past/4/4c/ZoraFlippers.png?width=1920", | 
					
						
							| 
									
										
										
										
											2020-06-22 20:25:24 +02:00
										 |  |  |     "Moon Pearl": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/6/63/ALttP_Moon_Pearl_Sprite.png?version=d601542d5abcc3e006ee163254bea77e", | 
					
						
							|  |  |  |     "Progressive Bow": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/b/bc/ALttP_Bow_%26_Arrows_Sprite.png?version=cfb7648b3714cccc80e2b17b2adf00ed", | 
					
						
							|  |  |  |     "Blue Boomerang": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/c/c3/ALttP_Boomerang_Sprite.png?version=96127d163759395eb510b81a556d500e", | 
					
						
							|  |  |  |     "Red Boomerang": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/b/b9/ALttP_Magical_Boomerang_Sprite.png?version=47cddce7a07bc3e4c2c10727b491f400", | 
					
						
							|  |  |  |     "Hookshot": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/2/24/Hookshot.png?version=c90bc8e07a52e8090377bd6ef854c18b", | 
					
						
							|  |  |  |     "Mushroom": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/3/35/ALttP_Mushroom_Sprite.png?version=1f1acb30d71bd96b60a3491e54bbfe59", | 
					
						
							|  |  |  |     "Magic Powder": | 
					
						
							| 
									
										
										
										
											2020-07-26 08:25:54 -04:00
										 |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/e/e5/ALttP_Magic_Powder_Sprite.png?version=c24e38effbd4f80496d35830ce8ff4ec", | 
					
						
							| 
									
										
										
										
											2020-06-22 20:25:24 +02:00
										 |  |  |     "Fire Rod": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/d/d6/FireRod.png?version=6eabc9f24d25697e2c4cd43ddc8207c0", | 
					
						
							|  |  |  |     "Ice Rod": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/d/d7/ALttP_Ice_Rod_Sprite.png?version=1f944148223d91cfc6a615c92286c3bc", | 
					
						
							|  |  |  |     "Bombos": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/8/8c/ALttP_Bombos_Medallion_Sprite.png?version=f4d6aba47fb69375e090178f0fc33b26", | 
					
						
							|  |  |  |     "Ether": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/3/3c/Ether.png?version=34027651a5565fcc5a83189178ab17b5", | 
					
						
							|  |  |  |     "Quake": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/5/56/ALttP_Quake_Medallion_Sprite.png?version=efd64d451b1831bd59f7b7d6b61b5879", | 
					
						
							|  |  |  |     "Lamp": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/6/63/ALttP_Lantern_Sprite.png?version=e76eaa1ec509c9a5efb2916698d5a4ce", | 
					
						
							|  |  |  |     "Hammer": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/d/d1/ALttP_Hammer_Sprite.png?version=e0adec227193818dcaedf587eba34500", | 
					
						
							|  |  |  |     "Shovel": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/c/c4/ALttP_Shovel_Sprite.png?version=e73d1ce0115c2c70eaca15b014bd6f05", | 
					
						
							|  |  |  |     "Flute": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/d/db/Flute.png?version=ec4982b31c56da2c0c010905c5c60390", | 
					
						
							|  |  |  |     "Bug Catching Net": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/5/54/Bug-CatchingNet.png?version=4d40e0ee015b687ff75b333b968d8be6", | 
					
						
							|  |  |  |     "Book of Mudora": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/2/22/ALttP_Book_of_Mudora_Sprite.png?version=11e4632bba54f6b9bf921df06ac93744", | 
					
						
							|  |  |  |     "Bottle": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/e/ef/ALttP_Magic_Bottle_Sprite.png?version=fd98ab04db775270cbe79fce0235777b", | 
					
						
							|  |  |  |     "Cane of Somaria": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/e/e1/ALttP_Cane_of_Somaria_Sprite.png?version=8cc1900dfd887890badffc903bb87943", | 
					
						
							|  |  |  |     "Cane of Byrna": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/b/bc/ALttP_Cane_of_Byrna_Sprite.png?version=758b607c8cbe2cf1900d42a0b3d0fb54", | 
					
						
							|  |  |  |     "Cape": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/1/1c/ALttP_Magic_Cape_Sprite.png?version=6b77f0d609aab0c751307fc124736832", | 
					
						
							|  |  |  |     "Magic Mirror": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/e/e5/ALttP_Magic_Mirror_Sprite.png?version=e035dbc9cbe2a3bd44aa6d047762b0cc", | 
					
						
							|  |  |  |     "Triforce": | 
					
						
							| 
									
										
										
										
											2020-06-24 16:06:19 +02:00
										 |  |  |         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": | 
					
						
							| 
									
										
										
										
											2020-07-19 22:32:56 +02:00
										 |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/7/73/ALttP_Treasure_Chest_Sprite.png?version=5f530ecd98dcb22251e146e8049c0dda", | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     "Light World": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/e/e7/ALttP_Soldier_Green_Sprite.png?version=d650d417934cd707a47e496489c268a6", | 
					
						
							|  |  |  |     "Dark World": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/9/94/ALttP_Moblin_Sprite.png?version=ebf50e33f4657c377d1606bcc0886ddc", | 
					
						
							|  |  |  |     "Hyrule Castle": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/d/d3/ALttP_Ball_and_Chain_Trooper_Sprite.png?version=1768a87c06d29cc8e7ddd80b9fa516be", | 
					
						
							|  |  |  |     "Agahnims Tower": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/1/1e/ALttP_Agahnim_Sprite.png?version=365956e61b0c2191eae4eddbe591dab5", | 
					
						
							|  |  |  |     "Desert Palace": | 
					
						
							|  |  |  |         r"https://www.zeldadungeon.net/wiki/images/2/25/Lanmola-ALTTP-Sprite.png", | 
					
						
							|  |  |  |     "Eastern Palace": | 
					
						
							|  |  |  |         r"https://www.zeldadungeon.net/wiki/images/d/dc/RedArmosKnight.png", | 
					
						
							|  |  |  |     "Tower of Hera": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/3/3c/ALttP_Moldorm_Sprite.png?version=c588257bdc2543468e008a6b30f262a7", | 
					
						
							|  |  |  |     "Palace of Darkness": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/e/ed/ALttP_Helmasaur_King_Sprite.png?version=ab8a4a1cfd91d4fc43466c56cba30022", | 
					
						
							|  |  |  |     "Swamp Palace": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/7/73/ALttP_Arrghus_Sprite.png?version=b098be3122e53f751b74f4a5ef9184b5", | 
					
						
							|  |  |  |     "Skull Woods": | 
					
						
							|  |  |  |         r"https://alttp-wiki.net/images/6/6a/Mothula.png", | 
					
						
							|  |  |  |     "Thieves Town": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/8/86/ALttP_Blind_the_Thief_Sprite.png?version=3833021bfcd112be54e7390679047222", | 
					
						
							|  |  |  |     "Ice Palace": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/3/33/ALttP_Kholdstare_Sprite.png?version=e5a1b0e8b2298e550d85f90bf97045c0", | 
					
						
							|  |  |  |     "Misery Mire": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/8/85/ALttP_Vitreous_Sprite.png?version=92b2e9cb0aa63f831760f08041d8d8d8", | 
					
						
							|  |  |  |     "Turtle Rock": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/9/91/ALttP_Trinexx_Sprite.png?version=0cc867d513952aa03edd155597a0c0be", | 
					
						
							|  |  |  |     "Ganons Tower": | 
					
						
							|  |  |  |         r"https://gamepedia.cursecdn.com/zelda_gamepedia_en/b/b9/ALttP_Ganon_Sprite.png?version=956f51f054954dfff53c1a9d4f929c74" | 
					
						
							| 
									
										
										
										
											2020-06-22 20:25:24 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | links = {"Bow": "Progressive Bow", | 
					
						
							|  |  |  |          "Silver Arrows": "Progressive Bow", | 
					
						
							| 
									
										
										
										
											2020-06-30 09:51:11 +02:00
										 |  |  |          "Silver Bow": "Progressive Bow", | 
					
						
							| 
									
										
										
										
											2020-06-22 20:25:24 +02:00
										 |  |  |          "Progressive Bow (Alt)": "Progressive Bow", | 
					
						
							|  |  |  |          "Bottle (Red Potion)": "Bottle", | 
					
						
							|  |  |  |          "Bottle (Green Potion)": "Bottle", | 
					
						
							|  |  |  |          "Bottle (Blue Potion)": "Bottle", | 
					
						
							|  |  |  |          "Bottle (Fairy)": "Bottle", | 
					
						
							|  |  |  |          "Bottle (Bee)": "Bottle", | 
					
						
							|  |  |  |          "Bottle (Good Bee)": "Bottle", | 
					
						
							|  |  |  |          "Fighter Sword": "Progressive Sword", | 
					
						
							|  |  |  |          "Master Sword": "Progressive Sword", | 
					
						
							|  |  |  |          "Tempered Sword": "Progressive Sword", | 
					
						
							|  |  |  |          "Golden Sword": "Progressive Sword", | 
					
						
							|  |  |  |          "Power Glove": "Progressive Glove", | 
					
						
							|  |  |  |          "Titans Mitts": "Progressive Glove" | 
					
						
							|  |  |  |          } | 
					
						
							| 
									
										
										
										
											2020-06-23 23:50:37 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | levels = {"Fighter Sword": 1, | 
					
						
							|  |  |  |           "Master Sword": 2, | 
					
						
							|  |  |  |           "Tempered Sword": 3, | 
					
						
							|  |  |  |           "Golden Sword": 4, | 
					
						
							|  |  |  |           "Power Glove": 1, | 
					
						
							| 
									
										
										
										
											2020-06-30 09:51:11 +02:00
										 |  |  |           "Titans Mitts": 2, | 
					
						
							| 
									
										
										
										
											2020-07-12 23:27:21 +02:00
										 |  |  |           "Bow": 1, | 
					
						
							| 
									
										
										
										
											2020-06-30 09:51:11 +02:00
										 |  |  |           "Silver Bow": 2} | 
					
						
							| 
									
										
										
										
											2020-06-23 23:50:37 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-14 14:38:23 +02:00
										 |  |  | multi_items = {get_alttp_id(name) for name in ("Progressive Sword", "Progressive Bow", "Bottle", "Progressive Glove")} | 
					
						
							|  |  |  | links = {get_alttp_id(key): get_alttp_id(value) for key, value in links.items()} | 
					
						
							|  |  |  | levels = {get_alttp_id(key): value for key, value in levels.items()} | 
					
						
							| 
									
										
										
										
											2020-06-22 20:25:24 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | tracking_names = ["Progressive Sword", "Progressive Bow", "Book of Mudora", "Hammer", | 
					
						
							|  |  |  |                   "Hookshot", "Magic Mirror", "Flute", | 
					
						
							|  |  |  |                   "Pegasus Boots", "Progressive Glove", "Flippers", "Moon Pearl", "Blue Boomerang", | 
					
						
							|  |  |  |                   "Red Boomerang", "Bug Catching Net", "Cape", "Shovel", "Lamp", | 
					
						
							|  |  |  |                   "Mushroom", "Magic Powder", | 
					
						
							|  |  |  |                   "Cane of Somaria", "Cane of Byrna", "Fire Rod", "Ice Rod", "Bombos", "Ether", "Quake", | 
					
						
							| 
									
										
										
										
											2021-03-06 05:59:49 +01:00
										 |  |  |                   "Bottle", "Triforce"] | 
					
						
							| 
									
										
										
										
											2020-06-22 20:25:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-23 02:50:07 +02:00
										 |  |  | default_locations = { | 
					
						
							|  |  |  |     'Light World': {1572864, 1572865, 60034, 1572867, 1572868, 60037, 1572869, 1572866, 60040, 59788, 60046, 60175, | 
					
						
							|  |  |  |                     1572880, 60049, 60178, 1572883, 60052, 60181, 1572885, 60055, 60184, 191256, 60058, 60187, 1572884, | 
					
						
							|  |  |  |                     1572886, 1572887, 1572906, 60202, 60205, 59824, 166320, 1010170, 60208, 60211, 60214, 60217, 59836, | 
					
						
							|  |  |  |                     60220, 60223, 59839, 1573184, 60226, 975299, 1573188, 1573189, 188229, 60229, 60232, 1573193, | 
					
						
							|  |  |  |                     1573194, 60235, 1573187, 59845, 59854, 211407, 60238, 59857, 1573185, 1573186, 1572882, 212328, | 
					
						
							|  |  |  |                     59881, 59761, 59890, 59770, 193020, 212605}, | 
					
						
							|  |  |  |     'Dark World': {59776, 59779, 975237, 1572870, 60043, 1572881, 60190, 60193, 60196, 60199, 60840, 1573190, 209095, | 
					
						
							|  |  |  |                    1573192, 1573191, 60241, 60244, 60247, 60250, 59884, 59887, 60019, 60022, 60028, 60031}, | 
					
						
							|  |  |  |     'Desert Palace': {1573216, 59842, 59851, 59791, 1573201, 59830}, | 
					
						
							|  |  |  |     'Eastern Palace': {1573200, 59827, 59893, 59767, 59833, 59773}, | 
					
						
							|  |  |  |     'Hyrule Castle': {60256, 60259, 60169, 60172, 59758, 59764, 60025, 60253}, | 
					
						
							|  |  |  |     'Agahnims Tower': {60082, 60085}, | 
					
						
							|  |  |  |     'Tower of Hera': {1573218, 59878, 59821, 1573202, 59896, 59899}, | 
					
						
							|  |  |  |     'Swamp Palace': {60064, 60067, 60070, 59782, 59785, 60073, 60076, 60079, 1573204, 60061}, | 
					
						
							|  |  |  |     'Thieves Town': {59905, 59908, 59911, 59914, 59917, 59920, 59923, 1573206}, | 
					
						
							|  |  |  |     'Skull Woods': {59809, 59902, 59848, 59794, 1573205, 59800, 59803, 59806}, | 
					
						
							|  |  |  |     'Ice Palace': {59872, 59875, 59812, 59818, 59860, 59797, 1573207, 59869}, | 
					
						
							|  |  |  |     'Misery Mire': {60001, 60004, 60007, 60010, 60013, 1573208, 59866, 59998}, | 
					
						
							|  |  |  |     'Turtle Rock': {59938, 59941, 59944, 1573209, 59947, 59950, 59953, 59956, 59926, 59929, 59932, 59935}, | 
					
						
							|  |  |  |     'Palace of Darkness': {59968, 59971, 59974, 59977, 59980, 59983, 59986, 1573203, 59989, 59959, 59992, 59962, 59995, | 
					
						
							|  |  |  |                            59965}, | 
					
						
							|  |  |  |     'Ganons Tower': {60160, 60163, 60166, 60088, 60091, 60094, 60097, 60100, 60103, 60106, 60109, 60112, 60115, 60118, | 
					
						
							| 
									
										
										
										
											2020-06-23 05:46:32 +02:00
										 |  |  |                      60121, 60124, 60127, 1573217, 60130, 60133, 60136, 60139, 60142, 60145, 60148, 60151, 60157}, | 
					
						
							|  |  |  |     'Total': set()} | 
					
						
							| 
									
										
										
										
											2020-06-24 16:06:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-27 00:47:59 -07:00
										 |  |  | key_only_locations = { | 
					
						
							|  |  |  |     'Light World': set(), | 
					
						
							|  |  |  |     'Dark World': set(), | 
					
						
							|  |  |  |     'Desert Palace': {0x140031, 0x14002b, 0x140061, 0x140028}, | 
					
						
							|  |  |  |     'Eastern Palace': {0x14005b, 0x140049}, | 
					
						
							|  |  |  |     'Hyrule Castle': {0x140037, 0x140034, 0x14000d, 0x14003d}, | 
					
						
							|  |  |  |     'Agahnims Tower': {0x140061, 0x140052}, | 
					
						
							|  |  |  |     'Tower of Hera': set(), | 
					
						
							|  |  |  |     'Swamp Palace': {0x140019, 0x140016, 0x140013, 0x140010, 0x14000a}, | 
					
						
							|  |  |  |     'Thieves Town': {0x14005e, 0x14004f}, | 
					
						
							|  |  |  |     'Skull Woods': {0x14002e, 0x14001c}, | 
					
						
							|  |  |  |     'Ice Palace': {0x140004, 0x140022, 0x140025, 0x140046}, | 
					
						
							|  |  |  |     'Misery Mire': {0x140055, 0x14004c, 0x140064}, | 
					
						
							|  |  |  |     'Turtle Rock': {0x140058, 0x140007}, | 
					
						
							|  |  |  |     'Palace of Darkness': set(), | 
					
						
							|  |  |  |     'Ganons Tower': {0x140040, 0x140043, 0x14003a, 0x14001f}, | 
					
						
							|  |  |  |     'Total': set() | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-24 16:06:19 +02:00
										 |  |  | 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"} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-19 21:15:55 +02:00
										 |  |  | big_key_locations = {"Desert Palace", "Eastern Palace", "Tower of Hera", "Swamp Palace", "Thieves Town", "Skull Woods", | 
					
						
							|  |  |  |                      "Ice Palace", "Misery Mire", "Turtle Rock", "Palace of Darkness", "Ganons Tower"} | 
					
						
							| 
									
										
										
										
											2020-06-23 02:50:07 +02:00
										 |  |  | location_to_area = {} | 
					
						
							|  |  |  | for area, locations in default_locations.items(): | 
					
						
							|  |  |  |     for location in locations: | 
					
						
							|  |  |  |         location_to_area[location] = area | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-27 00:47:59 -07:00
										 |  |  | for area, locations in key_only_locations.items(): | 
					
						
							|  |  |  |     for location in locations: | 
					
						
							|  |  |  |         location_to_area[location] = area | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-23 02:50:07 +02:00
										 |  |  | checks_in_area = {area: len(checks) for area, checks in default_locations.items()} | 
					
						
							| 
									
										
										
										
											2020-06-23 05:46:32 +02:00
										 |  |  | checks_in_area["Total"] = 216 | 
					
						
							| 
									
										
										
										
											2020-06-23 02:50:07 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | ordered_areas = ('Light World', 'Dark World', 'Hyrule Castle', 'Agahnims Tower', 'Eastern Palace', 'Desert Palace', | 
					
						
							|  |  |  |                  'Tower of Hera', 'Palace of Darkness', 'Swamp Palace', 'Skull Woods', 'Thieves Town', 'Ice Palace', | 
					
						
							| 
									
										
										
										
											2020-06-23 05:46:32 +02:00
										 |  |  |                  'Misery Mire', 'Turtle Rock', 'Ganons Tower', "Total") | 
					
						
							| 
									
										
										
										
											2020-06-23 02:50:07 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-22 20:25:24 +02:00
										 |  |  | tracking_ids = [] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | for item in tracking_names: | 
					
						
							| 
									
										
										
										
											2021-05-14 14:38:23 +02:00
										 |  |  |     tracking_ids.append(get_alttp_id(item)) | 
					
						
							| 
									
										
										
										
											2020-06-22 20:25:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-24 16:06:19 +02:00
										 |  |  | small_key_ids = {} | 
					
						
							|  |  |  | big_key_ids = {} | 
					
						
							| 
									
										
										
										
											2021-03-06 13:59:04 -08:00
										 |  |  | ids_small_key = {} | 
					
						
							|  |  |  | ids_big_key = {} | 
					
						
							| 
									
										
										
										
											2020-06-24 16:06:19 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 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: | 
					
						
							| 
									
										
										
										
											2021-02-01 01:57:44 +01:00
										 |  |  |             small_key_ids[area] = data[2] | 
					
						
							| 
									
										
										
										
											2021-03-06 13:59:04 -08:00
										 |  |  |             ids_small_key[data[2]] = area | 
					
						
							| 
									
										
										
										
											2020-06-24 16:06:19 +02:00
										 |  |  |         else: | 
					
						
							| 
									
										
										
										
											2021-02-01 01:57:44 +01:00
										 |  |  |             big_key_ids[area] = data[2] | 
					
						
							| 
									
										
										
										
											2021-03-06 13:59:04 -08:00
										 |  |  |             ids_big_key[data[2]] = area | 
					
						
							| 
									
										
										
										
											2020-06-24 16:06:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-04 03:18:19 +02:00
										 |  |  | from MultiServer import get_item_name_from_id, Context | 
					
						
							| 
									
										
										
										
											2020-06-22 20:25:24 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-23 23:50:37 +02:00
										 |  |  | def attribute_item(inventory, team, recipient, item): | 
					
						
							|  |  |  |     target_item = links.get(item, item) | 
					
						
							|  |  |  |     if item in levels:  # non-progressive | 
					
						
							|  |  |  |         inventory[team][recipient][target_item] = max(inventory[team][recipient][target_item], levels[item]) | 
					
						
							|  |  |  |     else: | 
					
						
							|  |  |  |         inventory[team][recipient][target_item] += 1 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-24 16:06:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-23 00:05:31 -05:00
										 |  |  | def attribute_item_solo(inventory, item): | 
					
						
							| 
									
										
										
										
											2021-05-13 21:57:11 +02:00
										 |  |  |     """Adds item to inventory counter, converts everything to progressive.""" | 
					
						
							| 
									
										
										
										
											2021-02-23 00:05:31 -05:00
										 |  |  |     target_item = links.get(item, item) | 
					
						
							|  |  |  |     if item in levels:  # non-progressive | 
					
						
							|  |  |  |         inventory[target_item] = max(inventory[target_item], levels[item]) | 
					
						
							|  |  |  |     else: | 
					
						
							|  |  |  |         inventory[target_item] += 1 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-24 16:06:19 +02:00
										 |  |  | @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}" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-28 09:28:13 +02:00
										 |  |  | _multidata_cache = {} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-29 15:18:59 -07:00
										 |  |  | def get_location_table(checks_table: dict) -> dict: | 
					
						
							|  |  |  |     loc_to_area = {} | 
					
						
							|  |  |  |     for area, locations in checks_table.items(): | 
					
						
							|  |  |  |         if area == "Total": | 
					
						
							|  |  |  |             continue | 
					
						
							|  |  |  |         for location in locations: | 
					
						
							|  |  |  |             loc_to_area[location] = area | 
					
						
							|  |  |  |     return loc_to_area | 
					
						
							| 
									
										
										
										
											2020-06-28 09:28:13 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | def get_static_room_data(room: Room): | 
					
						
							|  |  |  |     result = _multidata_cache.get(room.seed.id, None) | 
					
						
							|  |  |  |     if result: | 
					
						
							|  |  |  |         return result | 
					
						
							| 
									
										
										
										
											2021-04-04 03:18:19 +02:00
										 |  |  |     multidata = Context._decompress(room.seed.multidata) | 
					
						
							| 
									
										
										
										
											2020-06-28 09:28:13 +02:00
										 |  |  |     # in > 100 players this can take a bit of time and is the main reason for the cache | 
					
						
							| 
									
										
										
										
											2021-04-04 03:18:19 +02:00
										 |  |  |     locations = multidata['locations'] | 
					
						
							| 
									
										
										
										
											2020-06-28 09:28:13 +02:00
										 |  |  |     names = multidata["names"] | 
					
						
							| 
									
										
										
										
											2020-10-27 00:47:59 -07:00
										 |  |  |     seed_checks_in_area = checks_in_area.copy() | 
					
						
							| 
									
										
										
										
											2020-07-19 21:15:55 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     use_door_tracker = False | 
					
						
							|  |  |  |     if "tags" in multidata: | 
					
						
							| 
									
										
										
										
											2020-07-21 23:15:19 +02:00
										 |  |  |         use_door_tracker = "DR" in multidata["tags"] | 
					
						
							| 
									
										
										
										
											2020-10-27 00:47:59 -07:00
										 |  |  |     if use_door_tracker: | 
					
						
							|  |  |  |         for area, checks in key_only_locations.items(): | 
					
						
							|  |  |  |             seed_checks_in_area[area] += len(checks) | 
					
						
							|  |  |  |         seed_checks_in_area["Total"] = 249 | 
					
						
							| 
									
										
										
										
											2020-10-29 15:18:59 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-04 03:18:19 +02:00
										 |  |  |     player_checks_in_area = {playernumber: {areaname: len(multidata["checks_in_area"][playernumber][areaname]) | 
					
						
							|  |  |  |                                             if areaname != "Total" else multidata["checks_in_area"][playernumber]["Total"] | 
					
						
							|  |  |  |                                             for areaname in ordered_areas} | 
					
						
							|  |  |  |                              for playernumber in range(1, len(names[0]) + 1)} | 
					
						
							|  |  |  |     player_location_to_area = {playernumber: get_location_table(multidata["checks_in_area"][playernumber]) | 
					
						
							|  |  |  |                                for playernumber in range(1, len(names[0]) + 1)} | 
					
						
							| 
									
										
										
										
											2021-03-06 13:59:04 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     player_big_key_locations = {playernumber: set() for playernumber in range(1, len(names[0]) + 1)} | 
					
						
							|  |  |  |     player_small_key_locations = {playernumber: set() for playernumber in range(1, len(names[0]) + 1)} | 
					
						
							| 
									
										
										
										
											2021-05-13 21:57:11 +02:00
										 |  |  |     for loc_data in locations.values(): | 
					
						
							|  |  |  |         for item_id, item_player in loc_data.values(): | 
					
						
							|  |  |  |             if item_id in ids_big_key: | 
					
						
							|  |  |  |                 player_big_key_locations[item_player].add(ids_big_key[item_id]) | 
					
						
							|  |  |  |             elif item_id in ids_small_key: | 
					
						
							|  |  |  |                 player_small_key_locations[item_player].add(ids_small_key[item_id]) | 
					
						
							| 
									
										
										
										
											2021-03-06 13:59:04 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-04 03:18:19 +02:00
										 |  |  |     result = locations, names, use_door_tracker, player_checks_in_area, player_location_to_area, \ | 
					
						
							| 
									
										
										
										
											2021-05-19 21:55:18 +02:00
										 |  |  |              player_big_key_locations, player_small_key_locations, multidata["precollected_items"], \ | 
					
						
							|  |  |  |              multidata["games"] | 
					
						
							| 
									
										
										
										
											2020-07-19 21:15:55 +02:00
										 |  |  |     _multidata_cache[room.seed.id] = result | 
					
						
							|  |  |  |     return result | 
					
						
							| 
									
										
										
										
											2020-06-28 09:28:13 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-06 05:59:49 +01:00
										 |  |  | @app.route('/tracker/<suuid:tracker>/<int:tracked_team>/<int:tracked_player>') | 
					
						
							| 
									
										
										
										
											2021-05-13 21:57:11 +02:00
										 |  |  | @cache.memoize(timeout=60)  # multisave is currently created at most every minute | 
					
						
							| 
									
										
										
										
											2021-03-06 05:59:49 +01:00
										 |  |  | def getPlayerTracker(tracker: UUID, tracked_team: int, tracked_player: int): | 
					
						
							| 
									
										
										
										
											2021-02-23 00:05:31 -05:00
										 |  |  |     # Team and player must be positive and greater than zero | 
					
						
							| 
									
										
										
										
											2021-03-06 05:59:49 +01:00
										 |  |  |     if tracked_team < 0 or tracked_player < 1: | 
					
						
							| 
									
										
										
										
											2021-02-23 00:05:31 -05:00
										 |  |  |         abort(404) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-21 00:38:53 -05:00
										 |  |  |     room = Room.get(tracker=tracker) | 
					
						
							|  |  |  |     if not room: | 
					
						
							|  |  |  |         abort(404) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-23 00:05:31 -05:00
										 |  |  |     # Collect seed information and pare it down to a single player | 
					
						
							| 
									
										
										
										
											2021-05-19 21:55:18 +02:00
										 |  |  |     locations, names, use_door_tracker, seed_checks_in_area, player_location_to_area, \ | 
					
						
							|  |  |  |     player_big_key_locations, player_small_key_locations, precollected_items, games = get_static_room_data(room) | 
					
						
							| 
									
										
										
										
											2021-03-06 05:59:49 +01:00
										 |  |  |     player_name = names[tracked_team][tracked_player - 1] | 
					
						
							|  |  |  |     location_to_area = player_location_to_area[tracked_player] | 
					
						
							| 
									
										
										
										
											2021-02-21 00:38:53 -05:00
										 |  |  |     inventory = collections.Counter() | 
					
						
							|  |  |  |     checks_done = {loc_name: 0 for loc_name in default_locations} | 
					
						
							| 
									
										
										
										
											2021-02-23 00:05:31 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Add starting items to inventory | 
					
						
							| 
									
										
										
										
											2021-05-09 21:22:21 +02:00
										 |  |  |     starting_items = precollected_items[tracked_player] | 
					
						
							| 
									
										
										
										
											2021-02-23 00:05:31 -05:00
										 |  |  |     if starting_items: | 
					
						
							|  |  |  |         for item_id in starting_items: | 
					
						
							|  |  |  |             attribute_item_solo(inventory, item_id) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-04 03:18:19 +02:00
										 |  |  |     if room.multisave: | 
					
						
							|  |  |  |         multisave = restricted_loads(room.multisave) | 
					
						
							|  |  |  |     else: | 
					
						
							|  |  |  |         multisave = {} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-23 00:05:31 -05:00
										 |  |  |     # Add items to player inventory | 
					
						
							| 
									
										
										
										
											2021-05-13 21:57:11 +02:00
										 |  |  |     for (ms_team, ms_player), locations_checked in multisave.get("location_checks", {}).items(): | 
					
						
							| 
									
										
										
										
											2021-03-05 13:38:04 -08:00
										 |  |  |         # logging.info(f"{ms_team}, {ms_player}, {locations_checked}") | 
					
						
							| 
									
										
										
										
											2021-02-23 00:05:31 -05:00
										 |  |  |         # Skip teams and players not matching the request | 
					
						
							| 
									
										
										
										
											2021-05-13 21:57:11 +02:00
										 |  |  |         player_locations = locations[ms_player] | 
					
						
							| 
									
										
										
										
											2021-03-06 05:59:49 +01:00
										 |  |  |         if ms_team == tracked_team: | 
					
						
							|  |  |  |             # If the player does not have the item, do nothing | 
					
						
							|  |  |  |             for location in locations_checked: | 
					
						
							| 
									
										
										
										
											2021-05-13 21:57:11 +02:00
										 |  |  |                 if location in player_locations: | 
					
						
							|  |  |  |                     item, recipient = player_locations[location] | 
					
						
							|  |  |  |                     if recipient == tracked_player: # a check done for the tracked player | 
					
						
							|  |  |  |                         attribute_item_solo(inventory, item) | 
					
						
							|  |  |  |                     if ms_player == tracked_player: # a check done by the tracked player | 
					
						
							|  |  |  |                         checks_done[location_to_area[location]] += 1 | 
					
						
							|  |  |  |                         checks_done["Total"] += 1 | 
					
						
							| 
									
										
										
										
											2021-05-19 21:55:18 +02:00
										 |  |  |     if games[tracked_player] == "A Link to the Past": | 
					
						
							|  |  |  |         # Note the presence of the triforce item | 
					
						
							|  |  |  |         game_state = multisave.get("client_game_state", {}).get((tracked_team, tracked_player), 0) | 
					
						
							|  |  |  |         if game_state == 30: | 
					
						
							|  |  |  |             inventory[106] = 1  # Triforce | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # Progressive items need special handling for icons and class | 
					
						
							|  |  |  |         progressive_items = { | 
					
						
							|  |  |  |             "Progressive Sword": 94, | 
					
						
							|  |  |  |             "Progressive Glove": 97, | 
					
						
							|  |  |  |             "Progressive Bow": 100, | 
					
						
							|  |  |  |             "Progressive Mail": 96, | 
					
						
							|  |  |  |             "Progressive Shield": 95, | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         progressive_names = { | 
					
						
							|  |  |  |             "Progressive Sword": [None, 'Fighter Sword', 'Master Sword', 'Tempered Sword', 'Golden Sword'], | 
					
						
							|  |  |  |             "Progressive Glove": [None, 'Power Glove', 'Titan Mitts'], | 
					
						
							|  |  |  |             "Progressive Bow": [None, "Bow", "Silver Bow"], | 
					
						
							|  |  |  |             "Progressive Mail": ["Green Mail", "Blue Mail", "Red Mail"], | 
					
						
							|  |  |  |             "Progressive Shield": [None, "Blue Shield", "Red Shield", "Mirror Shield"] | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # Determine which icon to use | 
					
						
							|  |  |  |         display_data = {} | 
					
						
							|  |  |  |         for item_name, item_id in progressive_items.items(): | 
					
						
							| 
									
										
										
										
											2021-06-03 01:02:31 +02:00
										 |  |  |             level = min(inventory[item_id], len(progressive_names[item_name])-1) | 
					
						
							| 
									
										
										
										
											2021-05-19 21:55:18 +02:00
										 |  |  |             display_name = progressive_names[item_name][level] | 
					
						
							|  |  |  |             acquired = True | 
					
						
							|  |  |  |             if not display_name: | 
					
						
							|  |  |  |                 acquired = False | 
					
						
							|  |  |  |                 display_name = progressive_names[item_name][level+1] | 
					
						
							|  |  |  |             base_name = item_name.split(maxsplit=1)[1].lower() | 
					
						
							|  |  |  |             display_data[base_name+"_acquired"] = acquired | 
					
						
							|  |  |  |             display_data[base_name+"_url"] = icons[display_name] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # The single player tracker doesn't care about overworld, underworld, and total checks. Maybe it should? | 
					
						
							|  |  |  |         sp_areas = ordered_areas[2:15] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return render_template("lttpTracker.html", inventory=inventory, | 
					
						
							|  |  |  |                                player_name=player_name, room=room, icons=icons, checks_done=checks_done, | 
					
						
							|  |  |  |                                checks_in_area=seed_checks_in_area[tracked_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, | 
					
						
							|  |  |  |                                key_locations=player_small_key_locations[tracked_player], | 
					
						
							|  |  |  |                                big_key_locations=player_big_key_locations[tracked_player], | 
					
						
							|  |  |  |                                **display_data) | 
					
						
							|  |  |  |     else: | 
					
						
							| 
									
										
										
										
											2021-05-20 01:22:18 +02:00
										 |  |  |         checked_locations = multisave.get("location_checks", {}).get((tracked_team, tracked_player), set()) | 
					
						
							| 
									
										
										
										
											2021-05-19 21:55:18 +02:00
										 |  |  |         return render_template("genericTracker.html", | 
					
						
							| 
									
										
										
										
											2021-05-19 21:57:10 +02:00
										 |  |  |                                inventory=inventory, | 
					
						
							| 
									
										
										
										
											2021-05-19 21:55:18 +02:00
										 |  |  |                                player=tracked_player, team=tracked_team, room=room, player_name=player_name, | 
					
						
							|  |  |  |                                checked_locations= checked_locations, not_checked_locations = set(locations[tracked_player])-checked_locations) | 
					
						
							| 
									
										
										
										
											2021-02-21 00:38:53 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-27 05:04:49 +02:00
										 |  |  | @app.route('/tracker/<suuid:tracker>') | 
					
						
							| 
									
										
										
										
											2021-05-13 21:57:11 +02:00
										 |  |  | @cache.memoize(timeout=60)  # multisave is currently created at most every minute | 
					
						
							| 
									
										
										
										
											2020-11-30 21:15:47 -05:00
										 |  |  | def getTracker(tracker: UUID): | 
					
						
							| 
									
										
										
										
											2020-06-26 19:29:33 +02:00
										 |  |  |     room = Room.get(tracker=tracker) | 
					
						
							| 
									
										
										
										
											2020-06-22 20:25:24 +02:00
										 |  |  |     if not room: | 
					
						
							|  |  |  |         abort(404) | 
					
						
							| 
									
										
										
										
											2021-04-04 03:18:19 +02:00
										 |  |  |     locations, names, use_door_tracker, seed_checks_in_area, player_location_to_area, player_big_key_locations, \ | 
					
						
							| 
									
										
										
										
											2021-05-19 21:55:18 +02:00
										 |  |  |     player_small_key_locations, precollected_items, games = get_static_room_data(room) | 
					
						
							| 
									
										
										
										
											2020-06-26 19:29:33 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     inventory = {teamnumber: {playernumber: collections.Counter() for playernumber in range(1, len(team) + 1)} | 
					
						
							| 
									
										
										
										
											2020-06-28 09:28:13 +02:00
										 |  |  |                  for teamnumber, team in enumerate(names)} | 
					
						
							| 
									
										
										
										
											2020-06-26 19:29:33 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     checks_done = {teamnumber: {playernumber: {loc_name: 0 for loc_name in default_locations} | 
					
						
							|  |  |  |                                 for playernumber in range(1, len(team) + 1)} | 
					
						
							| 
									
										
										
										
											2020-06-28 09:28:13 +02:00
										 |  |  |                    for teamnumber, team in enumerate(names)} | 
					
						
							| 
									
										
										
										
											2021-04-04 03:18:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-27 19:30:31 +02:00
										 |  |  |     hints = {team: set() for team in range(len(names))} | 
					
						
							| 
									
										
										
										
											2021-04-04 03:18:19 +02:00
										 |  |  |     if room.multisave: | 
					
						
							|  |  |  |         multisave = restricted_loads(room.multisave) | 
					
						
							|  |  |  |     else: | 
					
						
							|  |  |  |         multisave = {} | 
					
						
							|  |  |  |     if "hints" in multisave: | 
					
						
							| 
									
										
										
										
											2021-05-13 21:57:11 +02:00
										 |  |  |         for (team, slot), slot_hints in multisave["hints"].items(): | 
					
						
							|  |  |  |             hints[team] |= set(slot_hints) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (team, player), locations_checked in multisave.get("location_checks", {}).items(): | 
					
						
							|  |  |  |         player_locations = locations[player] | 
					
						
							| 
									
										
										
										
											2020-06-26 19:29:33 +02:00
										 |  |  |         if precollected_items: | 
					
						
							| 
									
										
										
										
											2021-05-09 21:22:21 +02:00
										 |  |  |             precollected = precollected_items[player] | 
					
						
							| 
									
										
										
										
											2020-06-26 19:29:33 +02:00
										 |  |  |             for item_id in precollected: | 
					
						
							|  |  |  |                 attribute_item(inventory, team, player, item_id) | 
					
						
							|  |  |  |         for location in locations_checked: | 
					
						
							| 
									
										
										
										
											2021-05-13 21:57:11 +02:00
										 |  |  |             if location not in player_locations or location not in player_location_to_area[player]: | 
					
						
							| 
									
										
										
										
											2020-10-27 00:47:59 -07:00
										 |  |  |                 continue | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-13 21:57:11 +02:00
										 |  |  |             item, recipient = player_locations[location] | 
					
						
							| 
									
										
										
										
											2020-06-26 19:29:33 +02:00
										 |  |  |             attribute_item(inventory, team, recipient, item) | 
					
						
							| 
									
										
										
										
											2020-10-29 15:18:59 -07:00
										 |  |  |             checks_done[team][player][player_location_to_area[player][location]] += 1 | 
					
						
							| 
									
										
										
										
											2020-06-26 19:29:33 +02:00
										 |  |  |             checks_done[team][player]["Total"] += 1 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-13 21:57:11 +02:00
										 |  |  |     for (team, player), game_state in multisave.get("client_game_state", {}).items(): | 
					
						
							|  |  |  |         if game_state == 30: | 
					
						
							| 
									
										
										
										
											2020-06-26 19:29:33 +02:00
										 |  |  |             inventory[team][player][106] = 1  # Triforce | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-07 14:30:21 -08:00
										 |  |  |     group_big_key_locations = set() | 
					
						
							|  |  |  |     group_key_locations = set() | 
					
						
							|  |  |  |     for player in range(1, len(names[0]) + 1): | 
					
						
							|  |  |  |         group_key_locations |= player_small_key_locations[player] | 
					
						
							|  |  |  |         group_big_key_locations |= player_big_key_locations[player] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-26 19:29:33 +02:00
										 |  |  |     activity_timers = {} | 
					
						
							|  |  |  |     now = datetime.datetime.utcnow() | 
					
						
							| 
									
										
										
										
											2021-04-04 03:18:19 +02:00
										 |  |  |     for (team, player), timestamp in multisave.get("client_activity_timers", []): | 
					
						
							| 
									
										
										
										
											2020-06-26 19:29:33 +02:00
										 |  |  |         activity_timers[team, player] = now - datetime.datetime.utcfromtimestamp(timestamp) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     player_names = {} | 
					
						
							| 
									
										
										
										
											2020-06-28 09:28:13 +02:00
										 |  |  |     for team, names in enumerate(names): | 
					
						
							| 
									
										
										
										
											2020-06-26 19:29:33 +02:00
										 |  |  |         for player, name in enumerate(names, 1): | 
					
						
							|  |  |  |             player_names[(team, player)] = name | 
					
						
							| 
									
										
										
										
											2020-07-29 21:35:31 +02:00
										 |  |  |     long_player_names = player_names.copy() | 
					
						
							| 
									
										
										
										
											2021-06-05 03:54:16 +02:00
										 |  |  |     for (team, player), alias in multisave.get("name_aliases", {}).items(): | 
					
						
							| 
									
										
										
										
											2020-06-27 13:52:03 +02:00
										 |  |  |         player_names[(team, player)] = alias | 
					
						
							| 
									
										
										
										
											2020-07-29 21:35:31 +02:00
										 |  |  |         long_player_names[(team, player)] = f"{alias} ({long_player_names[(team, player)]})" | 
					
						
							| 
									
										
										
										
											2020-06-27 13:52:03 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     video = {} | 
					
						
							| 
									
										
										
										
											2021-04-04 03:18:19 +02:00
										 |  |  |     for (team, player), data in multisave.get("video", []): | 
					
						
							| 
									
										
										
										
											2020-06-27 13:52:03 +02:00
										 |  |  |         video[(team, player)] = data | 
					
						
							| 
									
										
										
										
											2020-06-26 19:29:33 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return render_template("tracker.html", inventory=inventory, get_item_name_from_id=get_item_name_from_id, | 
					
						
							|  |  |  |                            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, | 
					
						
							| 
									
										
										
										
											2020-10-27 00:47:59 -07:00
										 |  |  |                            checks_in_area=seed_checks_in_area, activity_timers=activity_timers, | 
					
						
							| 
									
										
										
										
											2021-03-07 14:30:21 -08:00
										 |  |  |                            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, | 
					
						
							| 
									
										
										
										
											2020-07-29 21:35:31 +02:00
										 |  |  |                            hints=hints, long_player_names = long_player_names) |