From c8904d7776d32f1a3fe6da535649d9944d7f0270 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 28 May 2019 09:04:38 +0200 Subject: [PATCH] Bug Fixed: Deleting Phases and Conditions --- FloatingSpace/StrategyPartConstructor.js | 6 +-- .../FunctionLibraries/NodeDeleter.js | 37 +++++++++---------- StrategySpace/Workspace/Workspace.js | 2 +- 3 files changed, 21 insertions(+), 24 deletions(-) diff --git a/FloatingSpace/StrategyPartConstructor.js b/FloatingSpace/StrategyPartConstructor.js index bd56f446e..54e2d3b9f 100644 --- a/FloatingSpace/StrategyPartConstructor.js +++ b/FloatingSpace/StrategyPartConstructor.js @@ -1026,7 +1026,7 @@ function newStrategyPartConstructor () { } function setFloatingObjectBasicProperties (floatingObject, payload) { - const FRICTION = 0.97 + const FRICTION = 0.98 switch (payload.node.type) { case 'Trading System': { @@ -1078,7 +1078,7 @@ function newStrategyPartConstructor () { break } case 'Phase': { - level_4() + level_2() break } case 'Formula': { @@ -1128,7 +1128,7 @@ function newStrategyPartConstructor () { function level_2 () { floatingObject.friction = FRICTION - floatingObject.initializeMass(50) + floatingObject.initializeMass(100) floatingObject.initializeRadius(40) floatingObject.initializeImageSize(70) floatingObject.initializeFontSize(10) diff --git a/StrategySpace/Workspace/FunctionLibraries/NodeDeleter.js b/StrategySpace/Workspace/FunctionLibraries/NodeDeleter.js index 82dddfb0f..e449a3ace 100644 --- a/StrategySpace/Workspace/FunctionLibraries/NodeDeleter.js +++ b/StrategySpace/Workspace/FunctionLibraries/NodeDeleter.js @@ -181,32 +181,29 @@ function newNodeDeleter () { for (let k = 0; k < payload.parentNode.phases.length; k++) { let phase = payload.parentNode.phases[k] if (phase.id === node.id) { - while (phase.situations.length > 0) { - let situation = phase.situations[0] - deleteSituation(situation) - } - phase.situations = [] /* Before deleting this phase we need to give its chainParent to the next phase down the chain */ if (k < payload.parentNode.phases.length - 1) { payload.parentNode.phases[k + 1].payload.chainParent = payload.chainParent } /* Continue destroying this phase */ payload.parentNode.phases.splice(k, 1) - destroyPart(phase) - cleanNode(phase) - return } } } else { - while (node.situations.length > 0) { - let situation = node.situations[0] - deleteSituation(situation) - } - node.situations = [] completeDeletion(node, rootNodes) - destroyPart(node) - cleanNode(node) } + + while (node.situations.length > 0) { + let situation = node.situations[0] + deleteSituation(situation) + } + node.situations = [] + + if (node.formula !== undefined) { + deleteFormula(node.formula, rootNodes) + } + destroyPart(node) + cleanNode(node) } function deleteFormula (node, rootNodes) { @@ -257,16 +254,16 @@ function newNodeDeleter () { let condition = payload.parentNode.conditions[i] if (condition.id === node.id) { payload.parentNode.conditions.splice(i, 1) - destroyPart(node) - cleanNode(condition) - return } } } else { completeDeletion(node, rootNodes) - destroyPart(node) - cleanNode(node) } + if (node.code !== undefined) { + deleteCode(node.code, rootNodes) + } + destroyPart(node) + cleanNode(node) } function deleteCode (node, rootNodes) { diff --git a/StrategySpace/Workspace/Workspace.js b/StrategySpace/Workspace/Workspace.js index 37b31e8ba..f4603106f 100644 --- a/StrategySpace/Workspace/Workspace.js +++ b/StrategySpace/Workspace/Workspace.js @@ -114,7 +114,7 @@ function newWorkspace () { rootNodes: stringifyReadyNodes } let textToSave = JSON.stringify(workspace) - window.localStorage.setItem('workspace', textToSave) + // window.localStorage.setItem('workspace', textToSave) } function spawn (nodeText, point) {