mirror of
https://github.com/thepaperpilot/Planar-Pioneers.git
synced 2025-04-01 13:31:07 +00:00
Set up most of forge's mechanics
This commit is contained in:
parent
977114c954
commit
8a08d2e7d4
1 changed files with 130 additions and 11 deletions
|
@ -141,6 +141,97 @@ export const main = createLayer("main", function (this: BaseLayer) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const tools = {
|
||||||
|
dirt: {
|
||||||
|
cost: 1000,
|
||||||
|
name: "Unknown Item",
|
||||||
|
type: "unknownType"
|
||||||
|
},
|
||||||
|
sand: {
|
||||||
|
cost: 1e4,
|
||||||
|
name: "Unknown Item",
|
||||||
|
type: "unknownType"
|
||||||
|
},
|
||||||
|
gravel: {
|
||||||
|
cost: 1e5,
|
||||||
|
name: "Unknown Item",
|
||||||
|
type: "unknownType"
|
||||||
|
},
|
||||||
|
wood: {
|
||||||
|
cost: 1e6,
|
||||||
|
name: "Unknown Item",
|
||||||
|
type: "unknownType"
|
||||||
|
},
|
||||||
|
stone: {
|
||||||
|
cost: 1e7,
|
||||||
|
name: "Unknown Item",
|
||||||
|
type: "unknownType"
|
||||||
|
},
|
||||||
|
coal: {
|
||||||
|
cost: 1e8,
|
||||||
|
name: "Unknown Item",
|
||||||
|
type: "unknownType"
|
||||||
|
},
|
||||||
|
copper: {
|
||||||
|
cost: 1e9,
|
||||||
|
name: "Unknown Item",
|
||||||
|
type: "unknownType"
|
||||||
|
},
|
||||||
|
iron: {
|
||||||
|
cost: 1e10,
|
||||||
|
name: "Portal Generator",
|
||||||
|
type: "portalGenerator"
|
||||||
|
},
|
||||||
|
silver: {
|
||||||
|
cost: 1e12,
|
||||||
|
name: "Unknown Item",
|
||||||
|
type: "unknownType"
|
||||||
|
},
|
||||||
|
gold: {
|
||||||
|
cost: 1e15,
|
||||||
|
name: "Unknown Item",
|
||||||
|
type: "unknownType"
|
||||||
|
},
|
||||||
|
emerald: {
|
||||||
|
cost: 1e19,
|
||||||
|
name: "Unknown Item",
|
||||||
|
type: "unknownType"
|
||||||
|
},
|
||||||
|
platinum: {
|
||||||
|
cost: 1e24,
|
||||||
|
name: "Unknown Item",
|
||||||
|
type: "unknownType"
|
||||||
|
},
|
||||||
|
diamond: {
|
||||||
|
cost: 1e30,
|
||||||
|
name: "Unknown Item",
|
||||||
|
type: "unknownType"
|
||||||
|
},
|
||||||
|
berylium: {
|
||||||
|
cost: 1e37,
|
||||||
|
name: "Unknown Item",
|
||||||
|
type: "unknownType"
|
||||||
|
},
|
||||||
|
unobtainium: {
|
||||||
|
cost: 1e45,
|
||||||
|
name: "Unknown Item",
|
||||||
|
type: "unknownType"
|
||||||
|
},
|
||||||
|
ultimatum: {
|
||||||
|
cost: 1e54,
|
||||||
|
name: "Unknown Item",
|
||||||
|
type: "unknownType"
|
||||||
|
}
|
||||||
|
} satisfies Record<
|
||||||
|
Resources,
|
||||||
|
{
|
||||||
|
cost: DecimalSource;
|
||||||
|
name: string;
|
||||||
|
type: string;
|
||||||
|
state?: State;
|
||||||
|
}
|
||||||
|
>;
|
||||||
|
|
||||||
const board = createBoard(board => ({
|
const board = createBoard(board => ({
|
||||||
startNodes: () => [
|
startNodes: () => [
|
||||||
{ position: { x: 0, y: 0 }, type: "mine", state: 0 },
|
{ position: { x: 0, y: 0 }, type: "mine", state: 0 },
|
||||||
|
@ -198,25 +289,48 @@ export const main = createLayer("main", function (this: BaseLayer) {
|
||||||
title: "🛠️",
|
title: "🛠️",
|
||||||
label: node =>
|
label: node =>
|
||||||
node === board.selectedNode.value
|
node === board.selectedNode.value
|
||||||
? { text: hasForged.value ? "Forge" : "Forge - Drag a material to me!" }
|
? {
|
||||||
|
text:
|
||||||
|
node.state == null
|
||||||
|
? hasForged.value
|
||||||
|
? "Forge"
|
||||||
|
: "Forge - Drag a material to me!"
|
||||||
|
: `Forge - ${tools[node.state as Resources].name} selected`
|
||||||
|
}
|
||||||
: null,
|
: null,
|
||||||
actionDistance: 100,
|
actionDistance: 100,
|
||||||
actions: [
|
actions: [
|
||||||
|
{
|
||||||
|
id: "craft",
|
||||||
|
icon: "done",
|
||||||
|
tooltip: node => ({
|
||||||
|
text: `Forge ${tools[node.state as Resources].name} - ${formatWhole(
|
||||||
|
tools[node.state as Resources].cost
|
||||||
|
)} energy`
|
||||||
|
}),
|
||||||
|
onClick(node) {
|
||||||
|
const cost = tools[node.state as Resources].cost;
|
||||||
|
if (Decimal.gte(energy.value, cost)) {
|
||||||
|
energy.value = Decimal.sub(energy.value, cost);
|
||||||
|
// TODO create tool
|
||||||
|
board.selectedAction.value = null;
|
||||||
|
board.selectedNode.value = null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
visibility: node => node.state != null,
|
||||||
|
confirmationLabel: node =>
|
||||||
|
Decimal.gte(energy.value, tools[node.state as Resources].cost)
|
||||||
|
? { text: "Tap again to confirm" }
|
||||||
|
: { text: "Cannot afford", color: "var(--danger)" }
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: "deselect",
|
id: "deselect",
|
||||||
icon: "",
|
icon: "close",
|
||||||
tooltip: { text: "De-select material" },
|
tooltip: { text: "De-select material" },
|
||||||
onClick(node) {
|
onClick(node) {
|
||||||
node.state = undefined;
|
node.state = undefined;
|
||||||
},
|
board.selectedAction.value = null;
|
||||||
visibility: node => node.state != null
|
board.selectedNode.value = null;
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "craft",
|
|
||||||
icon: "",
|
|
||||||
tooltip: node => ({ text: "Craft unknown item" }),
|
|
||||||
onClick(node) {
|
|
||||||
// TODO create tool
|
|
||||||
},
|
},
|
||||||
visibility: node => node.state != null
|
visibility: node => node.state != null
|
||||||
}
|
}
|
||||||
|
@ -396,6 +510,11 @@ export const main = createLayer("main", function (this: BaseLayer) {
|
||||||
if (board.selectedAction.value === board.types.brokenFactory.actions![0]) {
|
if (board.selectedAction.value === board.types.brokenFactory.actions![0]) {
|
||||||
return -1000;
|
return -1000;
|
||||||
}
|
}
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
|
if (board.selectedAction.value === board.types.factory.actions![0]) {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
|
return Decimal.neg(tools[board.selectedNode.value!.state as Resources].cost);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
const energyPreview = createFormulaPreview(
|
const energyPreview = createFormulaPreview(
|
||||||
|
|
Loading…
Add table
Reference in a new issue