plugin-backend #1
14
tunictracker/tracker/data/hints.json
Normal file
14
tunictracker/tracker/data/hints.json
Normal file
@ -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>...\""
|
||||||
|
}
|
@ -18,22 +18,41 @@ var cross_codes = {};
|
|||||||
var total_checks = 0;
|
var total_checks = 0;
|
||||||
var total_entrances = 0;
|
var total_entrances = 0;
|
||||||
var all_scenes = [];
|
var all_scenes = [];
|
||||||
|
var image_translations = {};
|
||||||
|
|
||||||
window.onload = async () => {
|
window.onload = async () => {
|
||||||
await get_updated_server_address();
|
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`)
|
fetch(`${document.URL}static/tracker/data/holy_cross_codes.json`)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then(
|
.then(
|
||||||
(data) => {
|
(data) => {
|
||||||
cross_codes = JSON.parse(JSON.stringify(data));
|
cross_codes = JSON.parse(JSON.stringify(data));
|
||||||
initialize_elements();
|
|
||||||
refresh_elements();
|
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
console.error(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() {
|
async function get_updated_server_address() {
|
||||||
fetch(`${document.URL}get/address`)
|
fetch(`${document.URL}get/address`)
|
||||||
@ -890,44 +909,54 @@ async function update_hints(hints) {
|
|||||||
hints_list.innerHTML = "";
|
hints_list.innerHTML = "";
|
||||||
hints_list.appendChild(hints_list_item.cloneNode(true));
|
hints_list.appendChild(hints_list_item.cloneNode(true));
|
||||||
hints_list_item.classList.remove("hidden");
|
hints_list_item.classList.remove("hidden");
|
||||||
Object.keys(hints).forEach((hint_index) => {
|
// Object.keys(hints).forEach((hint_index) => {
|
||||||
let hint = hints[hint_index].split(
|
for (const hint_index of Object.keys(hints)) {
|
||||||
/(\[[\w\s]+?\]|\"[\w \d\>\<#.\-\']+\"|\<[\w\d#]+\>)/gm
|
// 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 = `<img class="flex object-contain w-8 h-8 my-auto align-middle" src="${translated_image_name}.png"></img>`;
|
||||||
|
// // } 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) => {
|
Object.keys(hints).forEach((hint_index) => {
|
||||||
let hint = hints[hint_index];
|
// let hint = hints[hint_index];
|
||||||
let matches = Array.from(
|
// let matches = Array.from(
|
||||||
hint.matchAll(/\<([\w\d#]+)\>(.*)(\<[\w\d#]+\>)/gm)
|
// hint.matchAll(/\<([\w\d#]+)\>(.*)(\<[\w\d#]+\>)/gm)
|
||||||
);
|
// );
|
||||||
if (matches.length >= 1) {
|
// if (matches.length >= 1) {
|
||||||
hint = hint.replace(
|
// hint = hint.replace(
|
||||||
/(\<[\w\d#]+\>.*\<[\w\d#]+\>)/gm,
|
// /(\<[\w\d#]+\>.*\<[\w\d#]+\>)/gm,
|
||||||
`<span style="color: ${matches[0][1]};">${matches[0][2]}</span>`
|
// `<span style="color: ${matches[0][1]};">${matches[0][2]}</span>`
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
hint = hint.replace(/ "|" /gm, " ");
|
// hint = hint.replace(/ "|" /gm, " ");
|
||||||
hints_list_item.firstElementChild.innerHTML = hint;
|
hints_list_item.firstElementChild.innerHTML = hints[hint_index];
|
||||||
hints_list.appendChild(hints_list_item.cloneNode(true));
|
hints_list.appendChild(hints_list_item.cloneNode(true));
|
||||||
});
|
});
|
||||||
document.getElementById("hints-list").innerHTML = "";
|
document.getElementById("hints-list").innerHTML = "";
|
||||||
|
0
tunictracker/tracker/static/tracker/assets/test.js
Normal file
0
tunictracker/tracker/static/tracker/assets/test.js
Normal file
@ -43,6 +43,63 @@ const lookup = {
|
|||||||
"&": "zh",
|
"&": "zh",
|
||||||
};
|
};
|
||||||
const skip = [" ", ",", "."];
|
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 = `<span style="color: ${color_tags[1][1]}">${color_tags[0][1]}</span>`;
|
||||||
|
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,
|
||||||
|
`<img class="inline-block object-contain w-8 h-8 my-auto align-middle" src="/static/tracker/images/sprites/${translated_image}.png">`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
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) => {
|
const translate = (input) => {
|
||||||
let payload = "";
|
let payload = "";
|
||||||
@ -96,4 +153,4 @@ const translate = (input) => {
|
|||||||
return `<span class="inline-block pt-0.5 font-trunic text-md sm:text-xl h-full align-bottom">${payload} </span>`;
|
return `<span class="inline-block pt-0.5 font-trunic text-md sm:text-xl h-full align-bottom">${payload} </span>`;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default translate;
|
export default { test_parse_hints, translation_fetch };
|
||||||
|
@ -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"
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user