DNDGamePlayer: Electron редактор сцен, презентация, упаковка electron-builder
Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import type { GraphNodeId, SceneGraphEdge, SceneGraphNode, SceneId } from '../types';
|
||||
|
||||
/**
|
||||
* true — связь добавлять нельзя: нет узлов, петля по одной сцене, то же ребро уже есть,
|
||||
* или с этого узла уже ведёт связь к другой карточке той же целевой сцены.
|
||||
* Разрешены несколько исходящих «вариантов» с одной ноды только на разные сцены.
|
||||
*/
|
||||
export function isSceneGraphEdgeRejected(
|
||||
sceneGraphNodes: SceneGraphNode[],
|
||||
sceneGraphEdges: SceneGraphEdge[],
|
||||
sourceGraphNodeId: GraphNodeId,
|
||||
targetGraphNodeId: GraphNodeId,
|
||||
): boolean {
|
||||
const gnScene = new Map<GraphNodeId, SceneId>(sceneGraphNodes.map((n) => [n.id, n.sceneId]));
|
||||
const srcScene = gnScene.get(sourceGraphNodeId);
|
||||
const tgtScene = gnScene.get(targetGraphNodeId);
|
||||
if (srcScene === undefined || tgtScene === undefined) return true;
|
||||
if (srcScene === tgtScene) return true;
|
||||
|
||||
for (const e of sceneGraphEdges) {
|
||||
if (e.sourceGraphNodeId !== sourceGraphNodeId) continue;
|
||||
if (e.targetGraphNodeId === targetGraphNodeId) return true;
|
||||
if (gnScene.get(e.targetGraphNodeId) === tgtScene) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Reference in New Issue
Block a user