Disable dragging nodes to forge if item is already crafted

This commit is contained in:
thepaperpilot 2023-05-14 10:15:30 -05:00
parent a12d6cdd0a
commit 852050f474

View file

@ -118,7 +118,12 @@ export const factory = {
const resource = (
(main.board as GenericBoard).draggingNode.value?.state as unknown as ResourceState
).type;
const text = node.state === resource ? "Disconnect" : tools[resource].name;
const text =
node.state === resource
? "Disconnect"
: main.toolNodes.value[resource] == null
? tools[resource].name
: "Already crafted";
const color =
node.state === resource || main.toolNodes.value[resource] == null
? "var(--accent2)"
@ -209,7 +214,13 @@ export const factory = {
? "var(--accent2)"
: "var(--foreground)",
canAccept(node, otherNode) {
return otherNode.type === "resource";
if (otherNode.type !== "resource") {
return false;
}
const resource = (
(main.board as GenericBoard).draggingNode.value?.state as unknown as ResourceState
).type;
return main.toolNodes.value[resource] == null;
},
onDrop(node, otherNode) {
const droppedType = (otherNode.state as unknown as ResourceState).type;