// Copyright (c) 2023, Sam Hadow // //path_to_string.js // // This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. // // You should have received a copy of the GNU General Public License along with this program. If not, see . function path_to_string(path, edges, nodes) { // convert path (with only edges and nodes id) to a human-readable string let current = null; let string = '' for (let i = 0; i < path.length; i++){ current = edges.find(edge => edge.id === path[i][1]); if (current.type == "very easy" || current.type == "easy" || current.type == "difficult" || current.type == "very difficult" ){ string += i+1 +') Descendez la piste: ' + current.name + '
'; } else if (current.type == "surface lift") { string += i+1 +') Prenez le téléski: ' + current.name + '
'; } else if (current.type == "gondola") { string += i+1 +') Prenez la télécabine: ' + current.name + '
'; } else if (current.type == "cable car") { string += i+1 +') Prenez le téléphérique: ' + current.name + '
'; } else if (current.type == "chairlift") { string += i+1 +') Prenez le télésiège: ' + current.name + '
'; } else if (current.type == "high speed chairlift") { string += i+1 +') Prenez le télésiège express débrayable: ' + current.name + '
'; } else if (current.type == "path") { direction = nodes.find(node => node.id === current.target).name; if (direction != '') { string += i+1 +') Prenez le chemin en direction de: ' + direction + '
'; } else { string += i+1 +') Prenez un chemin
'; } } else if (current.type == "free lift") { string += i+1 +') Prenez la remontée mécanique gratuite: ' + current.name + '
'; } } return string }