diff --git a/src/components/features/Buyable.vue b/src/components/features/Buyable.vue
index ccb6d5d..3f2b68e 100644
--- a/src/components/features/Buyable.vue
+++ b/src/components/features/Buyable.vue
@@ -20,7 +20,7 @@
- Sell All
+ Sell One
diff --git a/src/components/features/Challenge.vue b/src/components/features/Challenge.vue
index dd6dcfa..758ef3e 100644
--- a/src/components/features/Challenge.vue
+++ b/src/components/features/Challenge.vue
@@ -1,8 +1,15 @@
-
+
-
+
{{ buttonText }}
@@ -32,15 +39,6 @@ export default {
shown() {
return this.challenge.unlocked && !(player.hideChallenges && this.challenge.maxes);
},
- challengeClass() {
- if (this.challenge.canComplete) {
- return "canComplete";
- }
- if (this.challenge.completed) {
- return "done";
- }
- return "locked";
- },
style() {
return [
layers[this.layer || this.tab.layer].componentStyles?.challenge,
@@ -48,8 +46,11 @@ export default {
];
},
title() {
- if (this.challenge.title) {
- return coerceComponent(this.challenge.titleDisplay, 'h3');
+ if (this.challenge.titleDisplay) {
+ return coerceComponent(this.challenge.titleDisplay, 'div');
+ }
+ if (this.challenge.name) {
+ return coerceComponent(this.challenge.name, 'h3');
}
return null;
},
@@ -82,6 +83,30 @@ export default {
diff --git a/src/components/features/DefaultChallengeDisplay.vue b/src/components/features/DefaultChallengeDisplay.vue
index e7b908b..4c8a885 100644
--- a/src/components/features/DefaultChallengeDisplay.vue
+++ b/src/components/features/DefaultChallengeDisplay.vue
@@ -32,14 +32,11 @@ export default {
return coerceComponent(`format(${this.goal}) ${this.currencyDisplayName || 'points'}`);
},
rewardDescription() {
- return coerceComponent(this.challenge.goalDescription);
+ return coerceComponent(this.challenge.rewardDescription);
},
rewardDisplay() {
if (this.challenge.rewardDisplay) {
- return coerceComponent(this.challenge.rewardDisplay);
- }
- if (this.challenge.rewardEffect) {
- return coerceComponent(`Currently: ${this.challenge.rewardEffect}`);
+ return coerceComponent(`Currently: ${this.challenge.rewardDisplay}`);
}
return null;
},
diff --git a/src/components/features/DefaultPrestigeButtonDisplay.vue b/src/components/features/DefaultPrestigeButtonDisplay.vue
index a26a344..843f104 100644
--- a/src/components/features/DefaultPrestigeButtonDisplay.vue
+++ b/src/components/features/DefaultPrestigeButtonDisplay.vue
@@ -58,7 +58,13 @@ export default {
return `${prefix} ${baseAmount} / ${nextAt} ${baseResource}`;
} else {
- return `Next at ${formatWhole(layers[this.layer || this.tab.layer].baseAmount)} ${layers[this.layer || this.tab.layer].baseResource}`;
+ let amount;
+ if (layers[this.layer || this.tab.layer].roundUpCost) {
+ amount = formatWhole(layers[this.layer || this.tab.layer].nextAt);
+ } else {
+ amount = format(layers[this.layer || this.tab.layer].nextAt);
+ }
+ return `Next at ${amount} ${layers[this.layer || this.tab.layer].baseResource}`;
}
}
return "";
diff --git a/src/components/features/Milestone.vue b/src/components/features/Milestone.vue
index b9e6fee..bc6efa3 100644
--- a/src/components/features/Milestone.vue
+++ b/src/components/features/Milestone.vue
@@ -1,5 +1,5 @@
-
+
@@ -42,7 +42,7 @@ export default {
return null;
},
optionsDisplay() {
- if (this.milestone.optionsDisplay) {
+ if (this.milestone.optionsDisplay && this.milestone.earned) {
return coerceComponent(this.milestone.optionsDisplay, 'div');
}
return null;
@@ -62,5 +62,11 @@ export default {
border-width: 4px;
border-radius: 5px;
color: rgba(0, 0, 0, 0.5);
+ margin: 0;
+}
+
+.milestone.done {
+ background-color: var(--bought);
+ cursor: default;
}
diff --git a/src/components/features/PrestigeButton.vue b/src/components/features/PrestigeButton.vue
index 5313097..819c8ed 100644
--- a/src/components/features/PrestigeButton.vue
+++ b/src/components/features/PrestigeButton.vue
@@ -10,6 +10,7 @@
import { layers } from '../../store/layers';
import { resetLayer } from '../../util/layers';
import { coerceComponent } from '../../util/vue';
+import './features.css'
export default {
name: 'prestige-button',
diff --git a/src/components/features/features.css b/src/components/features/features.css
index 052c9d9..bf89f46 100644
--- a/src/components/features/features.css
+++ b/src/components/features/features.css
@@ -1,7 +1,7 @@
.feature,
.feature button {
position: relative;
- padding-top: 5px;
+ padding: 5px;
border-radius: var(--border-radius);
border: 2px solid rgba(0, 0, 0, 0.125);
margin: var(--feature-margin);
diff --git a/src/components/fields/Slider.vue b/src/components/fields/Slider.vue
index b8b8cbe..91060e3 100644
--- a/src/components/fields/Slider.vue
+++ b/src/components/fields/Slider.vue
@@ -1,7 +1,9 @@
{{ title }}
- $emit('change', e.target.value)" :min="min" :max="max" />
+
+ $emit('change', parseInt(e.target.value))" :min="min" :max="max" />
+
@@ -9,7 +11,7 @@
import './fields.css';
export default {
- name: 'TextField',
+ name: 'Slider',
props: {
title: String,
value: Number,
@@ -20,4 +22,11 @@ export default {
diff --git a/src/components/system/LayerTab.vue b/src/components/system/LayerTab.vue
index 6ce9e1b..eac9d5c 100644
--- a/src/components/system/LayerTab.vue
+++ b/src/components/system/LayerTab.vue
@@ -13,7 +13,7 @@
-
▼
+
▼
@@ -32,7 +32,7 @@ export default {
layer: String,
index: Number,
forceFirstTab: Boolean,
- disableMinimize: Boolean,
+ minimizable: Boolean,
tab: Function
},
data() {
@@ -40,7 +40,7 @@ export default {
},
computed: {
minimized() {
- return !this.disableMinimize && player.minimized[this.layer];
+ return this.minimizable && player.minimized[this.layer];
},
name() {
return layers[this.layer].name;
@@ -91,6 +91,9 @@ export default {
},
watch: {
minimized(newValue) {
+ if (this.tab == undefined) {
+ return;
+ }
const tab = this.tab();
if (tab != undefined) {
if (newValue) {
@@ -108,6 +111,9 @@ export default {
}
},
mounted() {
+ if (this.tab == undefined) {
+ return;
+ }
const tab = this.tab();
if (tab != undefined) {
if (this.minimized) {
@@ -152,7 +158,7 @@ export default {
}
.layer-tab:not(.minimized) {
- padding-top: 50px;
+ padding-top: 20px;
padding-bottom: 20px;
min-height: 100%;
flex-grow: 1;
@@ -160,6 +166,10 @@ export default {
position: relative;
}
+.inner-tab > .layer-container > .layer-tab:not(.minimized) {
+ padding-top: 50px;
+}
+
.layer-tab.minimized {
position: absolute;
top: 0;
@@ -207,6 +217,11 @@ export default {
padding-left: 14px;
}
+.subtabs.floating {
+ justify-content: center;
+ margin-top: -25px;
+}
+
.modal-body .layer-tab {
padding-bottom: 0;
}
diff --git a/src/components/system/Microtab.vue b/src/components/system/Microtab.vue
index 701de51..d367c87 100644
--- a/src/components/system/Microtab.vue
+++ b/src/components/system/Microtab.vue
@@ -1,12 +1,21 @@
-
-
-
+
diff --git a/src/components/system/Tabs.vue b/src/components/system/Tabs.vue
index 94e206f..15c9577 100644
--- a/src/components/system/Tabs.vue
+++ b/src/components/system/Tabs.vue
@@ -7,7 +7,7 @@
-
diff --git a/src/components/tree/Tree.vue b/src/components/tree/Tree.vue
index 4e309e9..c300b17 100644
--- a/src/components/tree/Tree.vue
+++ b/src/components/tree/Tree.vue
@@ -8,7 +8,7 @@
{{ modalHeader }}
-
+
diff --git a/src/data/layers/aca/c.js b/src/data/layers/aca/c.js
index 9b6ac1d..68fd418 100644
--- a/src/data/layers/aca/c.js
+++ b/src/data/layers/aca/c.js
@@ -73,7 +73,7 @@ export default {
done() {return player[this.layer].best.gte(4)},
effectDisplay: "You can toggle beep and boop (which do nothing)",
optionsDisplay: `
-
+
player.c.beep = value" />
player.f.boop = value" />
@@ -160,21 +160,23 @@ export default {
},
buyables: {
showRespec: true,
- respec() { // Optional, reset things and give back your currency. Having this function makes a respec button appear
+ reset() { // Optional, reset things and give back your currency. Having this function makes a respec button appear
player[this.layer].points = player[this.layer].points.add(player[this.layer].spentOnBuyables) // A built-in thing to keep track of this but only keeps a single value
- this.reset;
+ this.reset();
resetLayer(this.layer, true) // Force a reset
},
respecText: "Respec Thingies", // Text on Respec button, optional
respecMessage: "Are you sure? Respeccing these doesn't accomplish much.",
11: {
title: "Exhancers", // Optional, displayed at the top in a larger font
- cost(x) { // cost for buying xth buyable, can be an object if there are multiple currencies
+ cost() { // cost for buying xth buyable, can be an object if there are multiple currencies
+ let x = this.amount;
if (x.gte(25)) x = x.pow(2).div(25)
let cost = Decimal.pow(2, x.pow(1.5))
return cost.floor()
},
- effect(x) { // Effects of owning x of the items, x is a decimal
+ effect() { // Effects of owning x of the items, x is a decimal
+ let x = this.amount;
let eff = {}
if (x.gte(0)) eff.first = Decimal.pow(25, x.pow(1.1))
else eff.first = Decimal.pow(1/25, x.times(-1).pow(1.1))
@@ -212,7 +214,6 @@ export default {
doReset(resettingLayer){ // Triggers when this layer is being reset, along with the layer doing the resetting. Not triggered by lower layers resetting, but is by layers on the same row.
if(layers[resettingLayer].row > this.row) resetLayerData(this.layer, ["points"]) // This is actually the default behavior
},
- layerShown() {return true}, // Condition for when layer appears on the tree
automate() {
}, // Do any automation inherent to this layer if appropriate
resetsNothing() {return false},
@@ -229,15 +230,13 @@ export default {
microtabs: {
stuff: {
first: {
- content: ["upgrades", ["display-text", function() {return "confirmed"}]]
+ display: `
`
},
second: {
- embedLayer: "f",
-
- content: [["upgrade", 11],
- ["row", [["upgrade", 11], "blank", "blank", ["upgrade", 11],]],
-
- ["display-text", function() {return "double confirmed"}]]
+ embedLayer: "f"
},
},
otherStuff: {
@@ -377,7 +376,7 @@ export default {
C O N F I R M E D
-
+
Adjust how many points H gives you!
player.c.otherThingy = value" :min="1" :max="30" />
diff --git a/src/data/layers/aca/f.js b/src/data/layers/aca/f.js
index 8ae29fc..1c826c0 100644
--- a/src/data/layers/aca/f.js
+++ b/src/data/layers/aca/f.js
@@ -33,7 +33,6 @@ export default {
//directMult() {return new Decimal(player.c.otherThingy)},
row: 1,
- layerShown() {return true},
branches: [{ target: "c", 'stroke-width': '25px', 'stroke': 'blue', style: 'filter: blur(5px)' }], // When this layer appears, a branch will appear from this layer to any layers here. Each entry can be a pair consisting of a layer id and a color.
tooltipLocked() { // Optional, tooltip displays when the layer is locked
diff --git a/src/data/mod.js b/src/data/mod.js
index 10b7ffc..15b0fe9 100644
--- a/src/data/mod.js
+++ b/src/data/mod.js
@@ -13,7 +13,7 @@ const g = {
symbol: "TH",
branches: ["c"],
color: '#6d3678',
- layerShown: true,
+ shown: true,
canClick() {return player.points.gte(10)},
tooltip: "Thanos your points",
onClick() {
@@ -23,8 +23,7 @@ const g = {
};
const h = {
id: "h",
- branches: ["g", { target: 'flatBoi', featureType: 'bar', endOffset: { x: () => -50 + 100 * layers.c.bars.flatBoi.progress.toNumber() } }],
- layerShown: true,
+ branches: ["g", () => ({ target: 'flatBoi', featureType: 'bar', endOffset: { x: -50 + 100 * layers.c.bars.flatBoi.progress.toNumber() } })],
tooltip() {return "Restore your points to " + player.c.otherThingy},
row: "side",
canClick() {return player.points.lt(player.c.otherThingy)},
@@ -49,6 +48,7 @@ const main = {
({{ player.oompsMag != 0 ? format(player.oomps) + " OOM" + (player.oompsMag < 0 ? "^OOM" : player.oompsMag > 1 ? "^" + player.oompsMag : "") + "s" : formatSmall($store.getters.pointGain) }}/sec)
+
`,
name: "Tree"
diff --git a/src/main.css b/src/main.css
index 31b6f87..acbbf35 100644
--- a/src/main.css
+++ b/src/main.css
@@ -26,6 +26,10 @@ h1, h2, h3, b, input {
display: inline;
}
+button {
+ color: black;
+}
+
a,
.button,
.link {
diff --git a/src/store/game.js b/src/store/game.js
index 13228bc..3c1b09a 100644
--- a/src/store/game.js
+++ b/src/store/game.js
@@ -17,11 +17,13 @@ function updateOOMPS(diff) {
if (player.points != undefined) {
player.oompsMag = 0;
if (player.points.lte(new Decimal(1e100))) {
+ player.lastPoints = player.points;
return;
}
- let curr = new Decimal(player.points);
+ let curr = player.points;
let prev = player.lastPoints || new Decimal(0);
+ player.lastPoints = curr;
if (curr.gt(prev)) {
if (curr.gte("10^^8")) {
curr = curr.slog(1e10);
diff --git a/src/store/layers.js b/src/store/layers.js
index 9423e5a..cd7b995 100644
--- a/src/store/layers.js
+++ b/src/store/layers.js
@@ -2,7 +2,7 @@ import { isFunction, isPlainObject } from '../util/common';
import { createProxy, createGridProxy, player } from './proxies';
import Decimal from '../util/bignum';
import store from './index';
-import { resetLayer, noCache, getStartingBuyables, getStartingClickables, getStartingChallenges } from '../util/layers';
+import { noCache, getStartingBuyables, getStartingClickables, getStartingChallenges, defaultLayerProperties } from '../util/layers';
export const layers = {};
export const hotkeys = [];
@@ -28,19 +28,15 @@ export function addLayer(layer) {
// Set default property values
layer = Object.assign({}, defaultLayerProperties, layer);
layer.layer = layer.id;
- if (layer.shown == undefined) {
- layer.shown = true;
- }
- if (layer.onClick != undefined) {
- layer.onClick.forceCached = false;
- }
- if (layer.update != undefined) {
- layer.update.forceCached = false;
- }
const getters = {};
// Process each feature
+ for (let property of uncachedProperties) {
+ if (layer[property]) {
+ layer[property].forceCached = false;
+ }
+ }
for (let property of gridProperties) {
if (layer[property]) {
setRowCol(layer[property]);
@@ -144,8 +140,17 @@ export function addLayer(layer) {
}
for (let id in layer.challenges) {
if (isPlainObject(layer.challenges[id])) {
+ if (layer.challenges[id].onComplete != undefined) {
+ layer.challenges[id].onComplete.forceCached = false;
+ }
+ if (layer.challenges[id].onEnter != undefined) {
+ layer.challenges[id].onEnter.forceCached = false;
+ }
+ if (layer.challenges[id].onExit != undefined) {
+ layer.challenges[id].onExit.forceCached = false;
+ }
layer.challenges[id].completed = function() {
- return !layer.deactivated && !!player[layer.id].challenges[id];
+ return !layer.deactivated && player[layer.id].challenges[id]?.gt(0);
}
layer.challenges[id].completions = function() {
return player[layer.id].challenges[id];
@@ -185,7 +190,7 @@ export function addLayer(layer) {
if (layer.challenges[id].completionLimit == undefined) {
layer.challenges[id].completionLimit = new Decimal(1);
}
- layer.challenges[id].toggle = function() {
+ layer.challenges[id].toggle = noCache(function() {
let exiting = player[layer.id].activeChallenge === id;
if (exiting) {
if (this.canComplete && !this.maxed) {
@@ -199,18 +204,21 @@ export function addLayer(layer) {
}
player[layer.id].activeChallenge = null;
this.onExit?.();
- resetLayer(layer.id, true);
+ layer.reset(true);
} else if (!exiting && this.canStart) {
- resetLayer(layer.id, true);
+ layer.reset(true);
player[layer.id].activeChallenge = id;
this.onEnter?.();
}
- }
+ });
if (layer.challenges[id].canStart == undefined) {
layer.challenges[id].canStart = true;
}
}
}
+ layer.activeChallenge = function() {
+ return Object.values(this.challenges).find(challenge => challenge.active);
+ }
}
if (layer.buyables) {
if (player[layer.id].buyables == undefined) {
@@ -220,6 +228,8 @@ export function addLayer(layer) {
layer.buyables.reset = noCache(function() {
player[this.layer].buyables = getStartingBuyables(layer);
});
+ } else {
+ layer.buyables.reset.forceCached = false;
}
for (let id in layer.buyables) {
if (isPlainObject(layer.buyables[id])) {
@@ -366,11 +376,18 @@ export function addLayer(layer) {
}
}
layer.microtabs[family].activeMicrotab = function() {
- if (this[player.subtabs[layer.id][family]]?.unlocked !== false) {
+ if (this[player.subtabs[layer.id][family]] && this[player.subtabs[layer.id][family]].unlocked !== false) {
return this[player.subtabs[layer.id][family]];
}
// Default to first unlocked tab
- return Object.values(this).find(microtab => microtab.unlocked !== false);
+ return this[Object.keys(this).find(microtab => microtab !== 'activeMicrotab' && this[microtab].unlocked !== false)];
+ }
+ }
+ }
+ if (layer.hotkeys) {
+ for (let id in layer.hotkeys) {
+ if (layer.hotkeys[id].onPress) {
+ layer.hotkeys[id].onPress.forceCached = false;
}
}
}
@@ -409,180 +426,7 @@ export function reloadLayer(layer) {
addLayer(layer);
}
-export const defaultLayerProperties = {
- type: "none",
- layerShown: true,
- glowColor: "red",
- minWidth: 640,
- displayRow() {
- return this.row;
- },
- symbol() {
- return this.id;
- },
- unlocked() {
- if (player[this.id].unlocked) {
- return true;
- }
- if (this.type !== "none" && this.canReset && this.layerShown) {
- return true;
- }
- return false;
- },
- trueGlowColor() {
- if (this.subtabs) {
- for (let subtab of Object.values(this.subtabs)) {
- if (subtab.notify) {
- return subtab.glowColor || "red";
- }
- }
- }
- if (this.microtabs) {
- for (let microtab of Object.values(this.microtabs)) {
- if (microtab.notify) {
- return microtab.glowColor || "red";
- }
- }
- }
- return this.glowColor || "red";
- },
- resetGain() {
- if (this.type === "none" || this.type === "custom") {
- return new Decimal(0);
- }
- if (this.gainExp?.eq(0)) {
- return new Decimal(0);
- }
- if (this.baseAmount.lt(this.requires)) {
- return new Decimal(0);
- }
- if (this.type === "static") {
- if (!this.canBuyMax) {
- return new Decimal(1);
- }
- let gain = this.baseAmount.div(this.requires).div(this.gainMult || 1).max(1).log(this.base)
- .times(this.gainExp || 1).pow(Decimal.pow(this.exponent || 1, -1));
- gain = gain.times(this.directMult || 1);
- return gain.floor().sub(player[this.layer].points).add(1).max(1);
- }
- if (this.type === "normal") {
- let gain = this.baseAmount.div(this.requires).pow(this.exponent || 1).times(this.gainMult || 1)
- .pow(this.gainExp || 1);
- if (this.softcap && gain.gte(this.softcap)) {
- gain = gain.pow(this.softcapPower).times(this.softcap.pow(Decimal.sub(1, this.softcapPower)));
- }
- gain = gain.times(this.directMult || 1);
- return gain.floor().max(0);
- }
- // Unknown prestige type
- return new Decimal(0);
- },
- nextAt() {
- if (this.type === "none" || this.type === "custom") {
- return new Decimal(Infinity);
- }
- if (this.gainMult?.lte(0) || this.gainExp?.lte(0)) {
- return new Decimal(Infinity);
- }
- if (this.type === "static") {
- const amount = player[this.layer].points.div(this.directMult || 1);
- const extraCost = Decimal.pow(this.base, amount.pow(this.exponent || 1).div(this.gainExp || 1))
- .times(this.gainMult || 1);
- let cost = extraCost.times(this.requires).max(this.requires);
- if (this.roundUpCost) {
- cost = cost.ceil();
- }
- return cost;
- }
- if (this.type === "normal") {
- let next = this.resetGain.div(this.directMult || 1);
- if (this.softcap && next.gte(this.softcap)) {
- next = next.div(this.softcap.pow(Decimal.sub(1, this.softcapPower)))
- .pow(Decimal.div(1, this.softcapPower));
- }
- next = next.root(this.gainExp || 1).div(this.gainMult || 1).root(this.exponent || 1)
- .times(this.requires).max(this.requires);
- if (this.roundUpCost) {
- next = next.ceil();
- }
- return next;
- }
- // Unknown prestige type
- return new Decimal(0);
- },
- nextAtMax() {
- if (!this.canBuyMax || this.type !== "static") {
- return this.nextAt;
- }
- const amount = player[this.layer].points.plus(this.resetGain).div(this.directMult || 1);
- const extraCost = Decimal.pow(this.base, amount.pow(this.exponent || 1).div(this.gainExp || 1))
- .times(this.gainMult || 1);
- let cost = extraCost.times(this.requires).max(this.requires);
- if (this.roundUpCost) {
- cost = cost.ceil();
- }
- return cost;
- },
- canReset() {
- if (this.type === "normal") {
- return this.baseAmount.gte(this.requires);
- }
- if (this.type === "static") {
- return this.baseAmount.gte(this.nextAt);
- }
- return false;
- },
- notify() {
- if (this.upgrades) {
- if (Object.values(this.upgrades).some(upgrade => upgrade.canAfford && !upgrade.bought && upgrade.unlocked)) {
- return true;
- }
- }
- if (player[this.layer].activeChallenge && this.challenges[player[this.layer].activeChallenge].canComplete) {
- return true;
- }
- if (this.subtabs) {
- if (Object.values(this.subtabs).some(subtab => subtab.notify)) {
- return true;
- }
- }
- if (this.microtabs) {
- if (Object.values(this.microtabs).some(subtab => subtab.notify)) {
- return true;
- }
- }
-
- return false;
- },
- resetNotify() {
- if (this.subtabs) {
- if (Object.values(this.subtabs).some(subtab => subtab.prestigeNotify)) {
- return true;
- }
- }
- if (this.microtabs) {
- if (Object.values(this.microtabs).some(microtab => microtab.prestigeNotify)) {
- return true;
- }
- }
- if (this.autoPrestige || this.passiveGeneration) {
- return false;
- }
- if (this.type === "static") {
- return this.canReset;
- }
- if (this.type === "normal") {
- return this.canReset && this.resetGain.gte(player[this.layer].points.div(10));
- }
- return false;
- },
- reset(force = false) {
- console.warn("Not yet implemented!", force);
- },
- resetData(keep = []) {
- console.warn("Not yet implemented!", keep);
- }
-};
+const uncachedProperties = [ 'startData', 'onClick', 'update', 'reset', 'hardReset' ];
const gridProperties = [ 'upgrades', 'achievements', 'challenges', 'buyables', 'clickables' ];
const featureProperties = [ 'upgrades', 'achievements', 'challenges', 'buyables', 'clickables', 'milestones', 'bars',
'infoboxes', 'grids', 'hotkeys', 'subtabs' ];
diff --git a/src/store/proxies.js b/src/store/proxies.js
index 8e8ee5c..f2b1356 100644
--- a/src/store/proxies.js
+++ b/src/store/proxies.js
@@ -20,7 +20,7 @@ const playerHandler = {
return true;
}
- if (typeof target[key] == "undefined") {
+ if (target[key] == undefined) {
return;
}
@@ -95,7 +95,7 @@ function getHandler(prefix) {
return true;
}
- if (typeof target[key] == "undefined") {
+ if (target[key] == undefined) {
return;
}
diff --git a/src/util/layers.js b/src/util/layers.js
index c91f2a7..c5c1c09 100644
--- a/src/util/layers.js
+++ b/src/util/layers.js
@@ -1,13 +1,14 @@
import Decimal from './bignum';
import { isPlainObject } from './common';
import { layers } from '../store/layers';
+import { player } from '../store/proxies';
export function resetLayer(layer, force = false) {
layers[layer].reset(force);
}
-export function resetLayerData(layer, keep = []) {
- layers[layer].resetData(keep);
+export function hardReset(layer, keep = []) {
+ layers[layer].hardReset(keep);
}
export function cache(func) {
@@ -46,3 +47,248 @@ export function getStartingChallenges(layer) {
return acc;
}, {});
}
+
+export function resetLayerData(layer, keep = []) {
+ keep.push('unlocked', 'forceTooltip', 'noRespecConfirm');
+ const keptData = keep.reduce((acc, curr) => {
+ acc[curr] = player[layer][curr];
+ return acc;
+ }, {});
+
+ player.upgrades = [];
+ player.achievements = [];
+ player.milestones = [];
+ player.infoboxes = {};
+
+ player[layer].buyables = getStartingBuyables(layers[layer]);
+ player[layer].clickables = getStartingClickables(layers[layer]);
+ player[layer].challenges = getStartingChallenges(layers[layer]);
+
+ Object.assign(player[layer], layers[layer].startData?.());
+
+ for (let item in keptData) {
+ player[layer][item] = keptData[item];
+ }
+}
+
+export function resetRow(row, ignore) {
+ Object.values(layers).filter(layer => layer.row === row && layer.layer !== ignore).forEach(layer => layer.hardReset());
+}
+
+export const defaultLayerProperties = {
+ type: "none",
+ shown: true,
+ layerShown: true,
+ glowColor: "red",
+ minWidth: 640,
+ displayRow() {
+ return this.row;
+ },
+ symbol() {
+ return this.id;
+ },
+ unlocked() {
+ if (player[this.id].unlocked) {
+ return true;
+ }
+ if (this.type !== "none" && this.canReset && this.layerShown) {
+ return true;
+ }
+ return false;
+ },
+ trueGlowColor() {
+ if (this.subtabs) {
+ for (let subtab of Object.values(this.subtabs)) {
+ if (subtab.notify) {
+ return subtab.glowColor || "red";
+ }
+ }
+ }
+ if (this.microtabs) {
+ for (let microtab of Object.values(this.microtabs)) {
+ if (microtab.notify) {
+ return microtab.glowColor || "red";
+ }
+ }
+ }
+ return this.glowColor || "red";
+ },
+ resetGain() {
+ if (this.type === "none" || this.type === "custom") {
+ return new Decimal(0);
+ }
+ if (this.gainExp?.eq(0)) {
+ return new Decimal(0);
+ }
+ if (this.baseAmount.lt(this.requires)) {
+ return new Decimal(0);
+ }
+ if (this.type === "static") {
+ if (!this.canBuyMax) {
+ return new Decimal(1);
+ }
+ let gain = this.baseAmount.div(this.requires).div(this.gainMult || 1).max(1).log(this.base)
+ .times(this.gainExp || 1).pow(Decimal.pow(this.exponent || 1, -1));
+ gain = gain.times(this.directMult || 1);
+ return gain.floor().sub(player[this.layer].points).add(1).max(1);
+ }
+ if (this.type === "normal") {
+ let gain = this.baseAmount.div(this.requires).pow(this.exponent || 1).times(this.gainMult || 1)
+ .pow(this.gainExp || 1);
+ if (this.softcap && gain.gte(this.softcap)) {
+ gain = gain.pow(this.softcapPower).times(this.softcap.pow(Decimal.sub(1, this.softcapPower)));
+ }
+ gain = gain.times(this.directMult || 1);
+ return gain.floor().max(0);
+ }
+ // Unknown prestige type
+ return new Decimal(0);
+ },
+ nextAt() {
+ if (this.type === "none" || this.type === "custom") {
+ return new Decimal(Infinity);
+ }
+ if (this.gainMult?.lte(0) || this.gainExp?.lte(0)) {
+ return new Decimal(Infinity);
+ }
+ if (this.type === "static") {
+ const amount = player[this.layer].points.div(this.directMult || 1);
+ const extraCost = Decimal.pow(this.base, amount.pow(this.exponent || 1).div(this.gainExp || 1))
+ .times(this.gainMult || 1);
+ let cost = extraCost.times(this.requires).max(this.requires);
+ if (this.roundUpCost) {
+ cost = cost.ceil();
+ }
+ return cost;
+ }
+ if (this.type === "normal") {
+ let next = this.resetGain.add(1).div(this.directMult || 1);
+ if (this.softcap && next.gte(this.softcap)) {
+ next = next.div(this.softcap.pow(Decimal.sub(1, this.softcapPower)))
+ .pow(Decimal.div(1, this.softcapPower));
+ }
+ next = next.root(this.gainExp || 1).div(this.gainMult || 1).root(this.exponent || 1)
+ .times(this.requires).max(this.requires);
+ if (this.roundUpCost) {
+ next = next.ceil();
+ }
+ return next;
+ }
+ // Unknown prestige type
+ return new Decimal(0);
+ },
+ nextAtMax() {
+ if (!this.canBuyMax || this.type !== "static") {
+ return this.nextAt;
+ }
+ const amount = player[this.layer].points.plus(this.resetGain).div(this.directMult || 1);
+ const extraCost = Decimal.pow(this.base, amount.pow(this.exponent || 1).div(this.gainExp || 1))
+ .times(this.gainMult || 1);
+ let cost = extraCost.times(this.requires).max(this.requires);
+ if (this.roundUpCost) {
+ cost = cost.ceil();
+ }
+ return cost;
+ },
+ canReset() {
+ if (this.type === "normal") {
+ return this.baseAmount.gte(this.requires);
+ }
+ if (this.type === "static") {
+ return this.baseAmount.gte(this.nextAt);
+ }
+ return false;
+ },
+ notify() {
+ if (this.upgrades) {
+ if (Object.values(this.upgrades).some(upgrade => upgrade.canAfford && !upgrade.bought && upgrade.unlocked)) {
+ return true;
+ }
+ }
+ if (this.activeChallenge?.canComplete) {
+ return true;
+ }
+ if (this.subtabs) {
+ if (Object.values(this.subtabs).some(subtab => subtab.notify)) {
+ return true;
+ }
+ }
+ if (this.microtabs) {
+ if (Object.values(this.microtabs).some(subtab => subtab.notify)) {
+ return true;
+ }
+ }
+
+ return false;
+ },
+ resetNotify() {
+ if (this.subtabs) {
+ if (Object.values(this.subtabs).some(subtab => subtab.prestigeNotify)) {
+ return true;
+ }
+ }
+ if (this.microtabs) {
+ if (Object.values(this.microtabs).some(microtab => microtab.prestigeNotify)) {
+ return true;
+ }
+ }
+ if (this.autoPrestige || this.passiveGeneration) {
+ return false;
+ }
+ if (this.type === "static") {
+ return this.canReset;
+ }
+ if (this.type === "normal") {
+ return this.canReset && this.resetGain.gte(player[this.layer].points.div(10));
+ }
+ return false;
+ },
+ reset(force = false) {
+ if (this.type === 'none') {
+ return;
+ }
+ if (!force) {
+ if (!this.canReset) {
+ return;
+ }
+ this.onPrestige?.(this.resetGain);
+ if (player[this.layer].points != undefined) {
+ player[this.layer].points = player[this.layer].points.add(this.resetGain);
+ }
+ if (!player[this.layer].unlocked) {
+ player[this.layer].unlocked = true;
+ if (this.increaseUnlockOrder) {
+ for (let layer in this.increaseUnlockOrder) {
+ player[layer].unlockOrder = (player[layer].unlockOrder || 0) + 1;
+ }
+ }
+ }
+ }
+
+ if (this.resetsNothing) {
+ return;
+ }
+
+ Object.values(layers).forEach(layer => {
+ if (this.row >= layer.row && (!force || this !== layer)) {
+ this.activeChallenge?.toggle();
+ }
+ });
+
+ player.points = new Decimal(0);
+
+ for (let row = this.row; row >= 0; row--) {
+ resetRow(row, this.layer);
+ }
+ resetRow('side', this.layer);
+
+ if (player[this.layer].resetTime != undefined) {
+ player[this.layer].resetTime = 0;
+ }
+ },
+ hardReset(keep = []) {
+ if (!isNaN(this.row)) {
+ resetLayerData(this.layer, keep);
+ }
+ }
+};