LCOV - code coverage report
Current view: top level - maps/random/rmgen/placer/noncentered - HeightPlacer.js (source / functions) Coverage Total Hit
Test: lcov.info Lines: 33.3 % 15 5
Test Date: 2026-11-22 03:02:19 Functions: 0.0 % 7 0

            Line data    Source code
       1              : /**
       2              :  * HeightPlacer constants determining whether the extrema should be included by the placer too.
       3              :  */
       4            7 : const Elevation_ExcludeMin_ExcludeMax = 0;
       5            7 : const Elevation_IncludeMin_ExcludeMax = 1;
       6            7 : const Elevation_ExcludeMin_IncludeMax = 2;
       7            7 : const Elevation_IncludeMin_IncludeMax = 3;
       8              : 
       9              : /**
      10              :  * The HeightPlacer provides all points between the minimum and maximum elevation that meet the Constraint,
      11              :  * even if they are far from the passable area of the map.
      12              :  */
      13              : function HeightPlacer(mode, minElevation, maxElevation)
      14              : {
      15            0 :         this.withinHeightRange =
      16            0 :                 mode == Elevation_ExcludeMin_ExcludeMax ? position => g_Map.getHeight(position) > minElevation && g_Map.getHeight(position) < maxElevation :
      17            0 :                         mode == Elevation_IncludeMin_ExcludeMax ? position => g_Map.getHeight(position) >= minElevation && g_Map.getHeight(position) < maxElevation :
      18            0 :                                 mode == Elevation_ExcludeMin_IncludeMax ? position => g_Map.getHeight(position) > minElevation && g_Map.getHeight(position) <= maxElevation :
      19            0 :                                         mode == Elevation_IncludeMin_IncludeMax ? position => g_Map.getHeight(position) >= minElevation && g_Map.getHeight(position) <= maxElevation :
      20              :                                                 undefined;
      21              : 
      22            0 :         if (!this.withinHeightRange)
      23            0 :                 throw new Error("Invalid HeightPlacer mode: " + mode);
      24              : }
      25              : 
      26            7 : HeightPlacer.prototype.place = function(constraint)
      27              : {
      28            0 :         const mapSize = g_Map.getSize();
      29              : 
      30            0 :         return getPointsInBoundingBox(getBoundingBox([new Vector2D(0, 0), new Vector2D(mapSize - 1, mapSize - 1)])).filter(
      31            0 :                 point => this.withinHeightRange(point) && constraint.allows(point));
      32              : };
        

Generated by: LCOV version 2.0-1