@@ 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);
}