From 5ce568410c3395667b5d1ac41dfb084044d87fb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n?= <58742147+dip000@users.noreply.github.com> Date: Sun, 13 Feb 2022 18:35:02 -0600 Subject: [PATCH] multi maps with cut system --- MapBuilderForWeb/MultimapMechanics.js | 104 ++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 MapBuilderForWeb/MultimapMechanics.js diff --git a/MapBuilderForWeb/MultimapMechanics.js b/MapBuilderForWeb/MultimapMechanics.js new file mode 100644 index 0000000..6cac94d --- /dev/null +++ b/MapBuilderForWeb/MultimapMechanics.js @@ -0,0 +1,104 @@ + + var cutsMap; + var nrows=1, ncols=1; + + function map(x, y){ + if(x == 0 || y == 0) + return; + + if( !AskForReset() ) return; + + initializeMapEditorGrid(x, y); + } + + function rows(numberOfRows){ + + + UpdateCutsMap(TARGET_ROWS, nrows, JOIN); + UpdateCutsMap(TARGET_ROWS, numberOfRows, CUT); + + UpdateCutsMap(TARGET_COLS, ncols, CUT); + nrows = numberOfRows; + } + + function cols(numberOfCols){ + + UpdateCutsMap(TARGET_COLS, ncols, JOIN); + UpdateCutsMap(TARGET_COLS, numberOfCols, CUT); + + UpdateCutsMap(TARGET_ROWS, nrows, CUT); + ncols = numberOfCols; + } + + + const TARGET_ROWS = true; + const TARGET_COLS = false; + const CUT = true; + const JOIN = false; + + function UpdateCutsMap(target, numberOfSuch, state){ + let x, y; + let mapLengthB, mapLengthA; + + if(target == TARGET_ROWS){ + mapLengthA = occupancyMap.length; + mapLengthB = occupancyMap[0].length; + } + else{ + mapLengthB = occupancyMap.length; + mapLengthA = occupancyMap[0].length; + } + + let increment = mapLengthA / numberOfSuch; + let incrementRounded = Math.round( increment ); + + if(numberOfSuch <= 0){ + console.log("Cannot make that few"); + return; + } + if(numberOfSuch > Math.round( mapLengthA/2 )){ + console.log("Cannot make that many"); + return; + } + + + + for(let i=0; i