mirror of
https://github.com/thepaperpilot/Planar-Pioneers.git
synced 2024-11-25 01:41:44 +00:00
Implement making tools
(but tools are not yet implemented)
This commit is contained in:
parent
a81868718d
commit
eddf0d53b7
1 changed files with 31 additions and 26 deletions
|
@ -145,37 +145,40 @@ export const main = createLayer("main", function (this: BaseLayer) {
|
||||||
dirt: {
|
dirt: {
|
||||||
cost: 1000,
|
cost: 1000,
|
||||||
name: "Unknown Item",
|
name: "Unknown Item",
|
||||||
type: "unknownType"
|
type: "passive",
|
||||||
|
state: "miningSpeed"
|
||||||
},
|
},
|
||||||
sand: {
|
sand: {
|
||||||
cost: 1e4,
|
cost: 1e4,
|
||||||
name: "Unknown Item",
|
name: "Dowsing Rod",
|
||||||
type: "unknownType"
|
type: "dowsing"
|
||||||
},
|
},
|
||||||
gravel: {
|
gravel: {
|
||||||
cost: 1e5,
|
cost: 1e5,
|
||||||
name: "Unknown Item",
|
name: "Unknown Item",
|
||||||
type: "unknownType"
|
type: "passive",
|
||||||
|
state: "droppedLoot"
|
||||||
},
|
},
|
||||||
wood: {
|
wood: {
|
||||||
cost: 1e6,
|
cost: 1e6,
|
||||||
name: "Unknown Item",
|
name: "Unknown Item", // (action node)
|
||||||
type: "unknownType"
|
type: "unknownType"
|
||||||
},
|
},
|
||||||
stone: {
|
stone: {
|
||||||
cost: 1e7,
|
cost: 1e7,
|
||||||
name: "Unknown Item",
|
name: "Unknown Item",
|
||||||
type: "unknownType"
|
type: "passive",
|
||||||
|
state: "energyGain"
|
||||||
},
|
},
|
||||||
coal: {
|
coal: {
|
||||||
cost: 1e8,
|
cost: 1e8,
|
||||||
name: "Unknown Item",
|
name: "Tool Empowerer",
|
||||||
type: "unknownType"
|
type: "empowerer"
|
||||||
},
|
},
|
||||||
copper: {
|
copper: {
|
||||||
cost: 1e9,
|
cost: 1e9,
|
||||||
name: "Unknown Item",
|
name: "Unknown Item", // (passive)
|
||||||
type: "unknownType"
|
type: "passive"
|
||||||
},
|
},
|
||||||
iron: {
|
iron: {
|
||||||
cost: 1e10,
|
cost: 1e10,
|
||||||
|
@ -222,7 +225,7 @@ export const main = createLayer("main", function (this: BaseLayer) {
|
||||||
name: "Unknown Item",
|
name: "Unknown Item",
|
||||||
type: "unknownType"
|
type: "unknownType"
|
||||||
}
|
}
|
||||||
} satisfies Record<
|
} as Record<
|
||||||
Resources,
|
Resources,
|
||||||
{
|
{
|
||||||
cost: DecimalSource;
|
cost: DecimalSource;
|
||||||
|
@ -268,11 +271,11 @@ export const main = createLayer("main", function (this: BaseLayer) {
|
||||||
{
|
{
|
||||||
id: "repair",
|
id: "repair",
|
||||||
icon: "build",
|
icon: "build",
|
||||||
tooltip: { text: "Repair - 1000 energy" },
|
tooltip: { text: "Repair - 100 energy" },
|
||||||
onClick(node) {
|
onClick(node) {
|
||||||
if (Decimal.gte(energy.value, 1000)) {
|
if (Decimal.gte(energy.value, 100)) {
|
||||||
node.type = "factory";
|
node.type = "factory";
|
||||||
energy.value = Decimal.sub(energy.value, 1000);
|
energy.value = Decimal.sub(energy.value, 100);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
confirmationLabel: () =>
|
confirmationLabel: () =>
|
||||||
|
@ -309,10 +312,17 @@ export const main = createLayer("main", function (this: BaseLayer) {
|
||||||
)} energy`
|
)} energy`
|
||||||
}),
|
}),
|
||||||
onClick(node) {
|
onClick(node) {
|
||||||
const cost = tools[node.state as Resources].cost;
|
const tool = tools[node.state as Resources];
|
||||||
if (Decimal.gte(energy.value, cost)) {
|
if (Decimal.gte(energy.value, tool.cost)) {
|
||||||
energy.value = Decimal.sub(energy.value, cost);
|
energy.value = Decimal.sub(energy.value, tool.cost);
|
||||||
// TODO create tool
|
const newNode = {
|
||||||
|
id: getUniqueNodeID(board as GenericBoard),
|
||||||
|
position: { ...node.position },
|
||||||
|
type: tool.type,
|
||||||
|
state: tool.state
|
||||||
|
};
|
||||||
|
board.placeInAvailableSpace(newNode);
|
||||||
|
board.nodes.value.push(newNode);
|
||||||
board.selectedAction.value = null;
|
board.selectedAction.value = null;
|
||||||
board.selectedNode.value = null;
|
board.selectedNode.value = null;
|
||||||
}
|
}
|
||||||
|
@ -382,18 +392,13 @@ export const main = createLayer("main", function (this: BaseLayer) {
|
||||||
let node = resourceNodes.value[type];
|
let node = resourceNodes.value[type];
|
||||||
if (node == null) {
|
if (node == null) {
|
||||||
const mine = board.nodes.value.find(n => n.type === "mine") as BoardNode;
|
const mine = board.nodes.value.find(n => n.type === "mine") as BoardNode;
|
||||||
let x = mine.position.x;
|
|
||||||
x = board.nodes.value
|
|
||||||
.filter(
|
|
||||||
n => n.position.y < mine.position.y + 50 && n.position.y > mine.position.y - 50
|
|
||||||
)
|
|
||||||
.reduce((x, node) => Math.max(x, node.position.x + 100), 0);
|
|
||||||
node = {
|
node = {
|
||||||
id: getUniqueNodeID(board),
|
id: getUniqueNodeID(board),
|
||||||
position: { x, y: mine.position.y },
|
position: { ...mine.position },
|
||||||
type: "resource",
|
type: "resource",
|
||||||
state: { type, amount }
|
state: { type, amount }
|
||||||
};
|
};
|
||||||
|
board.placeInAvailableSpace(node);
|
||||||
board.nodes.value.push(node);
|
board.nodes.value.push(node);
|
||||||
} else {
|
} else {
|
||||||
const state = node.state as unknown as ResourceState;
|
const state = node.state as unknown as ResourceState;
|
||||||
|
@ -508,7 +513,7 @@ export const main = createLayer("main", function (this: BaseLayer) {
|
||||||
const energyChange = computed(() => {
|
const energyChange = computed(() => {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
if (board.selectedAction.value === board.types.brokenFactory.actions![0]) {
|
if (board.selectedAction.value === board.types.brokenFactory.actions![0]) {
|
||||||
return -1000;
|
return -100;
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
if (board.selectedAction.value === board.types.factory.actions![0]) {
|
if (board.selectedAction.value === board.types.factory.actions![0]) {
|
||||||
|
|
Loading…
Reference in a new issue