~kylep/visual-cell-lang

95826ef9d9765ffc1b1f841fb7d61fe4568283c2 — Kyle Perik 1 year, 7 months ago 2ec4255
Remove data pieces on connection removal
1 files changed, 5 insertions(+), 0 deletions(-)

M src/game.js
M src/game.js => src/game.js +5 -0
@@ 43,6 43,11 @@ export function drawConnection(connection) {

export function removeConnection(connection, gameData, gs) {
  gs.connections.removeChild(connection.g);
  const piecesToRemove = gameData.dataPieces.filter(piece => {
    return piece.connection === connection
  });
  piecesToRemove.forEach(piece => gs.dataPieces.removeChild(piece.g));
  gameData.dataPieces = gameData.dataPieces.filter(piece => !piecesToRemove.includes(piece));
  gameData.connections.splice(gameData.connections.indexOf(connection), 1);
}