max completion % depending on the save file version

This commit is contained in:
ReznoRMichael 2021-07-14 16:21:27 +02:00
parent 9a62dd1fce
commit f1275d00db
5 changed files with 394 additions and 333 deletions

View file

@ -145,7 +145,7 @@ function HKCheckCompletion(jsonObject) {
CheckPlayTime(_hk_database_js__WEBPACK_IMPORTED_MODULE_0__.default.sections.intro, HKPlayerData.playTime); // ---------------- Game Completion Status ----------------- // CheckPlayTime(_hk_database_js__WEBPACK_IMPORTED_MODULE_0__.default.sections.intro, HKPlayerData.playTime); // ---------------- Game Completion Status ----------------- //
CheckCompletionPercent(_hk_database_js__WEBPACK_IMPORTED_MODULE_0__.default.sections.intro, HKPlayerData.completionPercentage); // ---------------- Game Completion Status ----------------- // CheckCompletionPercent(_hk_database_js__WEBPACK_IMPORTED_MODULE_0__.default.sections.intro, HKPlayerData); // ---------------- Game Completion Status ----------------- //
CheckSaveFileVersion(_hk_database_js__WEBPACK_IMPORTED_MODULE_0__.default.sections.intro, HKPlayerData.version); // ---------------- Fleur Divide ----------------- // CheckSaveFileVersion(_hk_database_js__WEBPACK_IMPORTED_MODULE_0__.default.sections.intro, HKPlayerData.version); // ---------------- Fleur Divide ----------------- //
// AppendHTML(HK.sections.intro, FLEUR_DIVIDE); // AppendHTML(HK.sections.intro, FLEUR_DIVIDE);
@ -263,8 +263,21 @@ function PrepareHTMLString(section) {
function CurrentDataTrue() { function CurrentDataTrue() {
var section = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var section = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var entry = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ""; var entry = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
section.percent++;
if (section.id === "hk-equipment") section.percent++; // double % for equipment /* Increase section percentage except the Game Status and Hints sections */
switch (section.id) {
case "hk-intro":
case "hk-hints":
break;
case "hk-equipment":
// double % for equipment
section.percent += 2;
break;
default:
section.percent++;
}
section.entries[entry].icon = "green"; section.entries[entry].icon = "green";
} }
@ -323,11 +336,43 @@ function CheckPlayTime(section, playTime) {
*/ */
function CheckCompletionPercent(section, completionPercentage) { function CheckCompletionPercent(section, playerData) {
completionPercentage >= 112 ? CurrentDataTrue(section, "gameCompletion") : CurrentDataFalse(section, "gameCompletion"); var completionPercentage = Math.round(playerData.completionPercentage);
var maxPercent = 0;
/* Normal (current) game version behaviour: 112% */
section.maxPercent = section.maxPercentDefault;
maxPercent = section.maxPercentDefault;
section.entries.gameCompletion.spoilerAfter = section.entries.gameCompletion.spoilerAfterDefault;
section.percent = completionPercentage; section.percent = completionPercentage;
section.entries.gameCompletion.spoiler = completionPercentage; section.entries.gameCompletion.spoiler = completionPercentage;
var textFill = "Game Completion:" + pSpan + "<b>" + completionPercentage + " %</b>" + pSpan + "(out of " + section.maxPercent + " %)"; // document.getElementById(section.id).innerHTML += divStart + completionSymbol + textFill + divEnd; /* Lifeblood behaviour: 107% */
if (!playerData.hasOwnProperty("hasGodfinder")) {
section.maxPercent = section.maxPercentLifeblood;
maxPercent = section.maxPercentLifeblood;
section.entries.gameCompletion.spoilerAfter = section.entries.gameCompletion.spoilerAfterLifeblood;
}
/* Grimm Troupe bahaviour: 106% */
if (!playerData.hasOwnProperty("killedHiveKnight")) {
section.maxPercent = section.maxPercentGrimmTroupe;
maxPercent = section.maxPercentGrimmTroupe;
section.entries.gameCompletion.spoilerAfter = section.entries.gameCompletion.spoilerAfterGrimmTroupe;
}
/* Base Game behaviour with no Content Packs: 100% */
if (!playerData.hasOwnProperty("gotCharm_37")) {
section.maxPercent = section.maxPercentBaseGame;
maxPercent = section.maxPercentBaseGame;
section.entries.gameCompletion.spoilerAfter = section.entries.gameCompletion.spoilerAfterBaseGame;
}
completionPercentage >= maxPercent ? CurrentDataTrue(section, "gameCompletion") : CurrentDataFalse(section, "gameCompletion");
/* let textFill = "Game Completion:" + pSpan + "<b>" + completionPercentage + " %</b>" + pSpan + "(out of " + section.maxPercent + " %)"; */
// document.getElementById(section.id).innerHTML += divStart + completionSymbol + textFill + divEnd;
} }
/** /**
* Reads the "version" string from the save file and appends it to the selected div ID element * Reads the "version" string from the save file and appends it to the selected div ID element
@ -2692,6 +2737,10 @@ var HK = {
id: "hk-intro", id: "hk-intro",
percent: 0, percent: 0,
maxPercent: 112, maxPercent: 112,
maxPercentDefault: 112,
maxPercentBaseGame: 100,
maxPercentGrimmTroupe: 106,
maxPercentLifeblood: 107,
entries: { entries: {
timePlayed: { timePlayed: {
id: "timePlayed", id: "timePlayed",
@ -2707,7 +2756,11 @@ var HK = {
icon: "red", icon: "red",
name: "Game Completion:", name: "Game Completion:",
spoiler: 0, spoiler: 0,
spoilerAfter: "(out of 112 %)" spoilerAfter: "(out of 112 %)",
spoilerAfterDefault: "(out of 112 %)",
spoilerAfterBaseGame: "(out of 100 %)",
spoilerAfterGrimmTroupe: "(out of 106 %)",
spoilerAfterLifeblood: "(out of 107 %)"
}, },
saveVersion: { saveVersion: {
id: "saveVersion", id: "saveVersion",
@ -5580,7 +5633,7 @@ function CompletionFill(section) {
if (section.id != "hk-intro") cp += "/"; if (section.id != "hk-intro") cp += "/";
fillText = "<div class='percent-box".concat(cl, "'>").concat(section.id === "hk-intro" ? cp : cp + section.maxPercent, "%</div>"); fillText = "<div class='percent-box".concat(cl, "'>").concat(section.id === "hk-intro" ? cp : "".concat(cp).concat(section.maxPercent), "%</div>");
} }
return "\t".concat(h2id).concat(h2).concat(fillText, "</h2>\n"); return "\t".concat(h2id).concat(h2).concat(fillText, "</h2>\n");
@ -5595,8 +5648,7 @@ function SingleEntryFill(obj) {
let iconRed = SYMBOL_FALSE; let iconRed = SYMBOL_FALSE;
let iconClock = SYMBOL_CLOCK; let iconClock = SYMBOL_CLOCK;
let iconNull = SYMBOL_EMPTY; let iconNull = SYMBOL_EMPTY;
let textPrefix = "";
let textPrefix = "";
let textSuffix = ""; let textSuffix = "";
let textFill = ""; let textFill = "";
let Img = ""; let Img = "";
@ -5609,8 +5661,7 @@ function SingleEntryFill(obj) {
let geoNormalImage = `<img src='${GEO_IMAGE}' class='geo-symbol' alt='geo symbol image' title='Geo'>`; let geoNormalImage = `<img src='${GEO_IMAGE}' class='geo-symbol' alt='geo symbol image' title='Geo'>`;
let geoShadeImage = `<img src='${GEO_SHADE_IMAGE}' class='geo-symbol' alt='shade geo symbol image' title='Shade Geo'>`; let geoShadeImage = `<img src='${GEO_SHADE_IMAGE}' class='geo-symbol' alt='shade geo symbol image' title='Shade Geo'>`;
let wiki = ""; let wiki = "";
let div = `<div class='single-entry'>`;
let div = `<div class='single-entry'>`;
let divFlex = `<div class='flex-container align-center'>`; let divFlex = `<div class='flex-container align-center'>`;
let b = ["<b>", "</b>"]; let b = ["<b>", "</b>"];
let p = "<span class='p-left-small'></span>"; let p = "<span class='p-left-small'></span>";
@ -5621,8 +5672,7 @@ function SingleEntryFill(obj) {
if (entry.hasOwnProperty("icon")) { if (entry.hasOwnProperty("icon")) {
switch (entry.icon) { switch (entry.icon) {
case "clock":
case "clock":
icon = iconClock; icon = iconClock;
break; break;
case "green": case "green":
@ -5637,132 +5687,99 @@ function SingleEntryFill(obj) {
} else { } else {
icon = iconRed; icon = iconRed;
} }
if (entry.hasOwnProperty("name")) {
if (entry.hasOwnProperty("name")) {
textPrefix = entry.name; textPrefix = entry.name;
} }
if (entry.hasOwnProperty("spoiler")) {
if (entry.hasOwnProperty("spoiler")) {
textSuffix = entry.spoiler; textSuffix = entry.spoiler;
} }
if (entry.hasOwnProperty("wiki")) {
if (entry.hasOwnProperty("wiki")) {
wiki = entry.wiki; wiki = entry.wiki;
} }
if (!textPrefix.length) b = ["", ""];
if (!textPrefix.length) b = ["", ""];
if (wiki.length) b = [`<a class="wiki" href="${WIKI_LINK}${wiki}" target="_blank">`, "</a>"]; if (wiki.length) b = [`<a class="wiki" href="${WIKI_LINK}${wiki}" target="_blank">`, "</a>"];
// #################### Different behaviour depending on the section #######################
// #################### Different behaviour depending on the section ####################### switch (section) {
case "intro":
switch (section) {
case "intro":
b = ["", ""]; b = ["", ""];
span = ["<b>", "</b>"]; span = ["<b>", "</b>"];
// Different text and images for each entry in the "Game Status" section
// Different text and images for each entry in the "Game Status" section switch (entry.id) {
switch (entry.id) {
case "gameCompletion": case "gameCompletion":
textSuffix = `${entry.spoiler} %`; textSuffix = `${entry.spoiler} %`;
break;
break; case "health":
case "health":
div = divFlex; div = divFlex;
span = ["", ""]; span = ["", ""];
(entry.permadeathMode) ? Img = maskSteel: Img = maskNormal;
(entry.permadeathMode) ? Img = maskSteel: Img = maskNormal; for (let i = 0, total = entry.amountTotal; i < total; i++) {
for (let i = 0, total = entry.amountTotal; i < total; i++) {
textSuffix += Img; textSuffix += Img;
} }
textSuffix += `${p}<sup>(${entry.amountTotal})</sup>`;
textSuffix += `${p}<sup>(${entry.amountTotal})</sup>`; p = "";
p = "";
break; break;
case "soul":
case "soul":
div = divFlex; div = divFlex;
span = ["", ""]; span = ["", ""];
Img = soulNormal; Img = soulNormal;
for (let i = 0, total = Math.round(entry.amountTotal / 33); i < total; i++) {
for (let i = 0, total = Math.round(entry.amountTotal / 33); i < total; i++) {
textSuffix += Img; textSuffix += Img;
} }
textSuffix += `${p}<sup>(${Math.round(entry.amountTotal / 33)})</sup>`;
textSuffix += `${p}<sup>(${Math.round(entry.amountTotal / 33)})</sup>`; p = "";
p = "";
break; break;
case "notches":
case "notches":
div = divFlex; div = divFlex;
span = ["", ""]; span = ["", ""];
// First, check filled (used) notches and fill them (skips if no filled notches)
// First, check filled (used) notches and fill them (skips if no filled notches)
if (entry.amountFilled > 0) { if (entry.amountFilled > 0) {
for (let i = 0, total = entry.amountFilled; i < total; i++) { for (let i = 0, total = entry.amountFilled; i < total; i++) {
textSuffix += notchFilledImage; textSuffix += notchFilledImage;
} }
} }
// Second, check overcharmed notches and fill them (skips if player is not overcharmed)
// Second, check overcharmed notches and fill them (skips if player is not overcharmed)
if (entry.amountOvercharmed > 0) { if (entry.amountOvercharmed > 0) {
for (let i = 0, total = entry.amountOvercharmed; i < total; i++) { for (let i = 0, total = entry.amountOvercharmed; i < total; i++) {
textSuffix += notchOvercharmedImage; textSuffix += notchOvercharmedImage;
} }
} }
// Last, fill all unused notches
// Last, fill all unused notches
if (entry.amountUnused > 0) { if (entry.amountUnused > 0) {
for (let i = 0, total = entry.amountUnused; i < total; i++) { for (let i = 0, total = entry.amountUnused; i < total; i++) {
textSuffix += notchNormalImage; textSuffix += notchNormalImage;
} }
} }
textSuffix += `${p}<sup>(${entry.amountTotal})</sup>`;
textSuffix += `${p}<sup>(${entry.amountTotal})</sup>`; break;
case "geo":
break;
case "geo":
div = divFlex; div = divFlex;
span = ["", ""]; span = ["", ""];
textSuffix += `${geoNormalImage}<b>${entry.amount}</b>`;
textSuffix += `${geoNormalImage}<b>${entry.amount}</b>`;
// Show Shade Geo value and image only if Shade has at least 1 Geo on it // Show Shade Geo value and image only if Shade has at least 1 Geo on it
if (entry.amountShade > 0) textSuffix += `${p}+${geoShadeImage}<b>${entry.amountShade}</b>`; if (entry.amountShade > 0) textSuffix += `${p}+${geoShadeImage}<b>${entry.amountShade}</b>`;
// Show also total Geo (Geo + Shade Geo) if player has at least 1 geo alongside the shade geo
// Show also total Geo (Geo + Shade Geo) if player has at least 1 geo alongside the shade geo
if (entry.amount > 0 && entry.amountShade > 0) textSuffix += `${p}=${p}<b>${entry.amountTotal}</b>`; if (entry.amount > 0 && entry.amountShade > 0) textSuffix += `${p}=${p}<b>${entry.amountTotal}</b>`;
p = ""; p = "";
break; break;
default:
default:
} }
// Optimized only for the "intro" section!
// Optimized only for the "intro" section!
if (entry.hasOwnProperty("spoilerAfter")) { if (entry.hasOwnProperty("spoilerAfter")) {
spoilerAfter = `</b> ${entry.spoilerAfter}`; spoilerAfter = `</b> ${entry.spoilerAfter}`;
span[1] = ""; span[1] = "";
} }
break; break;
case "hints":
case "hints":
b = ["", ""]; b = ["", ""];
span = ["<span>", "</span>"]; span = ["<span>", "</span>"];
icon = iconNull; icon = iconNull;
break; break;
default: default:
span = ["<span class='spoiler-span'>", "</span>"];
span = ["<span class='spoiler-span'>", "</span>"];
spoiler = ["<span class='spoiler-text'>", "</span>"]; spoiler = ["<span class='spoiler-text'>", "</span>"];
if (entry.hasOwnProperty("amount")) {
if (entry.hasOwnProperty("amount")) {
if (entry.hasOwnProperty("disabled")) { if (entry.hasOwnProperty("disabled")) {
if (entry.disabled !== true) { if (entry.disabled !== true) {
textPrefix += `: ${entry.amount}`; textPrefix += `: ${entry.amount}`;
@ -5771,35 +5788,26 @@ function SingleEntryFill(obj) {
textPrefix += `: ${entry.amount}`; textPrefix += `: ${entry.amount}`;
} }
} }
if (entry.hasOwnProperty("amountTotal")) {
if (entry.hasOwnProperty("amountTotal")) {
textPrefix += ` / ${entry.amountTotal}`; textPrefix += ` / ${entry.amountTotal}`;
} }
if (entry.hasOwnProperty("id")) {
if (entry.hasOwnProperty("id")) { switch (entry.id) {
case "geoRocks":
switch (entry.id) {
case "geoRocks":
case "itemsDiscovered": case "itemsDiscovered":
textPrefix += `: ${entry.notActivated} | ${entry.activated} | ${entry.discoveredTotal}`; textPrefix += `: ${entry.notActivated} | ${entry.activated} | ${entry.discoveredTotal}`;
break;
break; case "zoteStatus":
case "zoteStatus":
case "nailsmithStatus": case "nailsmithStatus":
if (entry.hasOwnProperty("currentName") && entry.hasOwnProperty("currentSpoiler")) { if (entry.hasOwnProperty("currentName") && entry.hasOwnProperty("currentSpoiler")) {
textPrefix = entry[entry.currentName]; textPrefix = entry[entry.currentName];
textSuffix = entry[entry.currentSpoiler]; textSuffix = entry[entry.currentSpoiler];
} }
break;
break; default:
default:
} }
} }
if (entry.hasOwnProperty("disabled")) {
if (entry.hasOwnProperty("disabled")) {
if (entry.disabled === true) { if (entry.disabled === true) {
textPrefix = `<del>${textPrefix}</del>`; textPrefix = `<del>${textPrefix}</del>`;
} }
@ -5808,8 +5816,7 @@ function SingleEntryFill(obj) {
if (textSuffix.length && textPrefix.length) textSuffix = `${textSuffix}`; if (textSuffix.length && textPrefix.length) textSuffix = `${textSuffix}`;
if (textPrefix.includes("<del>")) textSuffix = `<del>${textSuffix}</del>`; if (textPrefix.includes("<del>")) textSuffix = `<del>${textSuffix}</del>`;
} }
*/
*/
/* return [ /* return [
div, div,

File diff suppressed because one or more lines are too long

View file

@ -152,7 +152,7 @@ function HKCheckCompletion(jsonObject) {
// ---------------- Game Completion Status ----------------- // // ---------------- Game Completion Status ----------------- //
CheckCompletionPercent(HK.sections.intro, HKPlayerData.completionPercentage); CheckCompletionPercent(HK.sections.intro, HKPlayerData);
// ---------------- Game Completion Status ----------------- // // ---------------- Game Completion Status ----------------- //
@ -336,8 +336,22 @@ function PrepareHTMLString(section, textPrefix = "Unknown Completion Element: ",
*/ */
function CurrentDataTrue(section = {}, entry = "") { function CurrentDataTrue(section = {}, entry = "") {
section.percent++; /* Increase section percentage except the Game Status and Hints sections */
if (section.id === "hk-equipment") section.percent++; // double % for equipment switch (section.id) {
case "hk-intro":
case "hk-hints":
break;
case "hk-equipment":
// double % for equipment
section.percent += 2;
break;
default:
section.percent++;
}
section.entries[entry].icon = "green"; section.entries[entry].icon = "green";
} }
@ -396,14 +410,46 @@ function CheckPlayTime(section, playTime) {
* @param {object} section ID of the HTML element for data appending * @param {object} section ID of the HTML element for data appending
* @param {number} completionPercentage Number of completion percentage * @param {number} completionPercentage Number of completion percentage
*/ */
function CheckCompletionPercent(section, completionPercentage) { function CheckCompletionPercent(section, playerData) {
(completionPercentage >= 112) ? CurrentDataTrue(section, "gameCompletion"): CurrentDataFalse(section, "gameCompletion"); let completionPercentage = Math.round(playerData.completionPercentage);
let maxPercent = 0;
/* Normal (current) game version behaviour: 112% */
section.maxPercent = section.maxPercentDefault;
maxPercent = section.maxPercentDefault;
section.entries.gameCompletion.spoilerAfter = section.entries.gameCompletion.spoilerAfterDefault;
section.percent = completionPercentage; section.percent = completionPercentage;
section.entries.gameCompletion.spoiler = completionPercentage; section.entries.gameCompletion.spoiler = completionPercentage;
let textFill = "Game Completion:" + pSpan + "<b>" + completionPercentage + " %</b>" + pSpan + "(out of " + section.maxPercent + " %)"; /* Lifeblood behaviour: 107% */
if (!playerData.hasOwnProperty("hasGodfinder")) {
section.maxPercent = section.maxPercentLifeblood;
maxPercent = section.maxPercentLifeblood;
section.entries.gameCompletion.spoilerAfter = section.entries.gameCompletion.spoilerAfterLifeblood;
}
/* Grimm Troupe bahaviour: 106% */
if (!playerData.hasOwnProperty("killedHiveKnight")) {
section.maxPercent = section.maxPercentGrimmTroupe;
maxPercent = section.maxPercentGrimmTroupe;
section.entries.gameCompletion.spoilerAfter = section.entries.gameCompletion.spoilerAfterGrimmTroupe;
}
/* Base Game behaviour with no Content Packs: 100% */
if (!playerData.hasOwnProperty("gotCharm_37")) {
section.maxPercent = section.maxPercentBaseGame;
maxPercent = section.maxPercentBaseGame;
section.entries.gameCompletion.spoilerAfter = section.entries.gameCompletion.spoilerAfterBaseGame;
}
(completionPercentage >= maxPercent) ? CurrentDataTrue(section, "gameCompletion"): CurrentDataFalse(section, "gameCompletion");
/* let textFill = "Game Completion:" + pSpan + "<b>" + completionPercentage + " %</b>" + pSpan + "(out of " + section.maxPercent + " %)"; */
// document.getElementById(section.id).innerHTML += divStart + completionSymbol + textFill + divEnd; // document.getElementById(section.id).innerHTML += divStart + completionSymbol + textFill + divEnd;
} }

View file

@ -16,6 +16,10 @@ const HK = {
id: "hk-intro", id: "hk-intro",
percent: 0, percent: 0,
maxPercent: 112, maxPercent: 112,
maxPercentDefault: 112,
maxPercentBaseGame: 100,
maxPercentGrimmTroupe: 106,
maxPercentLifeblood: 107,
entries: { entries: {
timePlayed: { timePlayed: {
id: "timePlayed", id: "timePlayed",
@ -32,6 +36,10 @@ const HK = {
name: "Game Completion:", name: "Game Completion:",
spoiler: 0, spoiler: 0,
spoilerAfter: "(out of 112 %)", spoilerAfter: "(out of 112 %)",
spoilerAfterDefault: "(out of 112 %)",
spoilerAfterBaseGame: "(out of 100 %)",
spoilerAfterGrimmTroupe: "(out of 106 %)",
spoilerAfterLifeblood: "(out of 107 %)",
}, },
saveVersion: { saveVersion: {
id: "saveVersion", id: "saveVersion",

View file

@ -334,7 +334,7 @@ function GenerateInnerHTML(db) {
break; break;
/* #################### Hints (hints) #################### */ /* #################### Hints (hints) #################### */
case "hints": case "hints":
obj.b = ["", ""]; obj.b = ["", ""];
@ -350,7 +350,7 @@ function GenerateInnerHTML(db) {
break; break;
/* ###################### Create all other sections ##################### */ /* ###################### Create all other sections ##################### */
default: default:
@ -502,7 +502,7 @@ function SectionStart(section) {
/** /**
* Replaces the h2 titles with max percent values as read from the database * Replaces the h2 titles with max percent values as read from the database
*/ */
function CompletionFillNoSave(section) { function CompletionFillNoSave(section) {
let id = ""; let id = "";
let h2 = ""; let h2 = "";
@ -528,7 +528,7 @@ function SectionStart(section) {
/** /**
* Replaces the h2 titles with a current percent/max percent values as read from the database * Replaces the h2 titles with a current percent/max percent values as read from the database
*/ */
function CompletionFill(section) { function CompletionFill(section) {
let h2 = section.h2; let h2 = section.h2;
let h2id = `<h2 id="h2-${section.id}">`; let h2id = `<h2 id="h2-${section.id}">`;
@ -572,7 +572,7 @@ function SectionStart(section) {
// needed for Game Status to show percentage properly (adds a slash for all boxes except the Game Status one) // needed for Game Status to show percentage properly (adds a slash for all boxes except the Game Status one)
if (section.id != "hk-intro") cp += "/"; if (section.id != "hk-intro") cp += "/";
fillText = `<div class='percent-box${cl}'>${(section.id === "hk-intro") ? cp: cp + section.maxPercent}%</div>`; fillText = `<div class='percent-box${cl}'>${(section.id === "hk-intro") ? cp: `${cp}${section.maxPercent}`}%</div>`;
} }
return `\t${h2id}${h2}${fillText}</h2>\n`; return `\t${h2id}${h2}${fillText}</h2>\n`;
@ -581,227 +581,227 @@ function SectionStart(section) {
/* function SingleEntryFill(section, entry) { */ /* function SingleEntryFill(section, entry) { */
function SingleEntryFill(obj) { function SingleEntryFill(obj) {
/* /*
let icon = ""; let icon = "";
let iconGreen = SYMBOL_TRUE; let iconGreen = SYMBOL_TRUE;
let iconRed = SYMBOL_FALSE; let iconRed = SYMBOL_FALSE;
let iconClock = SYMBOL_CLOCK; let iconClock = SYMBOL_CLOCK;
let iconNull = SYMBOL_EMPTY; let iconNull = SYMBOL_EMPTY;
let textPrefix = ""; let textPrefix = "";
let textSuffix = ""; let textSuffix = "";
let textFill = ""; let textFill = "";
let Img = ""; let Img = "";
let maskNormal = `<img src='${HEALTH_MASK_IMAGE}' class='health-mask' alt='health mask image' title='Health Mask'>`; let maskNormal = `<img src='${HEALTH_MASK_IMAGE}' class='health-mask' alt='health mask image' title='Health Mask'>`;
let maskSteel = `<img src='${HEALTH_MASK_STEEL_IMAGE}' class='health-mask' alt='steel health mask image' title='Steel Health Mask'>`; let maskSteel = `<img src='${HEALTH_MASK_STEEL_IMAGE}' class='health-mask' alt='steel health mask image' title='Steel Health Mask'>`;
let soulNormal = `<img src='${SOUL_ORB_IMAGE}' class='soul-orb' alt='soul orb image' title='Single Soul Orb (one spell cast)'>`; let soulNormal = `<img src='${SOUL_ORB_IMAGE}' class='soul-orb' alt='soul orb image' title='Single Soul Orb (one spell cast)'>`;
let notchNormalImage = `<img src='${NOTCH_IMAGE}' class='notch' alt='notch image' title='Charm Notch (Free)'>`; let notchNormalImage = `<img src='${NOTCH_IMAGE}' class='notch' alt='notch image' title='Charm Notch (Free)'>`;
let notchFilledImage = `<img src='${NOTCH_FILLED_IMAGE}' class='notch' alt='notch image' title='Charm Notch (Used)'>`; let notchFilledImage = `<img src='${NOTCH_FILLED_IMAGE}' class='notch' alt='notch image' title='Charm Notch (Used)'>`;
let notchOvercharmedImage = `<img src='${NOTCH_OVERCHARMED_IMAGE}' class='notch' alt='notch image' title='Charm Notch (Overcharmed)'>`; let notchOvercharmedImage = `<img src='${NOTCH_OVERCHARMED_IMAGE}' class='notch' alt='notch image' title='Charm Notch (Overcharmed)'>`;
let geoNormalImage = `<img src='${GEO_IMAGE}' class='geo-symbol' alt='geo symbol image' title='Geo'>`; let geoNormalImage = `<img src='${GEO_IMAGE}' class='geo-symbol' alt='geo symbol image' title='Geo'>`;
let geoShadeImage = `<img src='${GEO_SHADE_IMAGE}' class='geo-symbol' alt='shade geo symbol image' title='Shade Geo'>`; let geoShadeImage = `<img src='${GEO_SHADE_IMAGE}' class='geo-symbol' alt='shade geo symbol image' title='Shade Geo'>`;
let wiki = ""; let wiki = "";
let div = `<div class='single-entry'>`; let div = `<div class='single-entry'>`;
let divFlex = `<div class='flex-container align-center'>`; let divFlex = `<div class='flex-container align-center'>`;
let b = ["<b>", "</b>"]; let b = ["<b>", "</b>"];
let p = "<span class='p-left-small'></span>"; let p = "<span class='p-left-small'></span>";
let span = ["", ""]; let span = ["", ""];
let spoiler = ["", ""]; let spoiler = ["", ""];
let spoilerAfter = ""; let spoilerAfter = "";
if (entry.hasOwnProperty("icon")) { if (entry.hasOwnProperty("icon")) {
switch (entry.icon) { switch (entry.icon) {
case "clock":
icon = iconClock;
break;
case "green":
icon = iconGreen;
break;
case "red":
icon = iconRed;
break;
default:
icon = iconNull;
}
} else {
icon = iconRed;
}
if (entry.hasOwnProperty("name")) {
textPrefix = entry.name;
}
if (entry.hasOwnProperty("spoiler")) {
textSuffix = entry.spoiler;
}
if (entry.hasOwnProperty("wiki")) {
wiki = entry.wiki;
}
if (!textPrefix.length) b = ["", ""];
if (wiki.length) b = [`<a class="wiki" href="${WIKI_LINK}${wiki}" target="_blank">`, "</a>"];
// #################### Different behaviour depending on the section #######################
switch (section) {
case "intro":
b = ["", ""];
span = ["<b>", "</b>"];
// Different text and images for each entry in the "Game Status" section
switch (entry.id) {
case "gameCompletion":
textSuffix = `${entry.spoiler} %`;
case "clock":
icon = iconClock;
break; break;
case "green":
case "health": icon = iconGreen;
div = divFlex;
span = ["", ""];
(entry.permadeathMode) ? Img = maskSteel: Img = maskNormal;
for (let i = 0, total = entry.amountTotal; i < total; i++) {
textSuffix += Img;
}
textSuffix += `${p}<sup>(${entry.amountTotal})</sup>`;
p = "";
break; break;
case "red":
case "soul": icon = iconRed;
div = divFlex;
span = ["", ""];
Img = soulNormal;
for (let i = 0, total = Math.round(entry.amountTotal / 33); i < total; i++) {
textSuffix += Img;
}
textSuffix += `${p}<sup>(${Math.round(entry.amountTotal / 33)})</sup>`;
p = "";
break; break;
case "notches":
div = divFlex;
span = ["", ""];
// First, check filled (used) notches and fill them (skips if no filled notches)
if (entry.amountFilled > 0) {
for (let i = 0, total = entry.amountFilled; i < total; i++) {
textSuffix += notchFilledImage;
}
}
// Second, check overcharmed notches and fill them (skips if player is not overcharmed)
if (entry.amountOvercharmed > 0) {
for (let i = 0, total = entry.amountOvercharmed; i < total; i++) {
textSuffix += notchOvercharmedImage;
}
}
// Last, fill all unused notches
if (entry.amountUnused > 0) {
for (let i = 0, total = entry.amountUnused; i < total; i++) {
textSuffix += notchNormalImage;
}
}
textSuffix += `${p}<sup>(${entry.amountTotal})</sup>`;
break;
case "geo":
div = divFlex;
span = ["", ""];
textSuffix += `${geoNormalImage}<b>${entry.amount}</b>`;
// Show Shade Geo value and image only if Shade has at least 1 Geo on it
if (entry.amountShade > 0) textSuffix += `${p}+${geoShadeImage}<b>${entry.amountShade}</b>`;
// Show also total Geo (Geo + Shade Geo) if player has at least 1 geo alongside the shade geo
if (entry.amount > 0 && entry.amountShade > 0) textSuffix += `${p}=${p}<b>${entry.amountTotal}</b>`;
p = "";
break;
default: default:
icon = iconNull;
} }
} else {
icon = iconRed;
}
// Optimized only for the "intro" section! if (entry.hasOwnProperty("name")) {
if (entry.hasOwnProperty("spoilerAfter")) { textPrefix = entry.name;
spoilerAfter = `</b> ${entry.spoilerAfter}`; }
span[1] = "";
}
break;
case "hints": if (entry.hasOwnProperty("spoiler")) {
b = ["", ""]; textSuffix = entry.spoiler;
span = ["<span>", "</span>"]; }
icon = iconNull;
break;
default: if (entry.hasOwnProperty("wiki")) {
wiki = entry.wiki;
}
span = ["<span class='spoiler-span'>", "</span>"]; if (!textPrefix.length) b = ["", ""];
spoiler = ["<span class='spoiler-text'>", "</span>"]; if (wiki.length) b = [`<a class="wiki" href="${WIKI_LINK}${wiki}" target="_blank">`, "</a>"];
if (entry.hasOwnProperty("amount")) { // #################### Different behaviour depending on the section #######################
if (entry.hasOwnProperty("disabled")) {
if (entry.disabled !== true) {
textPrefix += `: ${entry.amount}`;
}
} else {
textPrefix += `: ${entry.amount}`;
}
}
if (entry.hasOwnProperty("amountTotal")) { switch (section) {
textPrefix += ` / ${entry.amountTotal}`;
}
if (entry.hasOwnProperty("id")) { case "intro":
b = ["", ""];
span = ["<b>", "</b>"];
// Different text and images for each entry in the "Game Status" section
switch (entry.id) { switch (entry.id) {
case "gameCompletion":
case "geoRocks": textSuffix = `${entry.spoiler} %`;
case "itemsDiscovered":
textPrefix += `: ${entry.notActivated} | ${entry.activated} | ${entry.discoveredTotal}`;
break; break;
case "zoteStatus": case "health":
case "nailsmithStatus": div = divFlex;
if (entry.hasOwnProperty("currentName") && entry.hasOwnProperty("currentSpoiler")) { span = ["", ""];
textPrefix = entry[entry.currentName];
textSuffix = entry[entry.currentSpoiler]; (entry.permadeathMode) ? Img = maskSteel: Img = maskNormal;
for (let i = 0, total = entry.amountTotal; i < total; i++) {
textSuffix += Img;
} }
textSuffix += `${p}<sup>(${entry.amountTotal})</sup>`;
p = "";
break;
case "soul":
div = divFlex;
span = ["", ""];
Img = soulNormal;
for (let i = 0, total = Math.round(entry.amountTotal / 33); i < total; i++) {
textSuffix += Img;
}
textSuffix += `${p}<sup>(${Math.round(entry.amountTotal / 33)})</sup>`;
p = "";
break;
case "notches":
div = divFlex;
span = ["", ""];
// First, check filled (used) notches and fill them (skips if no filled notches)
if (entry.amountFilled > 0) {
for (let i = 0, total = entry.amountFilled; i < total; i++) {
textSuffix += notchFilledImage;
}
}
// Second, check overcharmed notches and fill them (skips if player is not overcharmed)
if (entry.amountOvercharmed > 0) {
for (let i = 0, total = entry.amountOvercharmed; i < total; i++) {
textSuffix += notchOvercharmedImage;
}
}
// Last, fill all unused notches
if (entry.amountUnused > 0) {
for (let i = 0, total = entry.amountUnused; i < total; i++) {
textSuffix += notchNormalImage;
}
}
textSuffix += `${p}<sup>(${entry.amountTotal})</sup>`;
break;
case "geo":
div = divFlex;
span = ["", ""];
textSuffix += `${geoNormalImage}<b>${entry.amount}</b>`;
// Show Shade Geo value and image only if Shade has at least 1 Geo on it
if (entry.amountShade > 0) textSuffix += `${p}+${geoShadeImage}<b>${entry.amountShade}</b>`;
// Show also total Geo (Geo + Shade Geo) if player has at least 1 geo alongside the shade geo
if (entry.amount > 0 && entry.amountShade > 0) textSuffix += `${p}=${p}<b>${entry.amountTotal}</b>`;
p = "";
break; break;
default: default:
} }
}
if (entry.hasOwnProperty("disabled")) { // Optimized only for the "intro" section!
if (entry.disabled === true) { if (entry.hasOwnProperty("spoilerAfter")) {
textPrefix = `<del>${textPrefix}</del>`; spoilerAfter = `</b> ${entry.spoilerAfter}`;
span[1] = "";
} }
} break;
if (textSuffix.length && textPrefix.length) textSuffix = `${textSuffix}`; case "hints":
if (textPrefix.includes("<del>")) textSuffix = `<del>${textSuffix}</del>`; b = ["", ""];
} span = ["<span>", "</span>"];
icon = iconNull;
break;
*/ default:
span = ["<span class='spoiler-span'>", "</span>"];
spoiler = ["<span class='spoiler-text'>", "</span>"];
if (entry.hasOwnProperty("amount")) {
if (entry.hasOwnProperty("disabled")) {
if (entry.disabled !== true) {
textPrefix += `: ${entry.amount}`;
}
} else {
textPrefix += `: ${entry.amount}`;
}
}
if (entry.hasOwnProperty("amountTotal")) {
textPrefix += ` / ${entry.amountTotal}`;
}
if (entry.hasOwnProperty("id")) {
switch (entry.id) {
case "geoRocks":
case "itemsDiscovered":
textPrefix += `: ${entry.notActivated} | ${entry.activated} | ${entry.discoveredTotal}`;
break;
case "zoteStatus":
case "nailsmithStatus":
if (entry.hasOwnProperty("currentName") && entry.hasOwnProperty("currentSpoiler")) {
textPrefix = entry[entry.currentName];
textSuffix = entry[entry.currentSpoiler];
}
break;
default:
}
}
if (entry.hasOwnProperty("disabled")) {
if (entry.disabled === true) {
textPrefix = `<del>${textPrefix}</del>`;
}
}
if (textSuffix.length && textPrefix.length) textSuffix = `${textSuffix}`;
if (textPrefix.includes("<del>")) textSuffix = `<del>${textSuffix}</del>`;
}
*/
/* return [ /* return [
div, div,
icon, icon,
@ -819,13 +819,13 @@ function SingleEntryFill(obj) {
return [ return [
obj.div, obj.div,
obj.icon, obj.icon,
`${obj.b[0]}${obj.textPrefix}${obj.b[1]}`, `${obj.b[0]}${obj.textPrefix}${obj.b[1]}`,
obj.span[0], obj.span[0],
obj.p, obj.p,
obj.spoiler[0], obj.spoiler[0],
`${obj.textSuffix}${obj.spoilerAfter}`, `${obj.textSuffix}${obj.spoilerAfter}`,
obj.spoiler[1], obj.spoiler[1],
obj.span[1], obj.span[1],
"</div>\n" "</div>\n"
].join(""); ].join("");
@ -1016,7 +1016,7 @@ function StorageAvailable(type) {
* @param {string} elementId Element ID to update * @param {string} elementId Element ID to update
* @param {string} textFill Updated contents (innerHTML) * @param {string} textFill Updated contents (innerHTML)
*/ */
function FillInnerHTML(elementId, textFill) { function FillInnerHTML(elementId, textFill) {
const element = document.getElementById(elementId); const element = document.getElementById(elementId);
element.innerHTML = textFill; element.innerHTML = textFill;
@ -1028,7 +1028,7 @@ function StorageAvailable(type) {
* @param {string} tooltipId Element ID of the tooltip to update * @param {string} tooltipId Element ID of the tooltip to update
* @param {string} tooltipFill Updated contents of the tooltip * @param {string} tooltipFill Updated contents of the tooltip
*/ */
function SelectCopyInputText(mouseEvent, tooltipId = "", tooltipFill = "") { function SelectCopyInputText(mouseEvent, tooltipId = "", tooltipFill = "") {
const element = document.getElementById(mouseEvent.target.id); const element = document.getElementById(mouseEvent.target.id);