diff --git a/TunicTransitionTracker-linux b/TunicTransitionTracker-linux new file mode 100755 index 0000000..cd4fc5b Binary files /dev/null and b/TunicTransitionTracker-linux differ diff --git a/lib/entrances.py b/lib/entrances.py deleted file mode 100644 index 7140f03..0000000 --- a/lib/entrances.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/python - -import logging -import re - - -def import_entrances(spoiler_log='/home/alice/Games/steam/steamapps/compatdata/553420/pfx/drive_c/users/steamuser/AppData/LocalLow/Andrew Shouldice/Secret Legend/Randomizer/Spoiler.log'): - """A function to import the entrance mappings from the user's spoiler log. - - Args: - spoiler_log (str, optional): The filepath of the spoiler log. Defaults to '/home/alice/Games/steam/steamapps/compatdata/553420/pfx/drive_c/users/steamuser/AppData/LocalLow/Andrew Shouldice/Secret Legend/Randomizer/Spoiler.log'. - """ - - try: - with open(spoiler_log, 'r') as f: - spoiler_text = f.read() - entrances_map = re.findall('\s+- (.+) -- (.+)\n', spoiler_text) - # logging.debug(entrances_map) - except: - logging.error(f'Could not find spoiler log from path: {spoiler_log}') - return - - return dict(entrances_map) - - -def log_entrances(e): - """A debug function to ensure entrance parsing has been done successfully. - """ - - for l in e: - logging.debug(f'{l[0]} <---> {l[1]}') - - -def check_mapped_entrances(new_entrances, entrances_map): - """A function to check off when a new entrance pair has been visited and validate it with the spoiler log. - - Args: - new_entrances (tuple): A pairing of two strings containing the entrance names. - entrances_map (dict): An imported dictionary mapping the entrances as listed in the spoiler log. - """ - if new_entrances[0] in entrances_map.keys(): - logging.debug(f'Validated that {new_entrances[0]} connects to {new_entrances[1]}') - elif new_entrances[1] in entrances_map.keys(): - logging.debug(f'Validated that {new_entrances[1]} connects to {new_entrances[0]}') - else: - logging.warn(f'No connection in spoiler log between {new_entrances[0]} and {new_entrances[1]}') - return False - return True \ No newline at end of file diff --git a/lib/saves.py b/lib/saves.py deleted file mode 100644 index 94378ce..0000000 --- a/lib/saves.py +++ /dev/null @@ -1,53 +0,0 @@ -import logging -import glob -import os -import re -# from collections import deque - - -def get_current_save_filename(saves_dir='/home/alice/Games/steam/steamapps/compatdata/553420/pfx/drive_c/users/steamuser/AppData/LocalLow/Andrew Shouldice/Secret Legend/SAVES'): - """Get the last modified save file in the saves directory. - - Args: - saves_dir (str, optional): Path to the saves directory. Defaults to '/home/alice/Games/steam/steamapps/compatdata/553420/pfx/drive_c/users/steamuser/AppData/LocalLow/Andrew Shouldice/Secret Legend/SAVES'. - """ - - try: - list_files = glob.glob(f'{saves_dir}/*.tunic') - except: - logging.error( - f'Something went wrong in looking for the saves directory at {saves_dir}') - - try: - latest_save_path = max(list_files, key=os.path.getmtime) - except: - logging.warn('A save file was deleted.') - return - - try: - latest_save_filename = re.search( - '([0-9]*)[a-z-]*~([0-9]*)\.tunic', latest_save_path) - except: - logging.error(f'Cannot perform regex successfully on save path: {latest_save_path}') - return - - if latest_save_filename != None: - return (latest_save_filename[0], latest_save_filename[1]) - return (None, None) - - -def get_visited_entrances(save_filename, saves_dir='/home/alice/Games/steam/steamapps/compatdata/553420/pfx/drive_c/users/steamuser/AppData/LocalLow/Andrew Shouldice/Secret Legend/SAVES'): - try: - with open(f'{saves_dir}/{save_filename}', 'r') as save: - save_file_text = save.read() - try: - save_entrances = re.findall('portal (.*)\|1\n', save_file_text) - except: - logging.error( - f'Unable to perform findall successfully on {save_filename}') - return - except: - logging.error(f'Could not find save file from path: {save_filename}') - return - - return save_entrances diff --git a/tunictracker/tracker/static/tracker/assets/test.js b/tunictracker/tracker/static/tracker/assets/test.js index e69de29..604dacc 100644 --- a/tunictracker/tracker/static/tracker/assets/test.js +++ b/tunictracker/tracker/static/tracker/assets/test.js @@ -0,0 +1,116 @@ +window.onload = () => { + let overview = { + checks: document.getElementById("overview_checks"), + entrances: document.getElementById("overview_entrances"), + }; + let current_scene = { + name: document.getElementById("current_scene_text"), + checks: { + title: document.getElementById("current_scene_checks_title"), + list: document.getElementById("current_scene_checks_list"), + }, + entrances: { + title: document.getElementById("current_scene_entrances_title"), + list: document.getElementById("current_scene_entrances_list"), + mapped: document.getElementById("current_scene_entrances_mapped"), + }, + }; + let line_elem = document + .getElementById("current_scene_checks_list") + .firstElementChild.cloneNode(true); + let mapped_line_elem = document + .getElementById("current_scene_entrances_mapped") + .firstElementChild.cloneNode(true); + const refresh_interval = setInterval( + refresh_elements, + 300, + overview, + current_scene, + line_elem, + mapped_line_elem + ); +}; + +async function refresh_elements( + overview, + current_scene, + line_elem, + mapped_line_elem +) { + fetch("http://localhost:8000/spoiler") + .then((response) => response.json()) + .then((data) => { + const response_object = JSON.parse(JSON.stringify(data)); + const overview_checks_undiscovered = + response_object.Totals.Checks.Undiscovered; + const overview_checks_total = response_object.Totals.Checks.Total; + const overview_entrances_undiscovered = + response_object.Totals.Entrances.Undiscovered; + const overview_entrances_total = response_object.Totals.Entrances.Total; + const current_scene_name = response_object.Scene; + const current_scene_checks_undiscovered = + response_object.Scenes[current_scene_name].Totals.Checks.Undiscovered; + const current_scene_checks_total = + response_object.Scenes[current_scene_name].Totals.Checks.Total; + const current_scene_entrances_undiscovered = + response_object.Scenes[current_scene_name].Totals.Entrances + .Undiscovered; + const current_scene_entrances_total = + response_object.Scenes[current_scene_name].Totals.Entrances.Total; + const current_scene_checks_list = + response_object.Scenes[current_scene_name].Checks; + const current_scene_entrances_list = + response_object.Scenes[current_scene_name].Entrances; + overview.checks.textContent = `Checks: ${overview_checks_undiscovered}/${overview_checks_total}`; + overview.entrances.textContent = `Entrances: ${overview_entrances_undiscovered}/${overview_entrances_total}`; + current_scene.name.textContent = current_scene_name; + current_scene.checks.title.textContent = `Checks: ${current_scene_checks_undiscovered}/${current_scene_checks_total}`; + current_scene.entrances.title.textContent = `Entrances: ${current_scene_entrances_undiscovered}/${current_scene_entrances_total}`; + current_scene.checks.list.innerHTML = ""; + current_scene.entrances.list.innerHTML = ""; + current_scene.entrances.mapped.innerHTML = ""; + Object.keys(current_scene_checks_list).forEach((check) => { + if (!current_scene_checks_list[check]) { + line_elem.textContent = `❌ ${check}`; + current_scene.checks.list.appendChild(line_elem.cloneNode(true)); + } + }); + Object.keys(current_scene_entrances_list).forEach((entrances) => { + if (current_scene_entrances_list[entrances] == "") { + line_elem.textContent = `❌ ${entrances}`; + current_scene.entrances.list.appendChild(line_elem.cloneNode(true)); + } else { + mapped_line_elem.textContent = `✔️ ${entrances} -> ${current_scene_entrances_list[entrances]}`; + current_scene.entrances.mapped.appendChild( + mapped_line_elem.cloneNode(true) + ); + } + }); + }) + .catch((err) => { + console.log(); + }); +} + +function log_elements() { + console.log(overview.checks.textContent); + console.log(overview.entrances.textContent); + console.log(current_scene.name.textContent); + console.log(current_scene.checks.title.textContent); + for (i in current_scene.checks.list.children) { + if (current_scene.checks.list.children[i].textContent) { + console.log(current_scene.checks.list.children[i].textContent); + } + } + console.log(current_scene.entrances.title.textContent); + for (i in current_scene.entrances.list.children) { + if (current_scene.entrances.list.children[i].textContent) { + console.log(current_scene.entrances.list.children[i].textContent); + } + } + for (i in current_scene.entrances.mapped.children) { + if (current_scene.entrances.mapped.children[i].textContent) { + console.log(current_scene.entrances.mapped.children[i].textContent); + } + } +} diff --git a/tunictracker/tracker/templates/index.html b/tunictracker/tracker/templates/index.html index 760a047..483c978 100644 --- a/tunictracker/tracker/templates/index.html +++ b/tunictracker/tracker/templates/index.html @@ -7,7 +7,7 @@ - + {% comment %} {% endcomment %} {% load static tailwind_tags %} {% tailwind_css %} {% load static %} diff --git a/tunictracker/tracker/templates/tracker/index.html b/tunictracker/tracker/templates/tracker/index.html index f61ef72..d4c4fba 100644 --- a/tunictracker/tracker/templates/tracker/index.html +++ b/tunictracker/tracker/templates/tracker/index.html @@ -13,8 +13,8 @@