DNDGamePlayer: Electron редактор сцен, презентация, упаковка electron-builder

Made-with: Cursor
This commit is contained in:
Ivan Fontosh
2026-04-19 14:16:54 +08:00
commit a6cbcc273e
82 changed files with 22195 additions and 0 deletions
+26
View File
@@ -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;
}