mirror of
https://github.com/thepaperpilot/Planar-Pioneers.git
synced 2024-11-22 00:21:31 +00:00
Fix "disconnect all" visibilities
This commit is contained in:
parent
cd9429b54a
commit
609885e8ff
2 changed files with 15 additions and 57 deletions
|
@ -25,11 +25,18 @@ export const deselectAllAction = {
|
|||
id: "deselect",
|
||||
icon: "close",
|
||||
tooltip: (node: BoardNode) => ({
|
||||
text: "tools" in (node.state as object) ? "Disconnect tools" : "Disconnect resources"
|
||||
text:
|
||||
"portals" in (node.state as object)
|
||||
? "Disconnect portals"
|
||||
: "tools" in (node.state as object)
|
||||
? "Disconnect tools"
|
||||
: "Disconnect resources"
|
||||
}),
|
||||
onClick(node: BoardNode) {
|
||||
if (Array.isArray((node.state as unknown as InfluenceState)?.data)) {
|
||||
node.state = { ...(node.state as object), data: [] };
|
||||
} else if ("portals" in (node.state as object)) {
|
||||
node.state = { ...(node.state as object), portals: [] };
|
||||
} else if ("resources" in (node.state as object)) {
|
||||
node.state = { ...(node.state as object), resources: [] };
|
||||
} else if ("tools" in (node.state as object)) {
|
||||
|
@ -42,6 +49,9 @@ export const deselectAllAction = {
|
|||
if (Array.isArray((node.state as unknown as InfluenceState)?.data)) {
|
||||
return ((node.state as unknown as InfluenceState).data as string[]).length > 0;
|
||||
}
|
||||
if ("portals" in (node.state as object)) {
|
||||
return (node.state as { portals: string[] }).portals.length > 0;
|
||||
}
|
||||
if ("resources" in (node.state as object)) {
|
||||
return (node.state as { resources: Resources[] }).resources.length > 0;
|
||||
}
|
||||
|
|
|
@ -652,20 +652,7 @@ export const booster = {
|
|||
},
|
||||
actionDistance: Math.PI / 4,
|
||||
actions: [
|
||||
{
|
||||
id: "deselect",
|
||||
icon: "close",
|
||||
tooltip: {
|
||||
text: "Disconnect portals"
|
||||
},
|
||||
onClick(node: BoardNode) {
|
||||
node.state = { ...(node.state as object), portals: [] };
|
||||
main.board.selectedAction.value = null;
|
||||
main.board.selectedNode.value = null;
|
||||
},
|
||||
visibility: (node: BoardNode) =>
|
||||
(node.state as unknown as BoosterState)?.portals.length ?? 0 > 0
|
||||
},
|
||||
deselectAllAction,
|
||||
getIncreaseConnectionsAction(x => x.add(6).pow_base(1000)),
|
||||
{
|
||||
id: "increaseBoost",
|
||||
|
@ -733,20 +720,7 @@ export const upgrader = {
|
|||
},
|
||||
actionDistance: Math.PI / 4,
|
||||
actions: [
|
||||
{
|
||||
id: "deselect",
|
||||
icon: "close",
|
||||
tooltip: {
|
||||
text: "Disconnect portals"
|
||||
},
|
||||
onClick(node: BoardNode) {
|
||||
node.state = { ...(node.state as object), portals: [] };
|
||||
main.board.selectedAction.value = null;
|
||||
main.board.selectedNode.value = null;
|
||||
},
|
||||
visibility: (node: BoardNode) =>
|
||||
(node.state as unknown as UpgraderState)?.portals.length ?? 0 > 0
|
||||
},
|
||||
deselectAllAction,
|
||||
getIncreaseConnectionsAction(x => x.add(4).pow_base(1e6)),
|
||||
togglePoweredAction
|
||||
],
|
||||
|
@ -782,20 +756,7 @@ export const automator = {
|
|||
},
|
||||
actionDistance: Math.PI / 4,
|
||||
actions: [
|
||||
{
|
||||
id: "deselect",
|
||||
icon: "close",
|
||||
tooltip: {
|
||||
text: "Disconnect portals"
|
||||
},
|
||||
onClick(node: BoardNode) {
|
||||
node.state = { ...(node.state as object), portals: [] };
|
||||
main.board.selectedAction.value = null;
|
||||
main.board.selectedNode.value = null;
|
||||
},
|
||||
visibility: (node: BoardNode) =>
|
||||
(node.state as unknown as AutomatorState)?.portals.length ?? 0 > 0
|
||||
},
|
||||
deselectAllAction,
|
||||
getIncreaseConnectionsAction(x => x.add(4).pow_base(1e6)),
|
||||
togglePoweredAction
|
||||
],
|
||||
|
@ -831,20 +792,7 @@ export const investments = {
|
|||
},
|
||||
actionDistance: Math.PI / 4,
|
||||
actions: [
|
||||
{
|
||||
id: "deselect",
|
||||
icon: "close",
|
||||
tooltip: {
|
||||
text: "Disconnect portals"
|
||||
},
|
||||
onClick(node: BoardNode) {
|
||||
node.state = { ...(node.state as object), portals: [] };
|
||||
main.board.selectedAction.value = null;
|
||||
main.board.selectedNode.value = null;
|
||||
},
|
||||
visibility: (node: BoardNode) =>
|
||||
(node.state as unknown as InvestmentsState)?.portals.length ?? 0 > 0
|
||||
},
|
||||
deselectAllAction,
|
||||
getIncreaseConnectionsAction(x => x.add(3).pow_base(1e8)),
|
||||
togglePoweredAction
|
||||
],
|
||||
|
|
Loading…
Reference in a new issue