Add pow procgen upgrade type

This commit is contained in:
thepaperpilot 2023-04-29 16:06:43 -05:00
parent 189cac6942
commit 65c5c392bd

View file

@ -27,6 +27,7 @@ import { addTooltip } from "features/tooltips/tooltip";
import { GenericAchievement, createAchievement } from "features/achievements/achievement"; import { GenericAchievement, createAchievement } from "features/achievements/achievement";
import { Computable } from "util/computed"; import { Computable } from "util/computed";
import { BoardNode } from "features/boards/board"; import { BoardNode } from "features/boards/board";
import { createExponentialModifier } from "game/modifiers";
export type Treasure = GenericAchievement & { export type Treasure = GenericAchievement & {
update?: (diff: number) => void; update?: (diff: number) => void;
@ -90,7 +91,8 @@ export function createPlane(id: string, tier: Resources, seed: number) {
for (let j = 0; j < 4; j++) { for (let j = 0; j < 4; j++) {
const upgradeTypeWeights = { const upgradeTypeWeights = {
add: 1, add: 1,
mult: i === 0 && j === 0 ? 0 : 1 mult: i === 0 && j === 0 ? 0 : 1,
pow: i === 0 ? 0 : 0.5
}; };
const sumUpgradeTypeWeights = Object.values(upgradeTypeWeights).reduce( const sumUpgradeTypeWeights = Object.values(upgradeTypeWeights).reduce(
(a, b) => a + b (a, b) => a + b
@ -153,6 +155,21 @@ export function createPlane(id: string, tier: Resources, seed: number) {
})); }));
break; break;
} }
case "pow": {
const exponent = random() / 5 + 1;
description = `Raise ${resource.displayName} gain to the ^${format(
exponent
)}`;
costFormula = costFormula.step(t.value, c => {
const beforeStep = Decimal.sub(t.value, c.evaluate());
return c.add(beforeStep).pow(exponent).sub(beforeStep);
});
modifier = createExponentialModifier(() => ({
exponent,
description: title,
enabled: upgrade.bought
}));
}
} }
t.value = Decimal.times(difficulty, random() + 0.5) t.value = Decimal.times(difficulty, random() + 0.5)
.pow_base(2) .pow_base(2)