Finish implementing the player tracker
This commit is contained in:
		
							parent
							
								
									69c1e138b4
								
							
						
					
					
						commit
						8615b2f0f5
					
				| 
						 | 
				
			
			@ -1,3 +1,20 @@
 | 
			
		|||
window.addEventListener('load', () => {
 | 
			
		||||
  // setTimeout(() => window.location.reload(), 15000);
 | 
			
		||||
  const url = window.location;
 | 
			
		||||
  setInterval(() => {
 | 
			
		||||
    const ajax = new XMLHttpRequest();
 | 
			
		||||
    ajax.onreadystatechange = () => {
 | 
			
		||||
      if (ajax.readyState !== 4) { return; }
 | 
			
		||||
 | 
			
		||||
      // Create a fake DOM using the returned HTML
 | 
			
		||||
      const domParser = new DOMParser();
 | 
			
		||||
      const fakeDOM = domParser.parseFromString(ajax.responseText, 'text/html');
 | 
			
		||||
 | 
			
		||||
      // Update item and location trackers
 | 
			
		||||
      document.getElementById('inventory-table').innerHTML = fakeDOM.getElementById('inventory-table').innerHTML;
 | 
			
		||||
      document.getElementById('location-table').innerHTML = fakeDOM.getElementById('location-table').innerHTML;
 | 
			
		||||
 | 
			
		||||
    };
 | 
			
		||||
    ajax.open('GET', url);
 | 
			
		||||
    ajax.send();
 | 
			
		||||
  }, 15000)
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,12 +1,16 @@
 | 
			
		|||
#player-tracker-wrapper{
 | 
			
		||||
 | 
			
		||||
    margin: 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#inventory-table{
 | 
			
		||||
    border: 2px solid black;
 | 
			
		||||
    border-radius: 4px;
 | 
			
		||||
    margin-bottom: 5px;
 | 
			
		||||
    width: 250px;
 | 
			
		||||
    border-top: 2px solid #000000;
 | 
			
		||||
    border-left: 2px solid #000000;
 | 
			
		||||
    border-right: 2px solid #000000;
 | 
			
		||||
    border-top-left-radius: 4px;
 | 
			
		||||
    border-top-right-radius: 4px;
 | 
			
		||||
    padding: 3px 3px 10px;
 | 
			
		||||
    width: 260px;
 | 
			
		||||
    background-color: #42b149;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#inventory-table td{
 | 
			
		||||
| 
						 | 
				
			
			@ -33,24 +37,27 @@
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
#location-table{
 | 
			
		||||
    width: 250px;
 | 
			
		||||
    border: 2px solid black;
 | 
			
		||||
    border-radius: 4px;
 | 
			
		||||
    width: 260px;
 | 
			
		||||
    border-left: 2px solid #000000;
 | 
			
		||||
    border-right: 2px solid #000000;
 | 
			
		||||
    border-bottom: 2px solid #000000;
 | 
			
		||||
    border-bottom-left-radius: 4px;
 | 
			
		||||
    border-bottom-right-radius: 4px;
 | 
			
		||||
    background-color: #42b149;
 | 
			
		||||
    padding: 0 3px 3px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#location-table th{
 | 
			
		||||
    vertical-align: middle;
 | 
			
		||||
    text-align: right;
 | 
			
		||||
    text-align: center;
 | 
			
		||||
    padding-right: 10px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#location-table td{
 | 
			
		||||
    padding-top: 2px;
 | 
			
		||||
    padding-bottom: 2px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#location-table th.counter{
 | 
			
		||||
    padding-right: 10px;
 | 
			
		||||
    text-align: center;
 | 
			
		||||
    padding-right: 5px;
 | 
			
		||||
    line-height: 20px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#location-table td.counter{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,15 +11,10 @@
 | 
			
		|||
        <table id="inventory-table">
 | 
			
		||||
            <tr>
 | 
			
		||||
                <td><img src="{{ bow_url }}" class="{{ 'acquired' if bow_acquired }}" /></td>
 | 
			
		||||
                <td>
 | 
			
		||||
                    <img
 | 
			
		||||
                            src="{{ icons["Red Boomerang"] if "Red Boomerang" in acquired_items else icons["Blue Boomerang"] }}"
 | 
			
		||||
                            class="{{ 'acquired' if "Red Boomerang" in acquired_items or "Blue Boomerang" in acquired_items }}"
 | 
			
		||||
                    />
 | 
			
		||||
                </td>
 | 
			
		||||
                <td><img src="{{ icons["Blue Boomerang"] }}" class="{{ 'acquired' if 'Blue Boomerang' in acquired_items }}" /></td>
 | 
			
		||||
                <td><img src="{{ icons["Red Boomerang"] }}" class="{{ 'acquired' if 'Red Boomerang' in acquired_items }}" /></td>
 | 
			
		||||
                <td><img src="{{ icons["Hookshot"] }}" class="{{ 'acquired' if 'Hookshot' in acquired_items }}" /></td>
 | 
			
		||||
                <td><img src="{{ icons["Magic Powder"] }}" class="powder-fix {{ 'acquired' if 'Magic Powder' in acquired_items }}" /></td>
 | 
			
		||||
                <td><img src="{{ sword_url }}" class="{{ 'acquired' if sword_acquired }}" /></td>
 | 
			
		||||
            </tr>
 | 
			
		||||
            <tr>
 | 
			
		||||
                <td><img src="{{ icons["Fire Rod"] }}" class="{{ 'acquired' if "Fire Rod" in acquired_items }}" /></td>
 | 
			
		||||
| 
						 | 
				
			
			@ -47,7 +42,14 @@
 | 
			
		|||
                <td><img src="{{ gloves_url }}" class="{{ 'acquired' if gloves_acquired }}" /></td>
 | 
			
		||||
                <td><img src="{{ icons["Flippers"] }}" class="{{ 'acquired' if "Flippers" in acquired_items }}" /></td>
 | 
			
		||||
                <td><img src="{{ icons["Moon Pearl"] }}" class="{{ 'acquired' if "Moon Pearl" in acquired_items }}" /></td>
 | 
			
		||||
                <td><img src="{{ icons["Green Mail"] }}" class="acquired" /></td>
 | 
			
		||||
                <td><img src="{{ icons["Mushroom"] }}" class="{{ 'acquired' if "Mushroom" in acquired_items }}" /></td>
 | 
			
		||||
            </tr>
 | 
			
		||||
            <tr>
 | 
			
		||||
                <td><img src="{{ sword_url }}" class="{{ 'acquired' if sword_acquired }}" /></td>
 | 
			
		||||
                <td><img src="{{ shield_url }}" class="{{ 'acquired' if shield_acquired }}" /></td>
 | 
			
		||||
                <td><img src="{{ mail_url }}" class="acquired" /></td>
 | 
			
		||||
                <td><img src="{{ icons["Shovel"] }}" class="{{ 'acquired' if "Shovel" in acquired_items }}" /></td>
 | 
			
		||||
                <td><img src="{{ icons["Triforce"] }}" class="{{ 'acquired' if "Triforce" in acquired_items }}" /></td>
 | 
			
		||||
            </tr>
 | 
			
		||||
        </table>
 | 
			
		||||
        <table id="location-table">
 | 
			
		||||
| 
						 | 
				
			
			@ -57,83 +59,18 @@
 | 
			
		|||
                <th class="counter"><img src="{{ icons["Small Key"] }}" /></th>
 | 
			
		||||
                <th><img src="{{ icons["Big Key"] }}" /></th>
 | 
			
		||||
            </tr>
 | 
			
		||||
            <tr>
 | 
			
		||||
                <td>Hyrule Castle</td>
 | 
			
		||||
                <td class="counter">{{ checks_done["Hyrule Castle"] }} / {{ checks_in_area["Hyrule Castle"] }}</td>
 | 
			
		||||
                <td class="counter">N/A</td>
 | 
			
		||||
                <td></td>
 | 
			
		||||
            </tr>
 | 
			
		||||
            <tr>
 | 
			
		||||
                <td>Eastern Palace</td>
 | 
			
		||||
                <td class="counter">{{ checks_done["Eastern Palace"] }} / {{ checks_in_area["Eastern Palace"] }}</td>
 | 
			
		||||
                <td class="counter">0 / 0</td>
 | 
			
		||||
                <td></td>
 | 
			
		||||
            </tr>
 | 
			
		||||
            <tr>
 | 
			
		||||
                <td>Desert Palace</td>
 | 
			
		||||
                <td class="counter">{{ checks_done["Desert Palace"] }} / {{ checks_in_area["Desert Palace"] }}</td>
 | 
			
		||||
                <td class="counter">0 / 0</td>
 | 
			
		||||
                <td></td>
 | 
			
		||||
            </tr>
 | 
			
		||||
            <tr>
 | 
			
		||||
                <td>Tower of Hera</td>
 | 
			
		||||
                <td class="counter">{{ checks_done["Tower of Hera"] }} / {{ checks_in_area["Tower of Hera"] }}</td>
 | 
			
		||||
                <td class="counter">0 / 0</td>
 | 
			
		||||
                <td></td>
 | 
			
		||||
            </tr>
 | 
			
		||||
            <tr>
 | 
			
		||||
                <td>Agahnim's Tower</td>
 | 
			
		||||
                <td class="counter">{{ checks_done["Agahnims Tower"] }} / {{ checks_in_area["Agahnims Tower"] }}</td>
 | 
			
		||||
                <td class="counter">N/A</td>
 | 
			
		||||
                <td></td>
 | 
			
		||||
            </tr>
 | 
			
		||||
            <tr>
 | 
			
		||||
                <td>Palace of Darkness</td>
 | 
			
		||||
                <td class="counter">{{ checks_done["Palace of Darkness"] }} / {{ checks_in_area["Palace of Darkness"] }}</td>
 | 
			
		||||
                <td class="counter">0 / 0</td>
 | 
			
		||||
                <td></td>
 | 
			
		||||
            </tr>
 | 
			
		||||
            <tr>
 | 
			
		||||
                <td>Swamp Palace</td>
 | 
			
		||||
                <td class="counter">{{ checks_done["Swamp Palace"] }} / {{ checks_in_area["Swamp Palace"] }}</td>
 | 
			
		||||
                <td class="counter">0 / 0</td>
 | 
			
		||||
                <td></td>
 | 
			
		||||
            </tr>
 | 
			
		||||
            <tr>
 | 
			
		||||
                <td>Skull Woods</td>
 | 
			
		||||
                <td class="counter">{{ checks_done["Skull Woods"] }} / {{ checks_in_area["Skull Woods"] }}</td>
 | 
			
		||||
                <td class="counter">0 / 0</td>
 | 
			
		||||
                <td></td>
 | 
			
		||||
            </tr>
 | 
			
		||||
            <tr>
 | 
			
		||||
                <td>Thieves' Town</td>
 | 
			
		||||
                <td class="counter">{{ checks_done["Thieves Town"] }} / {{ checks_in_area["Thieves Town"] }}</td>
 | 
			
		||||
                <td class="counter">0 / 0</td>
 | 
			
		||||
                <td></td>
 | 
			
		||||
            </tr>
 | 
			
		||||
            <tr>
 | 
			
		||||
                <td>Ice Palace</td>
 | 
			
		||||
                <td class="counter">{{ checks_done["Ice Palace"] }} / {{ checks_in_area["Ice Palace"] }}</td>
 | 
			
		||||
                <td class="counter">0 / 0</td>
 | 
			
		||||
                <td></td>
 | 
			
		||||
            </tr>
 | 
			
		||||
            <tr>
 | 
			
		||||
                <td>Misery Mire</td>
 | 
			
		||||
                <td class="counter">{{ checks_done["Misery Mire"] }} / {{ checks_in_area["Misery Mire"] }}</td>
 | 
			
		||||
                <td class="counter">0 / 0</td>
 | 
			
		||||
                <td></td>
 | 
			
		||||
            </tr>
 | 
			
		||||
            <tr>
 | 
			
		||||
                <td>Turtle Rock</td>
 | 
			
		||||
                <td class="counter">{{ checks_done["Turtle Rock"] }} / {{ checks_in_area["Turtle Rock"] }}</td>
 | 
			
		||||
                <td class="counter">0 / 0</td>
 | 
			
		||||
                <td></td>
 | 
			
		||||
            </tr><tr>
 | 
			
		||||
                <td>Ganon's Tower</td>
 | 
			
		||||
                <td class="counter">{{ checks_done["Ganons Tower"] }} / {{ checks_in_area["Ganons Tower"] }}</td>
 | 
			
		||||
                <td class="counter">0 / 0</td>
 | 
			
		||||
                <td></td>
 | 
			
		||||
            </tr>
 | 
			
		||||
            {% for area in sp_areas %}
 | 
			
		||||
                <tr>
 | 
			
		||||
                    <td>{{ area }}</td>
 | 
			
		||||
                    <td class="counter">{{ checks_done[area] }} / {{ checks_in_area[area] }}</td>
 | 
			
		||||
                    <td class="counter">
 | 
			
		||||
                        {{ inventory[small_key_ids[area]] if area in key_locations else 'N/A' }}
 | 
			
		||||
                    </td>
 | 
			
		||||
                    <td>
 | 
			
		||||
                        {{ '✔' if area in big_key_locations and inventory[big_key_ids[area]] else ('N/A' if area not in big_key_locations else '') }}
 | 
			
		||||
                    </td>
 | 
			
		||||
                </tr>
 | 
			
		||||
            {% endfor %}
 | 
			
		||||
        </table>
 | 
			
		||||
    </div>
 | 
			
		||||
</body>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -44,7 +44,7 @@
 | 
			
		|||
                        <tbody>
 | 
			
		||||
                            {%- for player, items in players.items() -%}
 | 
			
		||||
                                <tr>
 | 
			
		||||
                                    <td>{{ loop.index }}</td>
 | 
			
		||||
                                    <td><a href="{{ room.tracker|suuid }}/{{ team + 1 }}/{{ player }}">{{ loop.index }}</a></td>
 | 
			
		||||
                                    {%- if (team, loop.index) in video -%}
 | 
			
		||||
                                        {%- if video[(team, loop.index)][0] == "Twitch" -%}
 | 
			
		||||
                                        <td>
 | 
			
		||||
| 
						 | 
				
			
			@ -120,7 +120,7 @@
 | 
			
		|||
                        <tbody>
 | 
			
		||||
                            {%- for player, checks in players.items() -%}
 | 
			
		||||
                                <tr>
 | 
			
		||||
                                    <td>{{ loop.index }}</td>
 | 
			
		||||
                                    <td><a href="{{ room.tracker|suuid }}/{{ team + 1 }}/{{ player }}">{{ loop.index }}</a></td>
 | 
			
		||||
                                    <td>{{ player_names[(team, loop.index)]|e }}</td>
 | 
			
		||||
                                    {%- for area in ordered_areas -%}
 | 
			
		||||
                                        {%- set checks_done = checks[area] -%}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,6 +20,9 @@ app.jinja_env.filters["location_name"] = lambda location: Regions.lookup_id_to_n
 | 
			
		|||
app.jinja_env.filters['item_name'] = lambda id: Items.lookup_id_to_name.get(id, id)
 | 
			
		||||
 | 
			
		||||
icons = {
 | 
			
		||||
    "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",
 | 
			
		||||
    "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",
 | 
			
		||||
| 
						 | 
				
			
			@ -381,6 +384,8 @@ def getPlayerTracker(tracker: UUID, team: int, player: int):
 | 
			
		|||
        "Progressive Sword": 94,
 | 
			
		||||
        "Progressive Glove": 97,
 | 
			
		||||
        "Progressive Bow": 100,
 | 
			
		||||
        "Progressive Mail": 96,
 | 
			
		||||
        "Progressive Shield": 95,
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    # Determine which icon to use for the sword
 | 
			
		||||
| 
						 | 
				
			
			@ -423,11 +428,40 @@ def getPlayerTracker(tracker: UUID, team: int, player: int):
 | 
			
		|||
                bow_acquired = True
 | 
			
		||||
                break
 | 
			
		||||
 | 
			
		||||
    mail_url = icons["Green Mail"]
 | 
			
		||||
    mail_names = ["Blue Mail", "Red Mail"]
 | 
			
		||||
    if "Progressive Mail" in acquired_items:
 | 
			
		||||
        mail_url = icons[mail_names[inventory[progressive_items["Progressive Mail"]] - 1]]
 | 
			
		||||
    else:
 | 
			
		||||
        for mail in reversed(mail_names):
 | 
			
		||||
            if mail in acquired_items:
 | 
			
		||||
                mail_url = icons[mail]
 | 
			
		||||
                break
 | 
			
		||||
 | 
			
		||||
    shield_url = icons["Blue Shield"]
 | 
			
		||||
    shield_acquired = False
 | 
			
		||||
    shield_names = ["Blue Shield", "Red Shield", "Mirror Shield"]
 | 
			
		||||
    if "Progressive Shield" in acquired_items:
 | 
			
		||||
        shield_url = icons[shield_names[inventory[progressive_items["Progressive Shield"]] - 1]]
 | 
			
		||||
        shield_acquired = True
 | 
			
		||||
    else:
 | 
			
		||||
        for shield in reversed(shield_names):
 | 
			
		||||
            if shield in acquired_items:
 | 
			
		||||
                shield_url = icons[shield]
 | 
			
		||||
                shield_acquired = True
 | 
			
		||||
                break
 | 
			
		||||
 | 
			
		||||
    # 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("playerTracker.html", inventory=inventory, get_item_name_from_id=get_item_name_from_id,
 | 
			
		||||
                           player_name=player_name, room=room, icons=icons, checks_done=checks_done,
 | 
			
		||||
                           checks_in_area=seed_checks_in_area, acquired_items=acquired_items,
 | 
			
		||||
                           sword_url=sword_url, sword_acquired=sword_acquired, gloves_url=gloves_url,
 | 
			
		||||
                           gloves_acquired=gloves_acquired, bow_url=bow_url, bow_acquired=bow_acquired)
 | 
			
		||||
                           gloves_acquired=gloves_acquired, bow_url=bow_url, bow_acquired=bow_acquired,
 | 
			
		||||
                           small_key_ids=small_key_ids, big_key_ids=big_key_ids, sp_areas=sp_areas,
 | 
			
		||||
                           key_locations=key_locations, big_key_locations=big_key_locations, mail_url=mail_url,
 | 
			
		||||
                           shield_url=shield_url, shield_acquired=shield_acquired)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@app.route('/tracker/<suuid:tracker>')
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue