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

          Line data    Source code
       1             : /**
       2             :  * HeightPlacer constants determining whether the extrema should be included by the placer too.
       3             :  */
       4           6 : const Elevation_ExcludeMin_ExcludeMax = 0;
       5           6 : const Elevation_IncludeMin_ExcludeMax = 1;
       6           6 : const Elevation_ExcludeMin_IncludeMax = 2;
       7           6 : 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           6 : HeightPlacer.prototype.place = function(constraint)
      27             : {
      28           0 :         let 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 1.14