lib/tunnel.js
// find the location near the tunnelEndpoint to build the room door. (ideally centered in tunnel)
find the location near the tunnelEndpoint to build the room door. (ideally centered in tunnel)
find the location near the tunnelEndpoint to build the room door . ( ideally centered in tunnel )
_getDoorPosition(room, tunnelDirection) {
    const squares = this._findSquares(tunnelDirection)
    const centerIdx = Math.floor(this.tunnelWidth/2)
    const center = squares[centerIdx]
    removeItems(squares, centerIdx, 1)
    squares.unshift(center)
    for (let square of Array.from(squares)) {
      const doorTouchesRoom = overlaps(room, square)
      if (doorTouchesRoom && (!room.isCornerPoint(square.x, square.y))) {
        square.width = 1
        square.height = 1
        return square
      }
    }
    return null
  }
_getDoorPosition ( room , tunnelDirection ) { const squares = this . _findSquares ( tunnelDirection ) const centerIdx = Math . floor ( this . tunnelWidth / 2 ) const center = squares [ centerIdx ] removeItems ( squares , centerIdx , 1 ) squares . unshift ( center ) for ( let square of Array . from ( squares ) ) { const doorTouchesRoom = overlaps ( room , square ) if ( doorTouchesRoom && ( ! room . isCornerPoint ( square . x , square . y ) ) ) { square . width = 1 square . height = 1 return square } } return null }
find the location near the tunnelEndpoint to build the room door.
find the location near the tunnelEndpoint to build the room door .
// find all squares along the tunnel edge to potentially place a door at // prefer to center the door in tunnel if possible, so move the square that // represents tunnel center point to the front of the list to check