Added spell codes to the holy cross codes panel, logic for whether a code has been entered.

This commit is contained in:
Ada Werefox 2024-03-07 01:00:55 -06:00
parent c521c24602
commit 8e7c65303d
7 changed files with 61 additions and 43 deletions

View File

@ -1,4 +1,8 @@
{
"Default": {
"Speedrunner Code": "RULDDRULU",
"Seeking Spell": "ULURDL"
},
"Cathedral": {
"Secret Legend Door": "LULURULURDRRURDLDRDLDL"
},
@ -61,6 +65,12 @@
"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",

View File

@ -5,7 +5,7 @@ window.onload = () => {
};
async function refresh_elements() {
fetch("http://192.168.1.101:8000/spoiler")
fetch("http://localhost:8000/spoiler")
.then((response) => response.json())
.then(
(data) => {
@ -233,7 +233,6 @@ async function refresh_elements() {
});
// Replace with new data.
// console.log(new_summary_list);
document
.getElementById("overview")
.querySelector(".summary-list")
@ -242,17 +241,9 @@ async function refresh_elements() {
.getElementById("overview")
.querySelector(".breakdown-list")
.replaceWith(new_breakdown_list.cloneNode(true));
// document
// .getElementById("breakdown-current")
// .replaceWith(
// document.getElementById("breakdown-current").cloneNode(true)
// );
document
.getElementById("debug-block")
.replaceWith(new_debug_block.cloneNode(true));
// Debug
// console.log("We have data.");
},
(error) => {
document.getElementById("status-block").classList.remove("hidden");

View File

@ -57,5 +57,9 @@
{% endfor %}
</div>
</div>
<div class="pt-4">{% include "tracker/codes/index.html" %}</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>

View File

@ -0,0 +1,18 @@
<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>
<div class="p-2 m-auto justify-center align-top">
<div class="max-w-64">
{% for arrow in code %}
{% if arrow == "U" %}
⬆️
{% elif arrow == "D" %}
⬇️
{% elif arrow == "L" %}
⬅️
{% elif arrow == "R" %}
➡️
{% endif %}
{% endfor %}
</div>
</div>
</ul>

View File

@ -1,30 +1,17 @@
<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 not codes %}hidden{% endif %}">
<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 }}">
Holy Cross Codes
<div class="flex flex-col space-y-2" id="codes-block">
<ul class="flex flex-col space-y-2 rounded-md hidden">
</ul>
<ul class="flex flex-col space-y-4 rounded-md">
<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>
{% for name, code in codes.items %}
<ul class="flex flex-col p-2 rounded-md bg-bluelight-translucent-dark w-full">
<div class="p-2">{{ name }}:</div>
<div class="p-2 m-auto justify-center align-top">
<div class="max-w-64">
{% for arrow in code %}
{% if arrow == "U" %}
⬆️
{% elif arrow == "D" %}
⬇️
{% elif arrow == "L" %}
⬅️
{% elif arrow == "R" %}
➡️
{% endif %}
{% endfor %}
</div>
</div>
</ul>
{% for name, code in default_codes.items %}
{% 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 %}
{% include "tracker/codes/block.html" with code=code_tuple.0 is_entered=code_tuple.1 %}
{% endfor %}
</ul>
</div>

View File

@ -35,7 +35,11 @@
<div class="p-4 flex flex-col space-y-4 breakdown-list">
{% include "tracker/breakdown/block.html" with extra_classes="hidden" %}
{% for scene_title, scene_data in scenes.items %}
{% include "tracker/breakdown/block.html" %}
{% if scene_title == current_scene.title %}
{% include "tracker/breakdown/block.html" with extra_classes="hidden" %}
{% else %}
{% include "tracker/breakdown/block.html" %}
{% endif %}
{% endfor %}
</div>
</details>
@ -45,8 +49,7 @@
</div>
<details class="group p-2 flex max-w-full rounded-md ring-4 bg-bluelight-translucent ring-bluelight-dark">
<summary class="justify-start p-2">Tracker Debug</summary>
<div class="p-2 flex flex-col space-y-2"
id="debug-block">
<div class="p-2 flex flex-col space-y-2" id="debug-block">
<ul class="p-2 rounded-md bg-bluelight-translucent hidden">
</ul>
{% for name, value in debug.items %}

View File

@ -39,25 +39,30 @@ def index(request):
tracker_debug = tracker_output["Debug"]
tracker_totals = tracker_output["Totals"]
tracker_current_scene = tracker_output["Current"]["Scene"]
tracker_current_scane_data = tracker_output["Scenes"][tracker_current_scene]
tracker_current_scene_data = tracker_output["Scenes"][tracker_current_scene]
tracker_scenes = tracker_output["Scenes"]
tracker_codes = tracker_output["Codes"]
try:
current_cross_codes = cross_codes[tracker_current_scene]
except:
for k, v in cross_codes[tracker_current_scene].items():
current_cross_codes[k] = (
v, tracker_codes[tracker_current_scene][k])
except Exception as e:
current_cross_codes = {}
print(e)
template = loader.get_template("tracker/index.html")
context = {
"server_address": server_address,
"is_hidden": is_hidden,
"debug": tracker_debug,
"codes": current_cross_codes,
"codes_entered": tracker_codes,
"default_codes": cross_codes["Default"],
"spell_codes": cross_codes["Spells"],
"current_codes": current_cross_codes,
"totals": tracker_totals,
"scenes": tracker_scenes,
"current_scene": {
"title": tracker_current_scene,
"data": tracker_current_scane_data
"data": tracker_current_scene_data
}
}
return HttpResponse(template.render(context, request))