mirror of
https://github.com/thepaperpilot/Planar-Pioneers.git
synced 2024-11-22 08:31:31 +00:00
Implement increasing max connections
This commit is contained in:
parent
cc35cc6be8
commit
bd8d376e4a
1 changed files with 48 additions and 0 deletions
|
@ -32,6 +32,7 @@ import { ComputedRef, computed, nextTick, reactive, ref, watch } from "vue";
|
||||||
import { useToast } from "vue-toastification";
|
import { useToast } from "vue-toastification";
|
||||||
import { Section, createCollapsibleModifierSections, createFormulaPreview } from "./common";
|
import { Section, createCollapsibleModifierSections, createFormulaPreview } from "./common";
|
||||||
import "./main.css";
|
import "./main.css";
|
||||||
|
import { GenericFormula, InvertibleIntegralFormula } from "game/formulas/types";
|
||||||
|
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
|
|
||||||
|
@ -306,6 +307,40 @@ export const main = createLayer("main", function (this: BaseLayer) {
|
||||||
(node.state as { powered: boolean }).powered ? "var(--accent1)" : "var(--locked)"
|
(node.state as { powered: boolean }).powered ? "var(--accent1)" : "var(--locked)"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function getIncreaseConnectionsAction(
|
||||||
|
cost: (x: InvertibleIntegralFormula) => GenericFormula,
|
||||||
|
maxConnections = Infinity
|
||||||
|
) {
|
||||||
|
const formula = cost(Formula.variable(0));
|
||||||
|
return {
|
||||||
|
id: "moreConnections",
|
||||||
|
icon: "hub",
|
||||||
|
formula,
|
||||||
|
tooltip(node: BoardNode) {
|
||||||
|
return {
|
||||||
|
text: `Increase Connections - ${formatWhole(
|
||||||
|
formula.evaluate((node.state as { maxConnections: number }).maxConnections)
|
||||||
|
)} energy`
|
||||||
|
};
|
||||||
|
},
|
||||||
|
onClick(node: BoardNode) {
|
||||||
|
const cost = formula.evaluate(
|
||||||
|
(node.state as { maxConnections: number }).maxConnections
|
||||||
|
);
|
||||||
|
if (Decimal.gte(energy.value, cost)) {
|
||||||
|
energy.value = Decimal.sub(energy.value, cost);
|
||||||
|
}
|
||||||
|
node.state = {
|
||||||
|
...(node.state as object),
|
||||||
|
maxConnections: (node.state as { maxConnections: number }).maxConnections + 1
|
||||||
|
};
|
||||||
|
board.selectedAction.value = null;
|
||||||
|
},
|
||||||
|
visibility: (node: BoardNode) =>
|
||||||
|
(node.state as { maxConnections: number }).maxConnections < maxConnections
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const board = createBoard(board => ({
|
const board = createBoard(board => ({
|
||||||
startNodes: () => [
|
startNodes: () => [
|
||||||
{ position: { x: 0, y: 0 }, type: "mine", state: { progress: 0, powered: false } },
|
{ position: { x: 0, y: 0 }, type: "mine", state: { progress: 0, powered: false } },
|
||||||
|
@ -512,6 +547,8 @@ export const main = createLayer("main", function (this: BaseLayer) {
|
||||||
: `Dowsing - Doubling ${
|
: `Dowsing - Doubling ${
|
||||||
(node.state as { resources: Resources[] }).resources
|
(node.state as { resources: Resources[] }).resources
|
||||||
.length
|
.length
|
||||||
|
}/${
|
||||||
|
(node.state as { maxConnections: number }).maxConnections
|
||||||
} materials' odds`
|
} materials' odds`
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -547,6 +584,7 @@ export const main = createLayer("main", function (this: BaseLayer) {
|
||||||
visibility: node =>
|
visibility: node =>
|
||||||
(node.state as unknown as DowsingState).resources.length > 0
|
(node.state as unknown as DowsingState).resources.length > 0
|
||||||
},
|
},
|
||||||
|
getIncreaseConnectionsAction(x => x.add(2).pow_base(100), 16),
|
||||||
togglePoweredAction
|
togglePoweredAction
|
||||||
],
|
],
|
||||||
classes: node => ({
|
classes: node => ({
|
||||||
|
@ -899,6 +937,16 @@ export const main = createLayer("main", function (this: BaseLayer) {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
return Decimal.neg(tools[board.selectedNode.value!.state as Resources].cost);
|
return Decimal.neg(tools[board.selectedNode.value!.state as Resources].cost);
|
||||||
}
|
}
|
||||||
|
if (board.selectedAction.value?.id === "moreConnections") {
|
||||||
|
return Decimal.neg(
|
||||||
|
(
|
||||||
|
board.selectedAction.value as unknown as { formula: GenericFormula }
|
||||||
|
).formula.evaluate(
|
||||||
|
(board.selectedNode.value?.state as unknown as { maxConnections: number })
|
||||||
|
.maxConnections
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
const energyPreview = createFormulaPreview(
|
const energyPreview = createFormulaPreview(
|
||||||
|
|
Loading…
Reference in a new issue