From a8a5a2f46addb62ea05c00b989f4b0062a7abebb Mon Sep 17 00:00:00 2001 From: Harley White Date: Sun, 2 May 2021 22:39:38 -0400 Subject: [PATCH] Optimized more things out of temp --- js/Demo/demoLayers.js | 2 +- js/components.js | 30 ++++++++++++-------- js/technical/displays.js | 48 ++++++++++++++++++++++++++++++++ js/technical/systemComponents.js | 2 +- js/technical/temp.js | 46 ++---------------------------- js/utils.js | 13 --------- 6 files changed, 70 insertions(+), 71 deletions(-) diff --git a/js/Demo/demoLayers.js b/js/Demo/demoLayers.js index 8787a49..0758451 100644 --- a/js/Demo/demoLayers.js +++ b/js/Demo/demoLayers.js @@ -406,7 +406,7 @@ addLayer("f", { // The following are only currently used for "custom" Prestige type: prestigeButtonText() { //Is secretly HTML if (!this.canBuyMax()) return "Hi! I'm a weird dinosaur and I'll give you a Farm Point in exchange for all of your points and lollipops! (At least " + formatWhole(tmp[this.layer].nextAt) + " points)" - if (this.canBuyMax()) return "Hi! I'm a weird dinosaur and I'll give you " + formatWhole(tmp[this.layer].resetGain) + " Farm Points in exchange for all of your points and lollipops! (You'll get another one at " + formatWhole(tmp[layer].nextAtDisp) + " points)" + if (this.canBuyMax()) return "Hi! I'm a weird dinosaur and I'll give you " + formatWhole(tmp[this.layer].resetGain) + " Farm Points in exchange for all of your points and lollipops! (You'll get another one at " + formatWhole(tmp[this.layer].nextAtDisp) + " points)" }, getResetGain() { return getResetGain(this.layer, useType = "static") diff --git a/js/components.js b/js/components.js index b5985b9..b4be823 100644 --- a/js/components.js +++ b/js/components.js @@ -125,15 +125,16 @@ function loadVue() { Vue.component('challenge', { props: ['layer', 'data'], template: ` -
+



-

- +

+
Goal: {{format(tmp[layer].challenges[data].goal)}} {{tmp[layer].challenges[data].currencyDisplayName ? tmp[layer].challenges[data].currencyDisplayName : "points"}}
Reward:
- Currently: + Currently:
` @@ -159,11 +160,11 @@ function loadVue() { template: ` @@ -190,7 +191,7 @@ function loadVue() { template: `


-
+
  ` }) @@ -218,7 +219,7 @@ function loadVue() { Vue.component('main-display', { props: ['layer'], template: ` -
You have

{{formatWhole(player[layer].points)}}

{{tmp[layer].resource}},

+
You have

{{formatWhole(player[layer].points)}}

{{tmp[layer].resource}},

` }) @@ -261,7 +262,7 @@ function loadVue() { v-bind:style="[tmp[layer].buyables[data].canBuy ? {'background-color': tmp[layer].color} : {}, size ? {'height': size, 'width': size} : {}, tmp[layer].componentStyles.buyable, tmp[layer].buyables[data].style]" v-on:click="buyBuyable(layer, data)">


- +
@@ -306,7 +307,7 @@ function loadVue() { v-bind:style="[tmp[layer].clickables[data].canClick ? {'background-color': tmp[layer].color} : {}, size ? {'height': size, 'width': size} : {}, tmp[layer].clickables[data].style]" v-on:click="clickClickable(layer, data)">


- + ` }) @@ -341,10 +342,13 @@ function loadVue() { // data = id of the bar Vue.component('bar', { props: ['layer', 'data'], + computed: { + style() {return constructBarStyle(layer, data)} + }, template: `
- +
@@ -373,7 +377,7 @@ function loadVue() { props: ['layer', 'data'], template: `
+ v-bind:style="achievementStyle(layer, data)"> ${formatWhole(tmp[layer].resetGain)} ${tmp[layer].resource} ${tmp[layer].resetGain.lt(100) && player[layer].points.lt(1e3) ? `

Next at ${(tmp[layer].roundUpCost ? formatWhole(tmp[layer].nextAt) : format(tmp[layer].nextAt))} ${tmp[layer].baseResource}` : ""}` + if (tmp[layer].type == "static") + return `${tmp[layer].resetDescription !== undefined ? tmp[layer].resetDescription : "Reset for "}+${formatWhole(tmp[layer].resetGain)} ${tmp[layer].resource}

${player[layer].points.lt(30) ? (tmp[layer].baseAmount.gte(tmp[layer].nextAt) && (tmp[layer].canBuyMax !== undefined) && tmp[layer].canBuyMax ? "Next:" : "Req:") : ""} ${formatWhole(tmp[layer].baseAmount)} / ${(tmp[layer].roundUpCost ? formatWhole(tmp[layer].nextAtDisp) : format(tmp[layer].nextAtDisp))} ${tmp[layer].baseResource} + ` + if (tmp[layer].type == "none") + return "" + + return "You need prestige button text" +} + +function constructNodeStyle(layer){ + let style = [] + if ((tmp[layer].isLayer && layerunlocked(layer)) || (!tmp[layer].isLayer && tmp[layer].canClick)) + style.push({'background-color': tmp[layer].color}) + if (tmp[layer].image !== undefined) + style.push({'background-image': 'url("' + tmp[layer].image + '")'}) + style.push(tmp[layer].nodeStyle) + return style +} + + +function challengeStyle(layer, id) { + if (player[layer].activeChallenge == id && canCompleteChallenge(layer, id)) return "canComplete" + else if (hasChallenge(layer, id)) return "done" + return "locked" +} + +function challengeButtonText(layer, id) { + return (player[layer].activeChallenge==(id)?(canCompleteChallenge(layer, id)?"Finish":"Exit Early"):(hasChallenge(layer, id)?"Completed":"Start")) + +} + +function achievementStyle(layer, id){ + ach = tmp[layer].achievements[id] + let style = [] + if (ach.image){ + style.push({'background-image': 'url("' + ach.image + '")'}) + } + if (!ach.unlocked) style.push({'visibility': 'hidden'}) + style.push(ach.style) + return style +} + + diff --git a/js/technical/systemComponents.js b/js/technical/systemComponents.js index fe5042d..9331fdd 100644 --- a/js/technical/systemComponents.js +++ b/js/technical/systemComponents.js @@ -37,7 +37,7 @@ var systemComponents = { resetNotify: tmp[layer].prestigeNotify, can: ((player[layer].unlocked || tmp[layer].isLayer) && tmp[layer].isLayer) || (!tmp[layer].isLayer && tmp[layer].canClick), }" - v-bind:style="tmp[layer].computedNodeStyle"> + v-bind:style="constructNodeStyle(layer)"> ${formatWhole(tmp[layer].resetGain)} ${tmp[layer].resource} ${tmp[layer].resetGain.lt(100) && player[layer].points.lt(1e3) ? `

Next at ${(tmp[layer].roundUpCost ? formatWhole(tmp[layer].nextAt) : format(tmp[layer].nextAt))} ${tmp[layer].baseResource}` : ""}` - else if (tmp[layer].type == "static") - return `${tmp[layer].resetDescription !== undefined ? tmp[layer].resetDescription : "Reset for "}+${formatWhole(tmp[layer].resetGain)} ${tmp[layer].resource}

${player[layer].points.lt(30) ? (tmp[layer].baseAmount.gte(tmp[layer].nextAt) && (tmp[layer].canBuyMax !== undefined) && tmp[layer].canBuyMax ? "Next:" : "Req:") : ""} ${formatWhole(tmp[layer].baseAmount)} / ${(tmp[layer].roundUpCost ? formatWhole(tmp[layer].nextAtDisp) : format(tmp[layer].nextAtDisp))} ${tmp[layer].baseResource} - ` - else if (tmp[layer].type == "none") - return "" - else - return "You need prestige button text" -} function isFunction(obj) { return !!(obj && obj.constructor && obj.call && obj.apply);