CountGeoRocks()
This commit is contained in:
parent
0184473538
commit
8a9dac6639
4 changed files with 42 additions and 8 deletions
File diff suppressed because one or more lines are too long
|
|
@ -58,12 +58,14 @@ function HKCheckCompletion(jsonObject) {
|
||||||
|
|
||||||
let HKPlayerData;
|
let HKPlayerData;
|
||||||
let HKWorldItems;
|
let HKWorldItems;
|
||||||
|
let HKSceneData;
|
||||||
|
|
||||||
if (jsonObject.hasOwnProperty("playerData")) {
|
if (jsonObject.hasOwnProperty("playerData")) {
|
||||||
HKPlayerData = jsonObject.playerData;
|
HKPlayerData = jsonObject.playerData;
|
||||||
} else return false;
|
} else return false;
|
||||||
|
|
||||||
if (jsonObject.hasOwnProperty("sceneData")) {
|
if (jsonObject.hasOwnProperty("sceneData")) {
|
||||||
|
HKSceneData = jsonObject.sceneData;
|
||||||
if (jsonObject.sceneData.hasOwnProperty("persistentBoolItems")) {
|
if (jsonObject.sceneData.hasOwnProperty("persistentBoolItems")) {
|
||||||
HKWorldItems = jsonObject.sceneData.persistentBoolItems;
|
HKWorldItems = jsonObject.sceneData.persistentBoolItems;
|
||||||
} else return false;
|
} else return false;
|
||||||
|
|
@ -237,7 +239,7 @@ function HKCheckCompletion(jsonObject) {
|
||||||
|
|
||||||
// ------------------------- Game Statistics ----------------------------- //
|
// ------------------------- Game Statistics ----------------------------- //
|
||||||
|
|
||||||
CheckAdditionalThings(HK.DIV_ID.statistics, HK.STATISTICS, HKPlayerData, HKWorldItems);
|
CheckAdditionalThings(HK.DIV_ID.statistics, HK.STATISTICS, HKPlayerData, HKWorldItems, HKSceneData);
|
||||||
|
|
||||||
// ------------------------- Hints ----------------------------- //
|
// ------------------------- Hints ----------------------------- //
|
||||||
|
|
||||||
|
|
@ -654,7 +656,7 @@ function CheckWorldDataTrue(divId, idText, dataObject, worldData) {
|
||||||
* @param {object} playerData Reference/pointer to specific data where to search
|
* @param {object} playerData Reference/pointer to specific data where to search
|
||||||
* @param {object} worldData Reference/pointer to specific data where to search
|
* @param {object} worldData Reference/pointer to specific data where to search
|
||||||
*/
|
*/
|
||||||
function CheckAdditionalThings(divId, dataObject, playerData, worldData) {
|
function CheckAdditionalThings(divId, dataObject, playerData, worldData, sceneData) {
|
||||||
|
|
||||||
let textPrefix = "";
|
let textPrefix = "";
|
||||||
let textSuffix = "";
|
let textSuffix = "";
|
||||||
|
|
@ -704,13 +706,35 @@ function CheckAdditionalThings(divId, dataObject, playerData, worldData) {
|
||||||
return totalMaps;
|
return totalMaps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function CountGeoRocks(geoRocksArray, arrayLength, mode = "unbroken") {
|
||||||
|
|
||||||
|
let countTotal = 0;
|
||||||
|
|
||||||
|
if (mode === "unbroken") {
|
||||||
|
for (let i = 0; i < arrayLength; i++) {
|
||||||
|
if (geoRocksArray[i].hitsLeft > 0) countTotal++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (let i = 0; i < arrayLength; i++) {
|
||||||
|
if (geoRocksArray[i].hitsLeft === 0) countTotal++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return countTotal;
|
||||||
|
}
|
||||||
|
|
||||||
for (let i in dataObject) {
|
for (let i in dataObject) {
|
||||||
textPrefix = dataObject[i][0];
|
textPrefix = dataObject[i][0];
|
||||||
(dataObject[i][1]) ? textSuffix = dataObject[i][1]: textSuffix = "";
|
(dataObject[i][1]) ? textSuffix = dataObject[i][1]: textSuffix = "";
|
||||||
|
|
||||||
let amount = 0;
|
let {
|
||||||
let countTotal = 0;
|
amount,
|
||||||
let total = 0;
|
countTotal,
|
||||||
|
total,
|
||||||
|
unbroken,
|
||||||
|
broken,
|
||||||
|
discoveredTotal
|
||||||
|
} = 0;
|
||||||
|
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case "areaMaps":
|
case "areaMaps":
|
||||||
|
|
@ -748,6 +772,15 @@ function CheckAdditionalThings(divId, dataObject, playerData, worldData) {
|
||||||
textPrefix += ": " + Math.abs(playerData[i]);
|
textPrefix += ": " + Math.abs(playerData[i]);
|
||||||
(i === "geoPool" && playerData[i] > 0) ? CurrentDataBlank(): CurrentDataTrue();
|
(i === "geoPool" && playerData[i] > 0) ? CurrentDataBlank(): CurrentDataTrue();
|
||||||
break;
|
break;
|
||||||
|
case "geoRocks":
|
||||||
|
discoveredTotal = sceneData.geoRocks.length;
|
||||||
|
|
||||||
|
unbroken = CountGeoRocks(sceneData.geoRocks, discoveredTotal, "unbroken");
|
||||||
|
broken = CountGeoRocks(sceneData.geoRocks, discoveredTotal, "broken");
|
||||||
|
|
||||||
|
textPrefix += `: ${unbroken}/${broken}/${discoveredTotal}`;
|
||||||
|
CurrentDataTrue();
|
||||||
|
break;
|
||||||
case "shopkeeperKey":
|
case "shopkeeperKey":
|
||||||
(playerData.hasSlykey === true || playerData.gaveSlykey === true) ? CurrentDataTrue(): CurrentDataFalse();
|
(playerData.hasSlykey === true || playerData.gaveSlykey === true) ? CurrentDataTrue(): CurrentDataFalse();
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -399,6 +399,7 @@ const STATISTICS = {
|
||||||
relicsHallownestSeal: ["Relic #2 found total", "Hallownest Seal (out of 17)", 17, "trinket2", "soldTrinket2"],
|
relicsHallownestSeal: ["Relic #2 found total", "Hallownest Seal (out of 17)", 17, "trinket2", "soldTrinket2"],
|
||||||
relicsKingsIdol: ["Relic #3 found total", "King's Idol (out of 8)", 8, "trinket3", "soldTrinket3"],
|
relicsKingsIdol: ["Relic #3 found total", "King's Idol (out of 8)", 8, "trinket3", "soldTrinket3"],
|
||||||
relicsArcaneEgg: ["Relic #4 found total", "Arcane Egg (4 max, 1 missable)", 4, "trinket4", "soldTrinket4"],
|
relicsArcaneEgg: ["Relic #4 found total", "Arcane Egg (4 max, 1 missable)", 4, "trinket4", "soldTrinket4"],
|
||||||
|
geoRocks: ["Geo Rocks", "Unbroken/Broken/Discovered Total"],
|
||||||
geoPool: ["Shade Geo", "Amount of Geo the Shade is currently holding", 0], // not ghostCoins
|
geoPool: ["Shade Geo", "Amount of Geo the Shade is currently holding", 0], // not ghostCoins
|
||||||
rancidEggs: ["Rancid Eggs", "Find: Hallownest, Buy: Sly, Tuk"],
|
rancidEggs: ["Rancid Eggs", "Find: Hallownest, Buy: Sly, Tuk"],
|
||||||
xunFlowerBrokeTimes: ["Delicate Flowers broken", "Resting Grounds: Grey Mourner"],
|
xunFlowerBrokeTimes: ["Delicate Flowers broken", "Resting Grounds: Grey Mourner"],
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<script async src="https://www.googletagmanager.com/gtag/js?id=<%= ga_property_id %>"></script>
|
<script async src="https://www.googletagmanager.com/gtag/js?id=<%= ga_property_id %>"></script>
|
||||||
<script>
|
<script>
|
||||||
// Temporarily disable the tracking for testing (set to false to enable Analytics)
|
// Temporarily disable the tracking for testing (set to false to enable Analytics)
|
||||||
window['ga-disable-<%= ga_property_id %>'] = false;
|
window['ga-disable-<%= ga_property_id %>'] = true;
|
||||||
|
|
||||||
window.dataLayer = window.dataLayer || [];
|
window.dataLayer = window.dataLayer || [];
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue