diff --git a/tunictracker/tracker/data/hints.json b/tunictracker/tracker/data/hints.json
new file mode 100644
index 0000000..cb9b801
--- /dev/null
+++ b/tunictracker/tracker/data/hints.json
@@ -0,0 +1,14 @@
+{
+ "Hint Ghost Overworld Before Garden": "bI #uh wA, I hurd #aht \"FOUR SKULLS\" R gRdi^ [archipelago] \"FAXERYNTHIA'S OINTMENT.\" ",
+ "Hint Ghost Windmill": "bI #uh wA, I hurd #aht \"EAST FOREST SLIME\" iz gRdi^ [icebomb] \"TOASTERMANUAL'S ICE BOMB X3.\" ",
+ "Hint Ghost Purgatory": "bI #uh wA, I hurd #aht \"CATHEDRAL GAUNTLET\" iz gRdi^ [archipelago] \"PAPER LIME'S LYRICS.\" ",
+ "Hint Ghost Sword Cave": "bI #uh wA, I saw A [gun] \"GUN\" #uh lahst tIm I wuhs aht #uh \"CATHEDRAL.\" ",
+ "Hint Ghost Mountain": "bI #uh wA, I hurd #aht \"20 FAIRIES\" R gRdi^ [archipelago] \"PAPER LIME'S DEEPFOCUS2.\" ",
+ "Hint Ghost Changing Room 1": "bI #uh wA, I hurd #aht \"VAULT KEY PLINTH\" iz gRdi^ [archipelago] \"CHAIAMON EMERALD'S NUGGET.\" ",
+ "Hint Ghost Waterfall": "bI #uh wA, I saw A [potionrelic] \"HERO RELIC - POTION\" #uh lahst tIm I wuhs aht #uh \"STICK HOUSE.\" ",
+ "Mailbox": "lehjehnd sehz #uh \"CATHEDRAL\" kuhntAnz wuhn uhv mehnE \"<#00FFFF>FIRST STEPS<#ffffff>\" ahn yor jurnE.",
+ "West Garden Relic - Path": "lehjehnd sehz \"TOASTERMANUAL'S LIBRARY LAB\" iz lOkAtid awn #uh \"<#ffd700>PATH OF THE HERO<#ffffff>...\"",
+ "Library Relic - Path": "#A sA #uh \"LIBRARIAN\" iz wAr #uh <#33FF33>kwehstuhgawn [hexagram]<#FFFFFF> iz fownd\"...\"",
+ "Swamp Relic - Path": "#A sA #uh \"FORTRESS ARENA\" iz wAr #uh <#FF3333>kwehstuhgawn [hexagram]<#FFFFFF> iz fownd\"...\"",
+ "Fortress Relic - Path": "lehjehnd sehz \"CHAIAMON EMERALD'S WORLD\" aht \"ROUTE 111 - ITEM DESERT SOUTH\" iz lOkAtid awn #uh \"<#ffd700>PATH OF THE HERO<#ffffff>...\""
+}
diff --git a/tunictracker/tracker/static/tracker/assets/main.js b/tunictracker/tracker/static/tracker/assets/main.js
index b18d4d3..01a4924 100644
--- a/tunictracker/tracker/static/tracker/assets/main.js
+++ b/tunictracker/tracker/static/tracker/assets/main.js
@@ -18,22 +18,41 @@ var cross_codes = {};
var total_checks = 0;
var total_entrances = 0;
var all_scenes = [];
+var image_translations = {};
window.onload = async () => {
await get_updated_server_address();
+ await parse_cross_codes();
+ await parse_image_translations();
+ await initialize_elements();
+ await refresh_elements();
+};
+
+async function parse_cross_codes() {
fetch(`${document.URL}static/tracker/data/holy_cross_codes.json`)
.then((response) => response.json())
.then(
(data) => {
cross_codes = JSON.parse(JSON.stringify(data));
- initialize_elements();
- refresh_elements();
},
(error) => {
console.error(error);
}
);
-};
+}
+
+async function parse_image_translations() {
+ fetch(`${document.URL}static/tracker/data/image_translations.json`)
+ .then((response) => response.json())
+ .then(
+ (data) => {
+ image_translations = JSON.parse(JSON.stringify(data));
+ },
+ (error) => {
+ console.error(error);
+ }
+ );
+}
async function get_updated_server_address() {
fetch(`${document.URL}get/address`)
@@ -890,44 +909,54 @@ async function update_hints(hints) {
hints_list.innerHTML = "";
hints_list.appendChild(hints_list_item.cloneNode(true));
hints_list_item.classList.remove("hidden");
- Object.keys(hints).forEach((hint_index) => {
- let hint = hints[hint_index].split(
- /(\[[\w\s]+?\]|\"[\w \d\>\<#.\-\']+\"|\<[\w\d#]+\>)/gm
+ // Object.keys(hints).forEach((hint_index) => {
+ for (const hint_index of Object.keys(hints)) {
+ // let hint = hints[hint_index].split(
+ // /(\[[\w\s]+?\]|\"[\w \d\>\<#.\-\']+\"|\<[\w\d#]+\>)/gm
+ // );
+ // hint = await Promise.all(
+ // hint.map(async (segment) => {
+ // segment = segment.trim();
+ // if (segment) {
+ // // if (
+ // // !(
+ // // segment.startsWith("[") ||
+ // // segment.startsWith("<") ||
+ // // segment.startsWith('"')
+ // // )
+ // // ) {
+ // // segment = translate(segment.trim());
+ // // } else if (segment.startsWith("[")) {
+ // // segment = segment.trim();
+ // // let translated_image_name = image_translations[segment];
+ // // segment = `
`;
+ // // } else {
+ // // segment = ` ${segment.trim()} `;
+ // // }
+ // // console.log(segment)
+ // // return segment;
+ // return await translate.test_parse_hints(segment, image_translations);
+ // }
+ // })
+ // );
+ hints[hint_index] = await translate.test_parse_hints(
+ hints[hint_index],
+ image_translations
);
- hint = hint.map((segment) => {
- segment = segment.trim();
- if (segment) {
- if (
- !(
- segment.startsWith("[") ||
- segment.startsWith("<") ||
- segment.startsWith('"')
- )
- ) {
- segment = translate(segment.trim());
- } else if (segment.startsWith("[")) {
- segment = segment.trim();
- } else {
- segment = ` ${segment.trim()} `;
- }
- return segment;
- }
- });
- hints[hint_index] = hint.join("");
- });
+ }
Object.keys(hints).forEach((hint_index) => {
- let hint = hints[hint_index];
- let matches = Array.from(
- hint.matchAll(/\<([\w\d#]+)\>(.*)(\<[\w\d#]+\>)/gm)
- );
- if (matches.length >= 1) {
- hint = hint.replace(
- /(\<[\w\d#]+\>.*\<[\w\d#]+\>)/gm,
- `${matches[0][2]}`
- );
- }
- hint = hint.replace(/ "|" /gm, " ");
- hints_list_item.firstElementChild.innerHTML = hint;
+ // let hint = hints[hint_index];
+ // let matches = Array.from(
+ // hint.matchAll(/\<([\w\d#]+)\>(.*)(\<[\w\d#]+\>)/gm)
+ // );
+ // if (matches.length >= 1) {
+ // hint = hint.replace(
+ // /(\<[\w\d#]+\>.*\<[\w\d#]+\>)/gm,
+ // `${matches[0][2]}`
+ // );
+ // }
+ // hint = hint.replace(/ "|" /gm, " ");
+ hints_list_item.firstElementChild.innerHTML = hints[hint_index];
hints_list.appendChild(hints_list_item.cloneNode(true));
});
document.getElementById("hints-list").innerHTML = "";
diff --git a/tunictracker/tracker/static/tracker/assets/test.js b/tunictracker/tracker/static/tracker/assets/test.js
new file mode 100644
index 0000000..e69de29
diff --git a/tunictracker/tracker/static/tracker/assets/translate-hints.js b/tunictracker/tracker/static/tracker/assets/translate-hints.js
index 26fae1a..7c0470f 100644
--- a/tunictracker/tracker/static/tracker/assets/translate-hints.js
+++ b/tunictracker/tracker/static/tracker/assets/translate-hints.js
@@ -43,12 +43,69 @@ const lookup = {
"&": "zh",
};
const skip = [" ", ",", "."];
+const re =
+ /(\\"[\w\s\.\-']*\\")|\<(#[a-fA-F0-9]*)\>(.*)\<#[a-fA-F0-9]*\>|(\[[\w]*\])/gm;
+
+async function test_parse_hints(hint, translations) {
+ let new_hint = hint;
+ const color_tags = [
+ ...hint.matchAll(/\<[^\>]+\>(.*)\<[^\>]+\>/gm),
+ ...hint.matchAll(/\<([^\>]+)\>/gm),
+ ];
+ if (color_tags) {
+ if (color_tags[1]) {
+ const color_tags_text = `${color_tags[0][1]}`;
+ new_hint = new_hint.replace(
+ /\<[^\>]+\>[^\<]+\<[^\>]+\>/gm,
+ color_tags_text
+ );
+ }
+ }
+
+ const image_text = [...new_hint.matchAll(/\[[^\]]+\]/gm)];
+ if (image_text && image_text[0]) {
+ console.log(image_text[0][0]);
+ const translated_image = translations[image_text[0][0]];
+ console.log(translated_image);
+ new_hint = new_hint.replace(
+ /\[[^\]]+\]/gm,
+ `
`
+ );
+ }
+
+ const trunic_hint = new_hint
+ .split(/\<[^\>]+\>/gm)
+ .join(' "" ')
+ .split(/\"[^\"]*\"/gm);
+
+ for (const trunic in trunic_hint) {
+ new_hint = new_hint.replace(
+ trunic_hint[trunic].trim(),
+ translate(trunic_hint[trunic].trim())
+ );
+ }
+ return new_hint;
+}
+
+async function test_fetch() {
+ const response = await fetch(`http://localhost:51111/hints`);
+ const data = await response.json();
+ return data;
+}
+
+async function translation_fetch() {
+ const response = await fetch(
+ `http://localhost:8080/static/tracker/data/image_translations.json`
+ );
+ const data = await response.json();
+ return data;
+}
const translate = (input) => {
let payload = "";
let inQuote = false;
let cursor = 0;
-
+
// // remove [text in square brackets]
// // remove extra whitespace (eg., "I saw A [hourglass] "HOURGLASS"" becomes "I saw A "HOURGLASS"")
// input = input.replace(/\s+\[.+?\]\s+/gm, " ");
@@ -96,4 +153,4 @@ const translate = (input) => {
return `${payload} `;
};
-export default translate;
+export default { test_parse_hints, translation_fetch };
diff --git a/tunictracker/tracker/static/tracker/data/image_translations.json b/tunictracker/tracker/static/tracker/data/image_translations.json
new file mode 100644
index 0000000..ffff220
--- /dev/null
+++ b/tunictracker/tracker/static/tracker/data/image_translations.json
@@ -0,0 +1,86 @@
+{
+ "[stick]": "",
+ "[realsword]": "ThirdSword",
+ "[librariansword]": "SecondSword",
+ "[heirsword]": "ThirdSword",
+ "[wand]": "",
+ "[dagger]": "",
+ "[orb]": "",
+ "[shield]": "",
+ "[gun]": "",
+ "[hourglass]": "",
+ "[lantern]": "",
+ "[laurels]": "",
+ "[coin]": "",
+ "[trinket]": "",
+ "[square]": "",
+ "[fairy]": "",
+ "[mayor]": "SecretMayor",
+ "[book]": "",
+ "[att]": "",
+ "[def]": "",
+ "[potion]": "",
+ "[hp]": "",
+ "[sp]": "",
+ "[mp]": "",
+ "[attrelic]": "HeroRelicATT",
+ "[defrelic]": "HeroRelicDef",
+ "[potionrelic]": "HeroRelicPotion",
+ "[hprelic]": "HeroRelicHP",
+ "[sprelic]": "HeroRelicSP",
+ "[mprelic]": "HeroRelicMP",
+ "[yellowkey]": "",
+ "[housekey]": "",
+ "[vaultkey]": "",
+ "[firecracker]": "",
+ "[firebomb]": "",
+ "[icebomb]": "",
+ "[hpberry]": "",
+ "[mpberry]": "",
+ "[pepper]": "",
+ "[ivy]": "",
+ "[lure]": "",
+ "[effigy]": "",
+ "[flask]": "",
+ "[shard]": "",
+ "[dath]": "DathSteneTexture",
+ "[torch]": "",
+ "[triangle]": "",
+ "[realmoney]": "",
+ "[anklet]": "",
+ "[perfume]": "",
+ "[mufflingbell]": "",
+ "[rtsr]": "",
+ "[aurasgem]": "",
+ "[invertedash]": "",
+ "[bonecard]": "",
+ "[luckycup]": "",
+ "[glasscannon]": "",
+ "[daggerstrap]": "",
+ "[louderecho]": "",
+ "[magicecho]": "",
+ "[bracer]": "",
+ "[tincture]": "",
+ "[btsr]": "",
+ "[scavengermask]": "",
+ "[redhex]": "RedQuestagon",
+ "[greenhex]": "GreenQuestagon",
+ "[bluehex]": "BlueQuestagon",
+ "[goldhex]": "GoldHex",
+ "[mrmayor]": "MrMayor",
+ "[secretlegend]": "SecretLegend",
+ "[sacredgeometry]": "SacredGeometry",
+ "[vintage]": "Vintage",
+ "[justsomepals]": "JustSomePals",
+ "[regalweasel]": "RegalWeasel",
+ "[springfalls]": "SpringFalls",
+ "[powerup]": "PowerUp",
+ "[backtowork]": "BackToWork",
+ "[phonomath]": "Phonomath",
+ "[dusty]": "Dusty",
+ "[foreverfriend]": "ForeverFriend",
+ "[fooltrap]": "TinyFox",
+ "[archipelago]": "ArchipelagoItem",
+ "[ladder]": "Ladder",
+ "[hexagram]": "GoldHex"
+}