From aaad994749b1096aa77e18ff32717fa4061270d8 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Fri, 15 Apr 2016 11:50:09 +0200 Subject: Use last pivot direction for stopped path --- src/ch/epfl/xblast/server/GameState.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/ch/epfl/xblast/server/GameState.java b/src/ch/epfl/xblast/server/GameState.java index 7d94c69..e7a053b 100644 --- a/src/ch/epfl/xblast/server/GameState.java +++ b/src/ch/epfl/xblast/server/GameState.java @@ -247,12 +247,9 @@ public final class GameState { * @return the stop path */ private static Sq stopPath(Sq p0) { - SubCell nextCentral = GameState.nextCentralPosition(p0); - Direction currentDir = p0.head().direction(); - return GameState .pathToNextCentralPosition(p0) - .concat(Player.DirectedPosition.stopped(new Player.DirectedPosition(nextCentral, currentDir))); + .concat(Player.DirectedPosition.stopped(GameState.nextCentral(p0))); } /** @@ -263,11 +260,11 @@ public final class GameState { * @return the pivot path */ private static Sq pivotPath(Sq p0, Direction newDir) { - SubCell nextCentral = GameState.nextCentralPosition(p0); + SubCell nextCentralPos = GameState.nextCentral(p0).position(); return GameState .pathToNextCentralPosition(p0) - .concat(Player.DirectedPosition.moving(new Player.DirectedPosition(nextCentral, newDir))); + .concat(Player.DirectedPosition.moving(new Player.DirectedPosition(nextCentralPos, newDir))); } /** @@ -286,8 +283,8 @@ public final class GameState { * @param p the path to follow * @return the next central SubCell */ - private static SubCell nextCentralPosition(Sq p) { - return p.findFirst(dp -> dp.position().isCentral()).position(); + private static Player.DirectedPosition nextCentral(Sq p) { + return p.findFirst(dp -> dp.position().isCentral()); } /** @@ -321,7 +318,7 @@ public final class GameState { */ private static boolean isColliding(Sq path, Board board1, Set bombedCells1) { SubCell nextPos = path.tail().head().position(); - SubCell nextCentralPos = GameState.nextCentralPosition(Player.DirectedPosition.moving(path.tail().head())); + SubCell nextCentralPos = GameState.nextCentral(Player.DirectedPosition.moving(path.tail().head())).position(); if (!board1.blockAt(nextCentralPos.containingCell()).canHostPlayer()) return true; -- cgit v1.2.3