aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ch/epfl/xblast/server/GameState.java18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/ch/epfl/xblast/server/GameState.java b/src/ch/epfl/xblast/server/GameState.java
index 2818f26..7d921ee 100644
--- a/src/ch/epfl/xblast/server/GameState.java
+++ b/src/ch/epfl/xblast/server/GameState.java
@@ -241,7 +241,7 @@ public final class GameState {
241 */ 241 */
242 private static Sq<Player.DirectedPosition> nextPath(Player p0, Direction requestedDir) { 242 private static Sq<Player.DirectedPosition> nextPath(Player p0, Direction requestedDir) {
243 return GameState.newPath( 243 return GameState.newPath(
244 Player.DirectedPosition.moving(p0.directedPositions().head()), 244 p0.directedPositions(),
245 GameState.nextDirection(p0, requestedDir)); 245 GameState.nextDirection(p0, requestedDir));
246 } 246 }
247 247
@@ -253,10 +253,13 @@ public final class GameState {
253 * @return the new path 253 * @return the new path
254 */ 254 */
255 private static Sq<Player.DirectedPosition> newPath(Sq<Player.DirectedPosition> p0, Direction newDir) { 255 private static Sq<Player.DirectedPosition> newPath(Sq<Player.DirectedPosition> p0, Direction newDir) {
256 if (newDir == p0.head().direction())
257 return p0;
258
256 if (p0.head().direction().isPerpendicularTo(newDir)) 259 if (p0.head().direction().isPerpendicularTo(newDir))
257 return GameState.pivotPath(p0, newDir); 260 return GameState.pivotPath(Player.DirectedPosition.moving(p0.head()), newDir);
258 else 261
259 return Player.DirectedPosition.moving(new Player.DirectedPosition(p0.head().position(), newDir)); 262 return Player.DirectedPosition.moving(new Player.DirectedPosition(p0.head().position(), newDir));
260 } 263 }
261 264
262 /** 265 /**
@@ -325,12 +328,13 @@ public final class GameState {
325 */ 328 */
326 private static boolean isColliding(Sq<Player.DirectedPosition> path, Board board1, Set<Cell> bombedCells1) { 329 private static boolean isColliding(Sq<Player.DirectedPosition> path, Board board1, Set<Cell> bombedCells1) {
327 SubCell nextPos = path.tail().head().position(); 330 SubCell nextPos = path.tail().head().position();
328 if (!board1.blockAt(nextPos.containingCell()).canHostPlayer()) 331 SubCell nextCentralPos = GameState.nextCentralPosition(path.tail());
332
333 if (!board1.blockAt(nextCentralPos.containingCell()).canHostPlayer())
329 return true; 334 return true;
330 335
331 SubCell nextCentralPos = GameState.nextCentralPosition(path.tail());
332 if (bombedCells1.contains(nextCentralPos.containingCell())) 336 if (bombedCells1.contains(nextCentralPos.containingCell()))
333 if (nextPos.distanceTo(nextCentralPos) <= Board.BOMB_BLOCKING_DISTANCE) 337 if (nextPos.distanceTo(nextCentralPos) <= Board.BOMB_BLOCKING_DISTANCE + 1)
334 return true; 338 return true;
335 339
336 return false; 340 return false;