Drag portal to portal generator to copy tier + influences

This commit is contained in:
thepaperpilot 2023-05-14 00:57:53 -05:00
parent 8dfc9149d9
commit 7c28de797a

View file

@ -455,6 +455,11 @@ export const portalGenerator = {
text: "Add influence",
color: "var(--accent2)"
};
} else if (draggingNode?.type === "portal") {
const portal = layers[
(draggingNode.state as unknown as PortalState).id
] as GenericPlane;
return { text: `Copy tier/influences from ${portal.name}` };
}
return null;
},
@ -534,7 +539,11 @@ export const portalGenerator = {
}
],
canAccept(node, otherNode) {
return otherNode.type === "resource" || otherNode.type === "influence";
return (
otherNode.type === "resource" ||
otherNode.type === "influence" ||
otherNode.type === "portal"
);
},
onDrop(node, otherNode) {
if (otherNode.type === "resource") {
@ -558,6 +567,15 @@ export const portalGenerator = {
influences: [...currentInfluences, droppedInfluence]
};
}
} else if (otherNode.type === "portal") {
const portal = layers[(otherNode.state as unknown as PortalState).id] as GenericPlane;
node.state = {
...(node.state as object),
tier: portal.tier.value,
influences: (portal.influences.value as unknown as InfluenceState[]).map(
influence => influence.type
)
};
}
main.board.selectedNode.value = node;
},