CheckNailUpgrades()

This commit is contained in:
ReznoRMichael 2021-02-10 02:02:58 +01:00
parent a4c799aa72
commit 669642a7a7
2 changed files with 21 additions and 7 deletions

File diff suppressed because one or more lines are too long

View file

@ -163,12 +163,7 @@ function HKCheckCompletion(jsonObject) {
// ---------------- Nail Upgrades --------------------- //
// make it a function
for (let i = 0, length = HK.NAILUPGRADES.length; i < length; i++) {
(HKPlayerData.nailSmithUpgrades >= i) ? CurrentDataTrue(HK.DIV_ID.nailUpgrades): CurrentDataFalse();
FillHTML(HK.DIV_ID.nailUpgrades, HK.NAILUPGRADES[i][0], HK.NAILUPGRADES[i][1]);
}
if (HK.DIV_ID.nailUpgrades.percent) HK.DIV_ID.nailUpgrades.percent--; // subject one for the Old Nail
CheckNailUpgrades(HK.DIV_ID.nailUpgrades, HK.NAILUPGRADES, HKPlayerData);
// ---------------- Mask Shards --------------------- //
@ -632,6 +627,25 @@ function CheckGodmasterDoors(divId, dataObject, playerData) {
}
}
/**
* Verifies the level of player's nail upgrades, and appends HTML accordingly.
* @param {object} divId ID of the HTML element for data appending
* @param {object} dataObject Object containing nail upgrades data to be verified
* @param {object} playerData Reference/pointer to specific data where to search in the save file
*/
function CheckNailUpgrades(divId, dataObject, playerData) {
// appends "Nail" to every array element
// same as names in the database object
let nail = ["old", "sharpened", "channeled", "coiled", "pure"].map((element) => element + "Nail");
for (let i = 0; i < 5; i++) {
(playerData.nailSmithUpgrades >= i) ? CurrentDataTrue(divId): CurrentDataFalse();
FillHTML(divId, dataObject[nail[i]].name, dataObject[nail[i]].spoiler);
}
if (divId.percent) divId.percent--; // subject one for the Old Nail
}
/**
* Verifies if the data in a specific object are true or false, and appends HTML accordingly. Creates a copy of dataObject.
* @param {object} divId ID of the HTML element for data appending