Cross codes now update in place, as soon as a new save file is created.
This commit is contained in:
parent
8e7c65303d
commit
25102a6bbc
@ -1,10 +1,25 @@
|
||||
var current_hash = "";
|
||||
|
||||
window.onload = () => {
|
||||
const refresh_interval = setInterval(refresh_elements, 500);
|
||||
fetch("http://localhost:8080/static/tracker/data/holy_cross_codes.json")
|
||||
.then((response) => response.json())
|
||||
.then(
|
||||
(data) => {
|
||||
const cross_codes = JSON.parse(JSON.stringify(data));
|
||||
// console.log(cross_codes);
|
||||
const refresh_interval = setInterval(
|
||||
refresh_elements,
|
||||
500,
|
||||
cross_codes
|
||||
);
|
||||
},
|
||||
(error) => {
|
||||
console.log(error);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
async function refresh_elements() {
|
||||
async function refresh_elements(cross_codes) {
|
||||
fetch("http://localhost:8000/spoiler")
|
||||
.then((response) => response.json())
|
||||
.then(
|
||||
@ -28,7 +43,9 @@ async function refresh_elements() {
|
||||
const current_scene_name = response_object.Current.Scene;
|
||||
const all_scenes = response_object.Scenes;
|
||||
const debug_info = response_object.Debug;
|
||||
const cross_codes = response_object.Codes;
|
||||
const cross_codes_entered = response_object.Codes;
|
||||
const default_cross_codes = cross_codes.Default;
|
||||
const global_cross_codes = cross_codes.Global;
|
||||
|
||||
// Refresh elements with new data from the back end.
|
||||
|
||||
@ -47,6 +64,11 @@ async function refresh_elements() {
|
||||
.getElementById("overview")
|
||||
.querySelector(".breakdown-list")
|
||||
.firstElementChild.cloneNode(true);
|
||||
let cross_codes_block = document
|
||||
.getElementById("overview")
|
||||
.querySelector(".breakdown-list")
|
||||
.firstElementChild.querySelector(".codes-block")
|
||||
.cloneNode(true);
|
||||
breakdown_block.classList.remove("hidden");
|
||||
let debug_item = document
|
||||
.getElementById("debug-block")
|
||||
@ -122,18 +144,31 @@ async function refresh_elements() {
|
||||
.firstElementChild.cloneNode(true);
|
||||
breakdown_block_mapped_list_item.classList.remove("hidden");
|
||||
|
||||
cross_codes_block = document
|
||||
.getElementById("overview")
|
||||
.querySelector(".breakdown-list")
|
||||
.firstElementChild.querySelector(".codes-block")
|
||||
.cloneNode(true);
|
||||
let new_cross_codes_block_list = cross_codes_block
|
||||
.querySelector(".codes-list")
|
||||
.cloneNode(true);
|
||||
let cross_codes_block_list_item = cross_codes_block
|
||||
.querySelector(".codes-list")
|
||||
.firstElementChild.cloneNode(true);
|
||||
|
||||
// Clear out current list content.
|
||||
new_breakdown_block_checks_list.innerHTML = "";
|
||||
new_breakdown_block_entrances_list.innerHTML = "";
|
||||
new_breakdown_block_mapped_list.innerHTML = "";
|
||||
new_cross_codes_block_list.innerHTML = "";
|
||||
new_breakdown_block_checks_list.appendChild(
|
||||
breakdown_block_checks_list_item.cloneNode()
|
||||
breakdown_block_checks_list_item.cloneNode(true)
|
||||
);
|
||||
new_breakdown_block_entrances_list.appendChild(
|
||||
breakdown_block_entrances_list_item.cloneNode()
|
||||
breakdown_block_entrances_list_item.cloneNode(true)
|
||||
);
|
||||
new_breakdown_block_mapped_list.appendChild(
|
||||
breakdown_block_mapped_list_item.cloneNode()
|
||||
breakdown_block_mapped_list_item.cloneNode(true)
|
||||
);
|
||||
|
||||
// Create variables for commonly used values.
|
||||
@ -143,6 +178,7 @@ async function refresh_elements() {
|
||||
let scene_entrances_undiscovered =
|
||||
all_scenes[scene].Totals.Entrances.Undiscovered;
|
||||
let scene_entrances_total = all_scenes[scene].Totals.Entrances.Total;
|
||||
let scene_has_codes = Object.keys(cross_codes).includes(scene);
|
||||
|
||||
// Set textContent.
|
||||
summary_title.textContent = scene;
|
||||
@ -152,7 +188,7 @@ async function refresh_elements() {
|
||||
breakdown_block_checks_title.textContent = `Checks: ${all_scenes[scene].Totals.Checks.Undiscovered}/${all_scenes[scene].Totals.Checks.Total}`;
|
||||
breakdown_block_entrances_title.textContent = `Entrances: ${all_scenes[scene].Totals.Entrances.Undiscovered}/${all_scenes[scene].Totals.Entrances.Total}`;
|
||||
|
||||
// Create checks, entrances, and mapped entrances lists.
|
||||
// Create checks, entrances, mapped entrances, and cross code lists.
|
||||
Object.keys(all_scenes[scene].Checks).forEach((check) => {
|
||||
if (!all_scenes[scene].Checks[check]) {
|
||||
breakdown_block_checks_list_item.textContent = `❌ ${check}`;
|
||||
@ -174,6 +210,63 @@ async function refresh_elements() {
|
||||
);
|
||||
}
|
||||
});
|
||||
Object.keys(default_cross_codes).forEach((code) => {
|
||||
cross_codes_block_list_item.querySelector(
|
||||
".codes-list-item-title"
|
||||
).textContent = code;
|
||||
cross_codes_block_list_item.querySelector(
|
||||
".codes-list-item-code"
|
||||
).textContent = default_cross_codes[code]
|
||||
.replace(/U/g, "⬆️ ")
|
||||
.replace(/R/g, "➡️ ")
|
||||
.replace(/D/g, "⬇️ ")
|
||||
.replace(/L/g, "⬅️ ");
|
||||
new_cross_codes_block_list.appendChild(
|
||||
cross_codes_block_list_item.cloneNode(true)
|
||||
);
|
||||
});
|
||||
Object.keys(global_cross_codes).forEach((code) => {
|
||||
cross_codes_block_list_item.querySelector(
|
||||
".codes-list-item-title"
|
||||
).textContent = code;
|
||||
cross_codes_block_list_item.querySelector(
|
||||
".codes-list-item-code"
|
||||
).textContent = global_cross_codes[code]
|
||||
.replace(/U/g, "⬆️ ")
|
||||
.replace(/R/g, "➡️ ")
|
||||
.replace(/D/g, "⬇️ ")
|
||||
.replace(/L/g, "⬅️ ");
|
||||
if (cross_codes_entered.Global[code]) {
|
||||
cross_codes_block_list_item.classList.add("hidden");
|
||||
} else {
|
||||
cross_codes_block_list_item.classList.remove("hidden");
|
||||
}
|
||||
new_cross_codes_block_list.appendChild(
|
||||
cross_codes_block_list_item.cloneNode(true)
|
||||
);
|
||||
});
|
||||
if (scene_has_codes) {
|
||||
Object.keys(cross_codes[scene]).forEach((code) => {
|
||||
cross_codes_block_list_item.querySelector(
|
||||
".codes-list-item-title"
|
||||
).textContent = code;
|
||||
cross_codes_block_list_item.querySelector(
|
||||
".codes-list-item-code"
|
||||
).textContent = cross_codes[scene][code]
|
||||
.replace(/U/g, "⬆️ ")
|
||||
.replace(/R/g, "➡️ ")
|
||||
.replace(/D/g, "⬇️ ")
|
||||
.replace(/L/g, "⬅️ ");
|
||||
if (cross_codes_entered[scene][code]) {
|
||||
cross_codes_block_list_item.classList.add("hidden");
|
||||
} else {
|
||||
cross_codes_block_list_item.classList.remove("hidden");
|
||||
}
|
||||
new_cross_codes_block_list.appendChild(
|
||||
cross_codes_block_list_item.cloneNode(true)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// Apply color coding to summary block
|
||||
summary_block.classList.remove(
|
||||
@ -207,10 +300,16 @@ async function refresh_elements() {
|
||||
breakdown_block
|
||||
.querySelector(".breakdown-block-mapped-list")
|
||||
.replaceWith(new_breakdown_block_mapped_list);
|
||||
breakdown_block
|
||||
.querySelector(".codes-list")
|
||||
.replaceWith(new_cross_codes_block_list);
|
||||
|
||||
// Append relevant elements to lists.
|
||||
if (scene == current_scene_name) {
|
||||
summary_block.classList.add("hidden");
|
||||
breakdown_block
|
||||
.querySelector(".codes-block")
|
||||
.classList.remove("hidden");
|
||||
document
|
||||
.getElementById("breakdown-current")
|
||||
.firstElementChild.replaceWith(breakdown_block.cloneNode(true));
|
||||
|
@ -1,7 +1,8 @@
|
||||
{
|
||||
"Default": {
|
||||
"Speedrunner Code": "RULDDRULU",
|
||||
"Seeking Spell": "ULURDL"
|
||||
"Seeking Spell": "ULURDL",
|
||||
"Healing Spell": "DRDLURU"
|
||||
},
|
||||
"Cathedral": {
|
||||
"Secret Legend Door": "LULURULURDRRURDLDRDLDL"
|
||||
@ -19,6 +20,11 @@
|
||||
"Eastern Vault Fortress": {
|
||||
"Candles Fairy": "RLDRUL"
|
||||
},
|
||||
"Global": {
|
||||
"Firebomb": "LURDRURDRURDL",
|
||||
"Firecracker": "DRURULULDLDR",
|
||||
"Icebomb": "LDRURDRURDRUL"
|
||||
},
|
||||
"Hourglass Cave": {
|
||||
"Hourglass Door": "RULURULUURDLDRDLDR",
|
||||
"Hourglass Fairy": "LURURDRURULLLURU"
|
||||
@ -65,12 +71,6 @@
|
||||
"Secret Gathering Place": {
|
||||
"Waterfall Fairy": "DRURURULULURURULDLDLDRDLDRDRUR"
|
||||
},
|
||||
"Spells": {
|
||||
"Healing Spell": "DRDLURU",
|
||||
"Dynamite": "DRURULULDLDR",
|
||||
"Fire Bomb": "LURDRURDRURDL",
|
||||
"Ice Bomb": "LDRURDLURDLUL"
|
||||
},
|
||||
"West Garden": {
|
||||
"Sword Door": "DRULUR",
|
||||
"Tiles Fairy": "URULURULURDRULRLURULURULU",
|
@ -57,9 +57,5 @@
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% if current_scene.title != scene_title %}
|
||||
<div class="pt-4 hidden">{% include "tracker/codes/index.html" %}</div>
|
||||
{% else %}
|
||||
<div class="pt-4">{% include "tracker/codes/index.html" %}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
@ -1,7 +1,8 @@
|
||||
<ul class="flex flex-col p-2 rounded-md bg-bluelight-translucent-dark max-w-full {% if is_entered %}hidden{% endif %}">
|
||||
<div class="p-2">{{ name }}:</div>
|
||||
{% if not is_entered %}
|
||||
<ul class="flex flex-col p-2 rounded-md bg-bluelight-translucent-dark max-w-full">
|
||||
<div class="p-2 codes-list-item-title">{{ name }}</div>
|
||||
<div class="p-2 m-auto justify-center align-top">
|
||||
<div class="max-w-64">
|
||||
<div class="max-w-64 codes-list-item-code">
|
||||
{% for arrow in code %}
|
||||
{% if arrow == "U" %}
|
||||
⬆️
|
||||
@ -15,4 +16,5 @@
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</ul>
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
@ -1,18 +1,21 @@
|
||||
<div class="flex flex-col max-w-full text-lg rounded-md ring-4 bg-bluelight-translucent ring-bluelight-dark justify-start p-4 {{ is_hidden }}">
|
||||
<div class="flex flex-col max-w-full text-lg rounded-md ring-4 bg-bluelight-translucent ring-bluelight-dark justify-start p-4 {% if current_scene.title != scene_title %}hidden{% endif %} codes-block">
|
||||
Holy Cross Codes
|
||||
<div class="flex flex-col space-y-2">
|
||||
<ul class="flex flex-col space-y-4 rounded-md" id="codes-block">
|
||||
<ul class="flex flex-col p-2 rounded-md bg-bluelight-translucent-dark w-full hidden">
|
||||
</ul>
|
||||
<ul class="flex flex-col space-y-4 rounded-md codes-list">
|
||||
{% for name, code in default_codes.items %}
|
||||
{% include "tracker/codes/block.html" with is_entered=false %}
|
||||
{% include "tracker/codes/block.html" with is_entered=False %}
|
||||
{% endfor %}
|
||||
{% for name, code in spell_codes.items %}
|
||||
{% include "tracker/codes/block.html" with is_entered=false %}
|
||||
{% endfor %}
|
||||
{% for name, code_tuple in current_codes.items %}
|
||||
{% for scene, codes in tracked_codes.items %}
|
||||
{% if scene == "Global" %}
|
||||
{% for name, code_tuple in codes.items %}
|
||||
{% include "tracker/codes/block.html" with code=code_tuple.0 is_entered=code_tuple.1 %}
|
||||
{% endfor %}
|
||||
{% elif scene == scene_title %}
|
||||
{% for name, code_tuple in codes.items %}
|
||||
{% include "tracker/codes/block.html" with code=code_tuple.0 is_entered=code_tuple.1 %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -31,7 +31,7 @@ def index(request):
|
||||
is_hidden = False
|
||||
except:
|
||||
return
|
||||
with open('tracker/data/holy_cross_codes.json', 'r') as t:
|
||||
with open('tracker/static/tracker/data/holy_cross_codes.json', 'r') as t:
|
||||
try:
|
||||
cross_codes = loads(t.read())
|
||||
except:
|
||||
@ -41,12 +41,13 @@ def index(request):
|
||||
tracker_current_scene = tracker_output["Current"]["Scene"]
|
||||
tracker_current_scene_data = tracker_output["Scenes"][tracker_current_scene]
|
||||
tracker_scenes = tracker_output["Scenes"]
|
||||
tracker_codes = tracker_output["Codes"]
|
||||
entered_codes = tracker_output["Codes"]
|
||||
try:
|
||||
current_cross_codes = cross_codes[tracker_current_scene]
|
||||
for k, v in cross_codes[tracker_current_scene].items():
|
||||
current_cross_codes[k] = (
|
||||
v, tracker_codes[tracker_current_scene][k])
|
||||
tracker_codes = cross_codes
|
||||
for scene in entered_codes:
|
||||
for k, v in cross_codes[scene].items():
|
||||
tracker_codes[scene][k] = (
|
||||
v, entered_codes[scene][k])
|
||||
except Exception as e:
|
||||
current_cross_codes = {}
|
||||
print(e)
|
||||
@ -56,8 +57,7 @@ def index(request):
|
||||
"is_hidden": is_hidden,
|
||||
"debug": tracker_debug,
|
||||
"default_codes": cross_codes["Default"],
|
||||
"spell_codes": cross_codes["Spells"],
|
||||
"current_codes": current_cross_codes,
|
||||
"tracked_codes": tracker_codes,
|
||||
"totals": tracker_totals,
|
||||
"scenes": tracker_scenes,
|
||||
"current_scene": {
|
||||
|
Loading…
Reference in New Issue
Block a user