Skip to content

Commit

Permalink
- Reldens - v4.0.0 - Implement initial position threshold on player s…
Browse files Browse the repository at this point in the history
…tate randomizer.
  • Loading branch information
damian-pastorini committed Oct 22, 2024
1 parent 9bef68c commit 874e39e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/rooms/server/random-player-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class RandomPlayerState
this.tileHeight = room.roomWorld.mapJson.tileheight;
this.grid = room.roomWorld.pathFinder.grid;
this.always = room.joinInRandomPlaceAlways;
this.initialPositionThreshold = 50;
this.roomInitialPoint = {
x: room.roomData.returnPointDefault[RoomsConst.RETURN_POINT_KEYS.X],
y: room.roomData.returnPointDefault[RoomsConst.RETURN_POINT_KEYS.Y]
Expand Down Expand Up @@ -51,7 +52,14 @@ class RandomPlayerState

playerPositionIsRoomStartingPoint(currentPlayer)
{
return currentPlayer.state.x === this.roomInitialPoint.x && currentPlayer.state.y === this.roomInitialPoint.y;
let roomMaxX = this.roomInitialPoint.x + this.initialPositionThreshold;
let roomMinX = this.roomInitialPoint.x - this.initialPositionThreshold;
let roomMaxY = this.roomInitialPoint.y + this.initialPositionThreshold;
let roomMinY = this.roomInitialPoint.y - this.initialPositionThreshold;
return currentPlayer.state.x < roomMaxX
&& currentPlayer.state.y < roomMaxY
&& currentPlayer.state.x > roomMinX
&& currentPlayer.state.y > roomMinY;
}
}

Expand Down

0 comments on commit 874e39e

Please sign in to comment.