Fix bugs, mostly related to updating TMT

This commit is contained in:
thepaperpilot 2021-05-12 23:04:59 -05:00
parent 3aa539dc6b
commit 9c84543099
12 changed files with 58 additions and 64 deletions

View file

@ -90,7 +90,10 @@ function getInstrumentBuyable(id, instrumentName, title, baseSpeed, baseCost, co
return speed;
},
canAfford() {
return player.distill.points.gte(this.cost()) && getBuyableAmount("distill", id).lt(100);
return player.distill.points.gte(this.cost());
},
purchaseLimit() {
return new Decimal(100);
},
buy() {
player.distill.points = player.distill.points.sub(this.cost());
@ -160,9 +163,9 @@ addLayer("distill", {
};
},
shouldNotify() {
return Object.values(tmp[this.layer].buyables).some(buyable => buyable.unlocked && buyable.canAfford);
return Object.keys(tmp[this.layer].buyables).some(buyable => canBuyBuyable(this.layer, id));
},
tabFormat: () => player.tab !== "distill" ? null : [
tabFormat: () => [
"main-display",
["display-text", `You are getting ${format(getEssentiaMult())} essentia every time an instrument finishes.`],
"blank",

View file

@ -62,7 +62,7 @@ addLayer("flowers", {
passiveGeneration: new Decimal(1),
tabFormat: {
"Main": {
content: () => player.tab !== "flowers" ? null :[
content: () => [
"main-display",
["display-text", `You are collecting <span style="color: ${flowersColor}; text-shadow: ${flowersColor} 0 0 10px">${format(tmp.flowers.getResetGain)}</span> flowers per second`],
"blank",
@ -120,7 +120,7 @@ addLayer("flowers", {
shouldNotify: () => Object.values(tmp.flowers.buyables).some(buyable => buyable.unlocked && buyable.canAfford) || Object.values(tmp.flowers.upgrades).some(upgrade => upgrade.unlocked && upgrade.canAfford)
},
"Candypop": {
content: () => player.tab !== "flowers" ? null : [
content: () => [
["sticky", [0, ["column", [
["display-text", "Choose input job:"],
["row", [
@ -283,7 +283,7 @@ addLayer("flowers", {
},
11: {
title: "A chain of beautiful flowers<br>",
description: "Increase collection speed based on how many flowers you have<br>",
description: "Increase collection speed based on how many flowers you have",
cost: new Decimal(10),
effect: () => player.flowers.points.clampMin(1).pow(0.1).add(1),
unlocked: () => hasMilestone("flowers", 0),

View file

@ -144,7 +144,7 @@ addLayer("generators", {
passiveGeneration: new Decimal(1),
tabFormat: {
"Main": {
content: () => player.tab !== "generators" ? null : [
content: () => [
"main-display",
["display-text", `You are collecting <span style="color: ${electricColor}; text-shadow: ${electricColor} 0 0 10px">${format(tmp.generators.getResetGain)}</span> joules per second`],
"blank",
@ -179,7 +179,7 @@ addLayer("generators", {
shouldNotify: () => [11, 12, 13].map(id => tmp.generators.buyables[id]).some(buyable => buyable.unlocked && buyable.canAfford)
},
"Batteries": {
content: () => player.tab !== "generators" ? null : [
content: () => [
"main-display",
["display-text", "Each battery effects a job's output.<br/>Every power of 10 joules increases that job's gain by 1x.<br/>Batteries slowly lose charge over time.<br/>"],
"blank",

View file

@ -223,7 +223,7 @@ addLayer("rituals", {
},
tabFormat: {
"Main": {
content: () => player.tab !== "rituals" ? [] : [
content: () => [
["sticky", [0, ["row", [["bar", "job"], ["display-text", `<span style="margin-left: 20px;">Lv. ${getJobLevel("rituals")}</span>`]]]]],
"blank",
["display-text", (() => {
@ -258,7 +258,7 @@ addLayer("rituals", {
shouldNotify: () => Object.values(tmp.rituals.buyables).some(buyable => buyable.unlocked && buyable.canAfford)
},
"Ritual Book": {
content: () => player.tab !== "rituals" ? [] : [
content: () => [
["sticky", [0, ["row", [["bar", "job"], ["display-text", `<span style="margin-left: 20px;">Lv. ${getJobLevel("rituals")}</span>`]]]]],
"blank",
["display-text", "Form rituals in the grid to gain powerful effects. You can have multiples of each ritual, and runes can be a part of multiple, overlapping rituals.<br/><br/>For any ritual, replace the tiles with any rune, but each tile with the same number must have the same rune.<br/>Blank tiles can have anything in them."],

View file

@ -148,7 +148,7 @@ addLayer("sands", {
"Main": {
content: () => {
new Decimal(1).sub(player.sands.shrunkAmount.div(nextStoneCost())).times(10000);
return player.tab !== "sands" ? null : [
return [
"main-display",
"blank",
["display-text", (() => {
@ -194,7 +194,7 @@ addLayer("sands", {
}
},
"Upgrades": {
content: () => player.tab !== "sands" ? null : [
content: () => [
"main-display",
"blank",
["display-text", (() => {
@ -236,7 +236,7 @@ addLayer("sands", {
shouldNotify: () => Object.values(tmp.sands.upgrades).some(upgrade => upgrade.unlocked && upgrade.canAfford) || Object.values(tmp.sands.buyables).some(buyable => buyable.id !== "glass" && buyable.unlocked && buyable.canAfford)
},
"Glass": {
content: () => player.tab !== "sands" ? null : [
content: () => [
"main-display",
"blank",
["buyable", "glass"],

View file

@ -81,7 +81,7 @@ const getShop = (numCards = 3) => {
Vue.component("card", {
props: ["layer", "data"], // data is object with card, id, className, onclick, overrideLevel, width, height, and note
template: `<div class="upgCol">
template: `<div class="upgCol" v-if="data.card">
<div :id="data.id" class="card" :class="{ [data.className]: true }" :style="{ width: data.width || '200px', height: data.height || '300px' }" v-on:click="onclick">
<span style="border-bottom: 1px solid white; margin: 0; max-height: calc(50% - 30px); padding-bottom: 10px;">
<h3 v-html="title"></h3>
@ -278,9 +278,6 @@ addLayer("study", {
tabFormat: {
"Main": {
content: () => {
if (player.tab !== "study") {
return null;
}
const drawDuration = getDrawDuration();
return [
["sticky", [0, ["row", [["bar", "job"], ["display-text", `<span style="margin-left: 20px;">Lv. ${getJobLevel("study")}</span>`]]]]],
@ -315,7 +312,7 @@ addLayer("study", {
}
},
"Deck": {
content: () => player.tab !== "study" ? null : [
content: () => [
["sticky", [0, ["row", [["bar", "job"], ["display-text", `<span style="margin-left: 20px;">Lv. ${getJobLevel("study")}</span>`]]]]],
"blank",
["clickable", "reset"],
@ -324,7 +321,7 @@ addLayer("study", {
]
},
"Buy Cards": {
content: () => player.tab !== "study" ? null : [
content: () => [
["sticky", [0, ["row", [["bar", "job"], ["display-text", `<span style="margin-left: 20px;">Lv. ${getJobLevel("study")}</span>`]]]]],
"blank",
["sticky", ["36px", ["display-text", `<span>You have <h2 style="color: darkcyan; text-shadow: darkcyan 0 0 10px">${formatWhole(player.study.insights)}</h2> key insights</span>`]]],
@ -354,7 +351,7 @@ addLayer("study", {
unlocked: () => hasMilestone("study", 0)
},
"Destroy Cards": {
content: () => player.tab !== "study" ? null : [
content: () => [
["sticky", [0, ["row", [["bar", "job"], ["display-text", `<span style="margin-left: 20px;">Lv. ${getJobLevel("study")}</span>`]]]]],
"blank",
["sticky", ["36px", ["display-text", `<span>You have <h2 style="color: ${studyColor}; text-shadow: ${studyColor} 0 0 10px">${formatWhole(player.study.points)}</h2> properties studied`]]],
@ -366,7 +363,7 @@ addLayer("study", {
unlocked: () => hasMilestone("study", 1)
},
"Upgrade Cards": {
content: () => player.tab !== "study" ? null : [
content: () => [
["sticky", [0, ["row", [["bar", "job"], ["display-text", `<span style="margin-left: 20px;">Lv. ${getJobLevel("study")}</span>`]]]]],
"blank",
["sticky", ["36px", ["display-text", `<span>You have <h2 style="color: darkcyan; text-shadow: darkcyan 0 0 10px">${formatWhole(player.study.insights)}</h2> key insights`]]],

View file

@ -209,7 +209,7 @@ function loadVue() {
</span>
<span v-html="tmp[layer].upgrades[data].description"></span>
<span v-if="tmp[layer].upgrades[data].effectDisplay"><br>Currently: <span
v-html="tmp[layer].upgrades[data].effectDisplay"></span></span>
v-html="run(tmp[layer].upgrades[data].effectDisplay, layers[layer].upgrades[data])"></span></span>
<span v-if="tmp[layer].upgrades[data].cost"><br><br>Cost:
{{ formatWhole(tmp[layer].upgrades[data].cost) }}
{{ (tmp[layer].upgrades[data].currencyDisplayName ? tmp[layer].upgrades[data].currencyDisplayName : tmp[layer].resource) }}</span>
@ -417,7 +417,7 @@ function loadVue() {
<!--suppress HtmlUnknownTag -->
<h2 v-html="tmp[layer].clickables[data].title"></h2><br>
</span>
<span v-bind:style="{'white-space': 'pre-line'}" v-html="tmp[layer].clickables[data].display"></span>
<span v-bind:style="{'white-space': 'pre-line'}" v-html="run(layers[layer].clickables[data].display, layers[layer].clickables[data])"></span>
</button>
`,
data() {
@ -469,13 +469,13 @@ function loadVue() {
Vue.component('gridable', {
props: ['layer', 'data'],
template: `
<button
v-if="tmp[layer].grid && player[layer].grid[data]!== undefined && run(layers[layer].grid.getUnlocked, layers[layer].grid, data)"
<button
v-if="tmp[layer].grid && player[layer].grid[data]!== undefined && run(layers[layer].grid.getUnlocked, layers[layer].grid, data)"
v-bind:class="{ tile: true, can: canClick, locked: !canClick}"
v-bind:style="[canClick ? {'background-color': tmp[layer].color} : {}, gridRun(layer, 'getStyle', player[this.layer].grid[this.data], this.data)]"
v-on:click="clickGrid(layer, data)" @mousedown="start" @mouseleave="stop" @mouseup="stop" @touchstart="start" @touchend="stop" @touchcancel="stop">
<span v-if= "layers[layer].grid.getTitle"><h3 v-html="gridRun(this.layer, 'getTitle', player[this.layer].grid[this.data], this.data)"></h3><br></span>
<span v-bind:style="{'white-space': 'pre-line'}" v-html="gridRun(this.layer, 'getDisplay', player[this.layer].grid[this.data], this.data)"></span>
<span v-bind:style="{'white-space': 'pre-line'}" v-html="gridRun(this.layer, 'getDisplay', player[this.layer].grid[this.data], this.data)"></span>
</button>
`,
data() { return { interval: false, time: 0,}},
@ -488,7 +488,7 @@ function loadVue() {
if (!this.interval && layers[this.layer].grid.onHold) {
this.interval = setInterval((function() {
if(this.time >= 5 && gridRun(this.layer, 'getCanClick', player[this.layer].grid[this.data], this.data)) {
gridRun(this.layer, 'onHold', player[this.layer].grid[this.data], this.data) }
gridRun(this.layer, 'onHold', player[this.layer].grid[this.data], this.data) }
this.time = this.time+1
}).bind(this), 50)}
},
@ -534,14 +534,14 @@ function loadVue() {
<div v-if="tmp[layer].bars && tmp[layer].bars[data].unlocked !== false"
v-bind:style="{'position': 'relative'}">
<div
v-bind:style="[tmp[layer].bars[data].style, tmp[layer].bars[data].dims, {'display': 'table', 'borderRadius': '10px', 'boxShadow': '0 0 10px 2px var(--shadowColor), inset 0 0 10px 4px var(--innerShadowColor)'}]">
v-bind:style="[tmp[layer].bars[data].style, style.dims, {'display': 'table', 'borderRadius': '10px', 'boxShadow': '0 0 10px 2px var(--shadowColor), inset 0 0 10px 4px var(--innerShadowColor)'}]">
<div class="overlayTextContainer barBorder"
v-bind:style="[tmp[layer].bars[data].borderStyle, style.dims]">
<span class="overlayText" v-bind:style="[tmp[layer].bars[data].style, tmp[layer].bars[data].textStyle]"
v-html="run(layers[layer].bars[data].display, layers[layer].bars[data])"></span>
</div>
<div class="barBG barBorder"
v-bind:style="[tmp[layer].bars[data].style, tmp[layer].bars[data].baseStyle, tmp[layer].bars[data].borderStyle, tmp[layer].bars[data].dims]">
v-bind:style="[tmp[layer].bars[data].style, tmp[layer].bars[data].baseStyle, tmp[layer].bars[data].borderStyle, style.dims]">
<div class="fill"
v-bind:style="[tmp[layer].bars[data].style, tmp[layer].bars[data].fillStyle, style.fillDims]"></div>
</div>

View file

@ -18,14 +18,14 @@ function getResetGain(layer, useType = null) {
}
}
if (tmp[layer].type === "none") {
return new decimalZero;
return decimalZero;
}
if (tmp[layer].gainExp.eq(0)) {
return new decimalZero;
return decimalZero;
}
if (type === "static") {
if ((!tmp[layer].canBuyMax) || tmp[layer].baseAmount.lt(tmp[layer].requires)) {
return new Decimal(1);
return decimalOne;
}
let gain = tmp[layer].baseAmount.div(tmp[layer].requires).div(tmp[layer].gainMult).max(1).log(tmp[layer].base).times(tmp[layer].gainExp).pow(Decimal.pow(tmp[layer].exponent, -1));
gain = gain.times(tmp[layer].directMult);

View file

@ -46,7 +46,7 @@ function updateLayers(){
for (let row in OTHER_LAYERS) {
OTHER_LAYERS[row].sort((a, b) => (a.position > b.position) ? 1 : -1)
for (let layer in OTHER_LAYERS[row])
OTHER_LAYERS[row][layer] = OTHER_LAYERS[row][layer].layer
OTHER_LAYERS[row][layer] = OTHER_LAYERS[row][layer].layer
}
for (let row in TREE_LAYERS) {
TREE_LAYERS[row].sort((a, b) => (a.position > b.position) ? 1 : -1)
@ -66,7 +66,7 @@ function setupLayer(layer){
if (layers[layer].upgrades){
setRowCol(layers[layer].upgrades)
for (thing in layers[layer].upgrades){
if (!isNaN(thing)){
if (typeof layers[layer].upgrades[thing] === "object"){
layers[layer].upgrades[thing].id = thing
layers[layer].upgrades[thing].layer = layer
if (layers[layer].upgrades[thing].unlocked === undefined)
@ -76,7 +76,7 @@ function setupLayer(layer){
}
if (layers[layer].milestones){
for (let thing in layers[layer].milestones){
if (!isNaN(thing)){
if (typeof layers[layer].milestones[thing] === "object"){
layers[layer].milestones[thing].id = thing
layers[layer].milestones[thing].layer = layer
if (layers[layer].milestones[thing].unlocked === undefined)
@ -87,7 +87,7 @@ function setupLayer(layer){
if (layers[layer].achievements){
setRowCol(layers[layer].achievements)
for (thing in layers[layer].achievements){
if (!isNaN(thing)){
if (typeof layers[layer].achievements[thing] === "object"){
layers[layer].achievements[thing].id = thing
layers[layer].achievements[thing].layer = layer
if (layers[layer].achievements[thing].unlocked === undefined)
@ -98,7 +98,7 @@ function setupLayer(layer){
if (layers[layer].challenges){
setRowCol(layers[layer].challenges)
for (thing in layers[layer].challenges){
if (!isNaN(thing)){
if (typeof layers[layer].challenges[thing] === "object"){
layers[layer].challenges[thing].id = thing
layers[layer].challenges[thing].layer = layer
if (layers[layer].challenges[thing].unlocked === undefined)
@ -113,30 +113,29 @@ function setupLayer(layer){
layers[layer].buyables.layer = layer
setRowCol(layers[layer].buyables)
for (thing in layers[layer].buyables){
if (!isNaN(thing)){
if (typeof layers[layer].buyables[thing] === "object"){
layers[layer].buyables[thing].id = thing
layers[layer].buyables[thing].layer = layer
if (layers[layer].buyables[thing].unlocked === undefined)
if (layers[layer].buyables[thing].unlocked === undefined) {
layers[layer].buyables[thing].unlocked = true
}
layers[layer].buyables[thing].canBuy = function() {return canBuyBuyable(this.layer, this.id)}
if (layers[layer].buyables[thing].purchaseLimit === undefined) layers[layer].buyables[thing].purchaseLimit = new Decimal(Infinity)
}
}
}
}
if (layers[layer].clickables){
layers[layer].clickables.layer = layer
setRowCol(layers[layer].clickables)
for (thing in layers[layer].clickables){
if (!isNaN(thing)){
if (typeof layers[layer].clickables[thing] === "object"){
layers[layer].clickables[thing].id = thing
layers[layer].clickables[thing].layer = layer
if (layers[layer].clickables[thing].unlocked === undefined)
layers[layer].clickables[thing].unlocked = true
}
}
}
}
if (layers[layer].bars){
@ -146,7 +145,7 @@ function setupLayer(layer){
layers[layer].bars[thing].layer = layer
if (layers[layer].bars[thing].unlocked === undefined)
layers[layer].bars[thing].unlocked = true
}
}
}
if (layers[layer].infoboxes){
@ -155,9 +154,9 @@ function setupLayer(layer){
layers[layer].infoboxes[thing].layer = layer
if (layers[layer].infoboxes[thing].unlocked === undefined)
layers[layer].infoboxes[thing].unlocked = true
}
}
}
if (layers[layer].grid) {
layers[layer].grid.layer = layer
if (layers[layer].grid.getUnlocked === undefined)
@ -198,12 +197,12 @@ function setupLayer(layer){
ROW_LAYERS[row][layer]=layer;
let position = (layers[layer].position !== undefined ? layers[layer].position : layer)
if (!isNaN(displayRow)) TREE_LAYERS[displayRow].push({layer: layer, position: position})
else OTHER_LAYERS[displayRow].push({layer: layer, position: position})
if (maxRow < layers[layer].displayRow) maxRow = layers[layer].displayRow
}
@ -223,10 +222,10 @@ function addLayer(layerName, layerData, tabLayers = null){ // Call this to add l
let style = tmp[this.embedLayer].nodeStyle
if (style['border-color'] === undefined) style['border-color'] = tmp[this.embedLayer].color
return style
}
}
},
unlocked() {return tmp[this.embedLayer].layerShown},
}
}
}
layers[layerName].tabFormat = format
}

View file

@ -121,10 +121,6 @@ const systemComponents = {
<br>Offline Time: {{formatTime(player.offTime.remain)}}<br>
</span>
<br>
<span v-if="player.points.lt('1e1000')" class="overlayThing">You have </span>
<h2 class="overlayThing" id="points">{{format(player.points)}}</h2>
<span v-if="player.points.lt('1e1e6')" class="overlayThing"> {{modInfo.pointsName}}</span>
<br>
<span v-if="canGenPoints()" class="overlayThing">({{tmp.other.oompsMag != 0 ? format(tmp.other.oomps) + " OOM" + (tmp.other.oompsMag < 0 ? "^OOM" : tmp.other.oompsMag > 1 ? "^" + tmp.other.oompsMag : "") + "s" : formatSmall(getPointGen())}}/sec)</span>
<div v-for="thing in tmp.displayThings" class="overlayThing"><span v-if="thing" v-html="thing"></span></div>
</div>
@ -181,7 +177,6 @@ const systemComponents = {
</tr>
<tr>
<td><button class="opt" onclick="adjustMSDisp()">Show Milestones: {{ MS_DISPLAYS[MS_SETTINGS.indexOf(player.msDisplay)]}}</button></td>
<td><button class="opt" onclick="toggleOpt('hqTree')">High-Quality Tree: {{ player.hqTree?"ON":"OFF" }}</button></td>
<td><button class="opt" onclick="toggleOpt('forceOneTab'); needsCanvasUpdate = true">Single-Tab Mode: {{ player.forceOneTab?"ALWAYS":"AUTO" }}</button></td>
</tr>
</table>`

View file

@ -29,7 +29,7 @@ function setupTemp() {
tmp.displayThings = []
tmp.scrolled = 0
funcs = {}
setupTempData(layers, tmp, funcs)
for (let layer in layers){
tmp[layer].resetGain = {}
@ -82,7 +82,7 @@ function setupTempData(layerData, tmpData, funcsData) {
tmpData[item] = layerData[item]
}
}
}
}
}
function updateTemp() {
@ -106,12 +106,12 @@ function updateTemp() {
for (let thing in displayThings){
let text = displayThings[thing]
if (isFunction(text)) text = text()
tmp.displayThings.push(text)
tmp.displayThings.push(text)
}
}
function updateTempData(layerData, tmpData, funcsData) {
for (let item in funcsData){
if (Array.isArray(layerData[item])) {
if (item === "tabFormat" || item === "content") return // These are only updated when needed
@ -135,7 +135,7 @@ function updateTempData(layerData, tmpData, funcsData) {
}
Vue.set(tmpData, item, value)
}
}
}
}
function updateChallengeTemp(layer)

View file

@ -301,7 +301,7 @@ function layOver(obj1, obj2) {
function prestigeNotify(layer) {
if (layers[layer].prestigeNotify) return layers[layer].prestigeNotify()
if (isPlainObject(tmp[layer].tabFormat)) {
for (subtab in tmp[layer].tabFormat){
if (subtabResetNotify(layer, 'mainTabs', subtab))
@ -537,7 +537,7 @@ function adjustPopupTime(diff) {
}
function run(func, target, args = null) {
if (ifFunction(func)) {
if (isFunction(func)) {
let bound = func.bind(target);
return bound(args);
} else {