From 08f96ef00c34340fe298757f7123445b4a36a038 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sun, 10 Apr 2016 21:39:16 +0200 Subject: Handle initial stopped path --- src/ch/epfl/xblast/server/GameState.java | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/ch/epfl/xblast/server/GameState.java b/src/ch/epfl/xblast/server/GameState.java index 2fbea45..364a564 100644 --- a/src/ch/epfl/xblast/server/GameState.java +++ b/src/ch/epfl/xblast/server/GameState.java @@ -203,7 +203,7 @@ public final class GameState { Direction requestedDirection) { // 1. Compute the new path to follow - Sq updatedPath = GameState.nextPath(player0, requestedDirection); + Sq updatedPath = GameState.nextPath(player0.directedPositions(), requestedDirection); // 2. Follow the path if the Player can (moving life state and no collision) Sq directedPos1 = GameState.moveAhead(player0, updatedPath, board1, bombedCells1); @@ -221,30 +221,6 @@ public final class GameState { return p1; } - /** - * Returns the next Direction of the Player according to the constraints. - * - * @param p0 the Player - * @param requestedDir the requested new Direction - * @return the next Direction - */ - private static Direction nextDirection(Player p0, Direction requestedDir) { - return !Objects.isNull(requestedDir) ? requestedDir : p0.direction(); - } - - /** - * Generates the new Sequence of DirectedPositions. - * - * @param p0 the Player - * @param requestedDir the new requested Direction - * @return the next path - */ - private static Sq nextPath(Player p0, Direction requestedDir) { - return GameState.newPath( - p0.directedPositions(), - GameState.nextDirection(p0, requestedDir)); - } - /** * Computes the new path to follow according to the Player's wishes and the Board constraints. * @@ -252,8 +228,8 @@ public final class GameState { * @param newDir the new requested Direction * @return the new path */ - private static Sq newPath(Sq p0, Direction newDir) { - if (newDir == p0.head().direction()) + private static Sq nextPath(Sq p0, Direction newDir) { + if (Objects.isNull(newDir)) return p0; if (p0.head().direction().isPerpendicularTo(newDir)) -- cgit v1.2.3