Mark resources as not persistent where appropriate

This commit is contained in:
thepaperpilot 2022-12-06 00:18:10 -06:00
parent c07298df9c
commit 55f0a7f2dd
6 changed files with 38 additions and 33 deletions

View file

@ -13,6 +13,7 @@ import MainDisplay from "features/resources/MainDisplay.vue";
import { createResource, displayResource } from "features/resources/resource";
import { createUpgrade } from "features/upgrades/upgrade";
import { BaseLayer, createLayer } from "game/layers";
import { noPersist } from "game/persistence";
import Decimal, { DecimalSource, format, formatWhole } from "util/bignum";
import { render, renderRow } from "util/vue";
import { unref } from "vue";
@ -29,7 +30,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
const boxesConversion = createCumulativeConversion(() => ({
scaling: createPolynomialScaling(1e10, 1),
baseResource: trees.logs,
gainResource: boxes,
gainResource: noPersist(boxes),
roundUpCost: true
}));
@ -72,7 +73,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
onPurchase() {
main.days[3].recentlyUpdated.value = true;
},
resource: boxes,
resource: noPersist(boxes),
cost: 100
}));
const ashUpgrade = createUpgrade(() => ({
@ -83,7 +84,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
onPurchase() {
main.days[3].recentlyUpdated.value = true;
},
resource: boxes,
resource: noPersist(boxes),
cost: 1000
}));
const coalUpgrade = createUpgrade(() => ({
@ -94,7 +95,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
onPurchase() {
main.days[3].recentlyUpdated.value = true;
},
resource: boxes,
resource: noPersist(boxes),
cost: 4000
}));
const upgrades = { logsUpgrade, ashUpgrade, coalUpgrade };
@ -107,7 +108,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
<>{format(Decimal.div(logBoxesBuyable.amount.value, 2).add(1))}x</>
))
},
resource: boxes,
resource: noPersist(boxes),
cost() {
return Decimal.pow(3, logBoxesBuyable.amount.value).times(100);
},
@ -121,7 +122,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
<>{format(Decimal.div(ashBoxesBuyable.amount.value, 2).add(1))}x</>
))
},
resource: boxes,
resource: noPersist(boxes),
cost() {
return Decimal.pow(5, ashBoxesBuyable.amount.value).times(1000);
},
@ -135,7 +136,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
<>{format(Decimal.div(coalBoxesBuyable.amount.value, 2).add(1))}x</>
))
},
resource: boxes,
resource: noPersist(boxes),
cost() {
return Decimal.pow(7, coalBoxesBuyable.amount.value).times(1000);
},

View file

