Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions backend/src/main/java/adg/processing/ProcessOnMove.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,12 @@ private boolean startTileIsBlockedByOwnPawn(PositionKey startTile) {
&& board.cannotMoveToTileBecauseSamePlayer(pawn1, startTile);
}

/** Three steps back, then the blockade turns the pawn around for its last step. */
private void landBeyondBlockadedStartTile() {
if (gs.isExactMoveRequired()) {
reject(CANNOT_MAKE_MOVE, MoveRejectionReason.CANNOT_PASS_START_TILE);
return;
}
PositionKey tile2 = new PositionKey(playerIdOfTile, 2);
if (board.canMoveToTile(pawn1, tile2)) {
landOnTile(tile2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,25 @@ void backwardMove_BlockedByOccupiedStartTile_CannotMove() {
assertEquals(new PositionKey("1", 2), gameState.getPawn(pawn1).getCurrentTileId());
}

@Test
void backwardMove_LandingExactlyOnBlockedStartTile_CannotMove() {
// pawn at (1,4) - 4 steps → would land exactly on (1,0), but player1's pawn blocks it
// → without setting: three steps back, turns around, one step forward to (1,2)
// GIVEN
Card card = givePlayerCard(cardsDeck, 0, -4);
Pawn pawn1 = placePawnOnNest(gameState, "0", new PositionKey("1", 4));
Pawn blocker = placePawnOnNest(gameState, "1", new PositionKey("1", 0));

// WHEN
createMoveRequest(moveMessage, pawn1, card);
ProcessOnMove.process(gameState, moveMessage, moveResponse);

// THEN
assertEquals(CANNOT_MAKE_MOVE, moveResponse.getResult());
assertNull(moveResponse.getPawn1());
assertEquals(new PositionKey("1", 4), gameState.getPawn(pawn1).getCurrentTileId());
}

@Test
void backwardMove_BlockedByOwnOccupiedStartTile_CannotMove() {
// pawn at (0,3) - 5 steps → wants to cross through (0,0), but player0's own pawn blocks it
Expand Down
Loading