Implemented dirt relic

This commit is contained in:
thepaperpilot 2023-05-12 09:27:08 -05:00
parent c36b4c2f6b
commit a378d4e6a1

View file

@ -40,7 +40,7 @@ import { Computable, ProcessedComputable, convertComputable } from "util/compute
import { VueFeature, render, renderCol, renderRow, trackHover } from "util/vue"; import { VueFeature, render, renderCol, renderRow, trackHover } from "util/vue";
import { ComputedRef, Ref, computed, ref, unref } from "vue"; import { ComputedRef, Ref, computed, ref, unref } from "vue";
import { useToast } from "vue-toastification"; import { useToast } from "vue-toastification";
import { isPowered } from "./boardUtils"; import { isEmpowered, isPowered } from "./boardUtils";
import { createCollapsibleModifierSections, createFormulaPreview, estimateTime } from "./common"; import { createCollapsibleModifierSections, createFormulaPreview, estimateTime } from "./common";
import { import {
AutomatorState, AutomatorState,
@ -235,7 +235,9 @@ export function createPlane(
const cost = nextCost.value; const cost = nextCost.value;
const title = getPowerName(random); const title = getPowerName(random);
let description = ""; let description = "";
let modifier: WithRequired<Modifier, "description" | "invert">; let modifier: (
condition?: () => boolean
) => WithRequired<Modifier, "description" | "invert">;
let previewModifier: WithRequired<Modifier, "invert">; let previewModifier: WithRequired<Modifier, "invert">;
const currentN = n.value; const currentN = n.value;
switch (upgradeType) { switch (upgradeType) {
@ -243,11 +245,15 @@ export function createPlane(
const addend = Decimal.add(cost, 10).pow(random() / 4 + 0.875); const addend = Decimal.add(cost, 10).pow(random() / 4 + 0.875);
description = `Gain ${format(addend)} ${resource.displayName}/s`; description = `Gain ${format(addend)} ${resource.displayName}/s`;
costFormula = costFormula.add(addend); costFormula = costFormula.add(addend);
modifier = createAdditiveModifier(() => ({ modifier = condition =>
addend, createAdditiveModifier(() => ({
description: title, addend,
enabled: upgrade.bought description: title,
})); enabled:
condition == null
? upgrade.bought
: () => condition() && upgrade.bought.value
}));
previewModifier = createAdditiveModifier(() => ({ addend })); previewModifier = createAdditiveModifier(() => ({ addend }));
break; break;
} }
@ -259,11 +265,15 @@ export function createPlane(
costFormula = costFormula.add( costFormula = costFormula.add(
Decimal.sub(multiplier, 1).times(cachedGain[currentN - 1]) Decimal.sub(multiplier, 1).times(cachedGain[currentN - 1])
); );
modifier = createMultiplicativeModifier(() => ({ modifier = condition =>
multiplier, createMultiplicativeModifier(() => ({
description: title, multiplier,
enabled: upgrade.bought description: title,
})); enabled:
condition == null
? upgrade.bought
: () => condition() && upgrade.bought.value
}));
previewModifier = createMultiplicativeModifier(() => ({ previewModifier = createMultiplicativeModifier(() => ({
multiplier multiplier
})); }));
@ -277,11 +287,15 @@ export function createPlane(
costFormula = costFormula costFormula = costFormula
.add(Decimal.pow(cachedGain[currentN - 1], exponent)) .add(Decimal.pow(cachedGain[currentN - 1], exponent))
.sub(cachedGain[currentN - 1]); .sub(cachedGain[currentN - 1]);
modifier = createExponentialModifier(() => ({ modifier = condition =>
exponent, createExponentialModifier(() => ({
description: title, exponent,
enabled: upgrade.bought description: title,
})); enabled:
condition == null
? upgrade.bought
: () => condition() && upgrade.bought.value
}));
previewModifier = createExponentialModifier(() => ({ exponent })); previewModifier = createExponentialModifier(() => ({ exponent }));
} }
} }
@ -302,11 +316,15 @@ export function createPlane(
prepareFeature({ prepareFeature({
feature: upgrade, feature: upgrade,
canClick: () => upgrade.canPurchase.value, canClick: () => upgrade.canPurchase.value,
modifier, modifier: modifier(),
cost, cost,
showETA: () => !upgrade.bought.value, showETA: () => !upgrade.bought.value,
previewModifier previewModifier
}); });
resourceModifiers.push(
modifier(() => main.toolNodes.value.dirtRelic != null)
);
resourceModifiers.push(modifier(() => isEmpowered("dirtRelic")));
upgrades.push(upgrade); upgrades.push(upgrade);
} }
features.push(upgrades); features.push(upgrades);