@ -15,7 +15,7 @@ import { jsx, JSXFunction, showIf, StyleValue, Visibility } from "features/featu
import { createResource, Resource } from "features/resources/resource";
import { globalBus } from "game/events";
import { BaseLayer, createLayer } from "game/layers";
import { persistent } from "game/persistence";
import { noPersist, persistent } from "game/persistence";
import Decimal, { DecimalSource, format, formatWhole } from "util/bignum";
import { render, renderRow } from "util/vue";
import { computed, ref, unref } from "vue";
@ -295,7 +295,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
}));
const warmerCutters = createUpgrade(() => ({
resource: coal,
resource: noPersist(coal),
cost: 5,
display: {
title: "Warmer Cutters",
@ -304,7 +304,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
style: { color: colorText }
}));
const warmerPlanters = createUpgrade(() => ({
resource: coal,
resource: noPersist(coal),
cost: 5,
display: {
title: "Warmer Planters",
@ -313,7 +313,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
style: { color: colorText }
}));
const basicFertilizer = createUpgrade(() => ({
resource: ash,
resource: noPersist(ash),
cost: 5000,
display: {
title: "Ashy Soil",
@ -336,7 +336,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
const row1upgrades = [warmerCutters, warmerPlanters, basicFertilizer, unlockBonfire];
const dedicatedCutters = createUpgrade(() => ({
resource: coal,
resource: noPersist(coal),
cost: 250,
display: {
title: "Dedicated Cutter Heaters",
@ -346,7 +346,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
visibility: () => showIf(unlockBonfire.bought.value)
}));
const dedicatedPlanters = createUpgrade(() => ({
resource: coal,
resource: noPersist(coal),
cost: 250,
display: {
title: "Dedicated Planter Heaters",
@ -392,7 +392,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
const row2upgrades = [dedicatedCutters, dedicatedPlanters, betterFertilizer, unlockKiln];
const heatedCutters = createBuyable(() => ({
resource: coal,
resource: noPersist(coal),
cost() {
let v = this.amount.value;
if (Decimal.gte(v, 50)) v = Decimal.pow(v, 2).div(50);
@ -412,7 +412,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
visibility: () => showIf(warmerCutters.bought.value)
})) as GenericBuyable & { display: { title: string }; resource: Resource };
const heatedPlanters = createBuyable(() => ({
resource: coal,
resource: noPersist(coal),
cost() {
let v = this.amount.value;
if (Decimal.gte(v, 50)) v = Decimal.pow(v, 2).div(50);
@ -432,7 +432,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
visibility: () => showIf(warmerPlanters.bought.value)
})) as GenericBuyable & { display: { title: string }; resource: Resource };
const moreFertilizer = createBuyable(() => ({
resource: ash,
resource: noPersist(ash),
cost() {
let v = this.amount.value;
if (Decimal.gte(v, 50)) v = Decimal.pow(v, 2).div(50);

View file

@ -325,6 +325,8 @@ const layer = createLayer(id, function (this: BaseLayer) {
const upgrade = createUpgrade(() => {
return {
...options,
// Don't duplicate buyable data
buyable: undefined,
toggle,
buyProgress,
update,

View file

@ -11,6 +11,7 @@ import { jsx, showIf } from "features/feature";
import MainDisplay from "features/resources/MainDisplay.vue";
import { createResource, displayResource } from "features/resources/resource";
import { BaseLayer, createLayer } from "game/layers";
import { noPersist } from "game/persistence";
import Decimal, { DecimalSource, format, formatWhole } from "util/bignum";
import { render, renderCol } from "util/vue";
import { computed, unref } from "vue";
@ -36,7 +37,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
const paperConversion = createCumulativeConversion(() => ({
scaling: createPolynomialScaling(1, 1.2),
baseResource: pulp,
gainResource: paper,
gainResource: noPersist(paper),
roundUpCost: true,
spend(gain, cost) {
trees.logs.value = Decimal.sub(trees.logs.value, Decimal.times(cost, 1e9));
@ -89,7 +90,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
)),
showAmount: false
},
resource: paper,
resource: noPersist(paper),
cost: () => Decimal.pow(5, buyable.amount.value).times(10),
style: "width: 600px"
})) as GenericBuyable;

View file

@ -23,7 +23,7 @@ import {
createSequentialModifier,
Modifier
} from "game/modifiers";
import { persistent } from "game/persistence";
import { noPersist, persistent } from "game/persistence";
import Decimal, { DecimalSource, format, formatWhole, formatLimit } from "util/bignum";
import { Direction, WithRequired } from "util/common";
import { render, renderRow } from "util/vue";
@ -79,7 +79,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
const computedTotalTrees = computed(() => totalTrees.apply(10));
const manualCutUpgrade1 = createUpgrade(() => ({
resource: logs,
resource: noPersist(logs),
cost: 10,
display: {
title: "Wooden Fingers",
@ -87,7 +87,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
}
}));
const manualPlantUpgrade1 = createUpgrade(() => ({
resource: logs,
resource: noPersist(logs),
cost: 10,
display: {
title: "Leafy Fingers",
@ -95,7 +95,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
}
}));
const autoCutUpgrade1 = createUpgrade(() => ({
resource: logs,
resource: noPersist(logs),
cost: 25,
display: {
title: "Automated Knives",
@ -103,7 +103,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
}
}));
const autoPlantUpgrade1 = createUpgrade(() => ({
resource: logs,
resource: noPersist(logs),
cost: 25,
display: {
title: "Automated Spade",
@ -111,7 +111,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
}
}));
const researchUpgrade1 = createUpgrade(() => ({
resource: logs,
resource: noPersist(logs),
cost: 40,
display: {
title: "Research I",
@ -127,7 +127,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
];
const manualCutUpgrade2 = createUpgrade(() => ({
resource: logs,
resource: noPersist(logs),
cost: 50,
visibility: () => showIf(researchUpgrade1.bought.value),
display: {
@ -136,7 +136,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
}
}));
const manualPlantUpgrade2 = createUpgrade(() => ({
resource: logs,
resource: noPersist(logs),
cost: 50,
visibility: () => showIf(researchUpgrade1.bought.value),
display: {
@ -145,7 +145,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
}
}));
const manualCutUpgrade3 = createUpgrade(() => ({
resource: logs,
resource: noPersist(logs),
cost: 150,
visibility: () => showIf(researchUpgrade1.bought.value),
display: {
@ -155,7 +155,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
}
}));
const manualPlantUpgrade3 = createUpgrade(() => ({
resource: logs,
resource: noPersist(logs),
cost: 150,
visibility: () => showIf(researchUpgrade1.bought.value),
display: {
@ -165,7 +165,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
}
}));
const researchUpgrade2 = createUpgrade(() => ({
resource: logs,
resource: noPersist(logs),
cost: 300,
visibility: () => showIf(researchUpgrade1.bought.value),
display: {
@ -182,7 +182,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
];
const autoCuttingBuyable1 = createBuyable(() => ({
resource: logs,
resource: noPersist(logs),
cost() {
let v = this.amount.value;
if (Decimal.gte(v, 50)) v = Decimal.pow(v, 2).div(50);
@ -198,7 +198,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
visibility: () => showIf(researchUpgrade2.bought.value)
})) as GenericBuyable & { display: { title: string }; resource: Resource };
const autoPlantingBuyable1 = createBuyable(() => ({
resource: logs,
resource: noPersist(logs),
cost() {
let v = this.amount.value;
if (Decimal.gte(v, 50)) v = Decimal.pow(v, 2).div(50);
@ -214,7 +214,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
visibility: () => showIf(researchUpgrade2.bought.value)
})) as GenericBuyable & { display: { title: string }; resource: Resource };
const expandingForestBuyable = createBuyable(() => ({
resource: logs,
resource: noPersist(logs),
cost() {
let v = this.amount.value;
if (Decimal.gte(v, 100)) v = Decimal.pow(v, 2).div(100);

View file

@ -18,6 +18,7 @@ import { createHotkey } from "features/hotkey";
import { createMilestone } from "features/milestones/milestone";
import { createResource, displayResource, Resource } from "features/resources/resource";
import { BaseLayer, createLayer } from "game/layers";
import { noPersist } from "game/persistence";
import Decimal, { DecimalSource, formatWhole } from "util/bignum";
import { Direction } from "util/common";
import { render } from "util/vue";
@ -47,7 +48,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
createIndependentConversion(() => ({
scaling: createPolynomialScaling(250, 1.5),
baseResource: trees.logs,
gainResource: foundationProgress,
gainResource: noPersist(foundationProgress),
roundUpCost: true,
buyMax: false,
spend(gain, spent) {