aboutsummaryrefslogtreecommitdiff
path: root/src/ch/epfl
diff options
context:
space:
mode:
Diffstat (limited to 'src/ch/epfl')
-rw-r--r--src/ch/epfl/xblast/server/GameState.java15
1 files 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 {
247 * @return the stop path 247 * @return the stop path
248 */ 248 */
249 private static Sq<Player.DirectedPosition> stopPath(Sq<Player.DirectedPosition> p0) { 249 private static Sq<Player.DirectedPosition> stopPath(Sq<Player.DirectedPosition> p0) {
250 SubCell nextCentral = GameState.nextCentralPosition(p0);
251 Direction currentDir = p0.head().direction();
252
253 return GameState 250 return GameState
254 .pathToNextCentralPosition(p0) 251 .pathToNextCentralPosition(p0)
255 .concat(Player.DirectedPosition.stopped(new Player.DirectedPosition(nextCentral, currentDir))); 252 .concat(Player.DirectedPosition.stopped(GameState.nextCentral(p0)));
256 } 253 }
257 254
258 /** 255 /**
@@ -263,11 +260,11 @@ public final class GameState {
263 * @return the pivot path 260 * @return the pivot path
264 */ 261 */
265 private static Sq<Player.DirectedPosition> pivotPath(Sq<Player.DirectedPosition> p0, Direction newDir) { 262 private static Sq<Player.DirectedPosition> pivotPath(Sq<Player.DirectedPosition> p0, Direction newDir) {
266 SubCell nextCentral = GameState.nextCentralPosition(p0); 263 SubCell nextCentralPos = GameState.nextCentral(p0).position();
267 264
268 return GameState 265 return GameState
269 .pathToNextCentralPosition(p0) 266 .pathToNextCentralPosition(p0)
270 .concat(Player.DirectedPosition.moving(new Player.DirectedPosition(nextCentral, newDir))); 267 .concat(Player.DirectedPosition.moving(new Player.DirectedPosition(nextCentralPos, newDir)));
271 } 268 }
272 269
273 /** 270 /**
@@ -286,8 +283,8 @@ public final class GameState {
286 * @param p the path to follow 283 * @param p the path to follow
287 * @return the next central SubCell 284 * @return the next central SubCell
288 */ 285 */
289 private static SubCell nextCentralPosition(Sq<Player.DirectedPosition> p) { 286 private static Player.DirectedPosition nextCentral(Sq<Player.DirectedPosition> p) {
290 return p.findFirst(dp -> dp.position().isCentral()).position(); 287 return p.findFirst(dp -> dp.position().isCentral());
291 } 288 }
292 289
293 /** 290 /**
@@ -321,7 +318,7 @@ public final class GameState {
321 */ 318 */
322 private static boolean isColliding(Sq<Player.DirectedPosition> path, Board board1, Set<Cell> bombedCells1) { 319 private static boolean isColliding(Sq<Player.DirectedPosition> path, Board board1, Set<Cell> bombedCells1) {
323 SubCell nextPos = path.tail().head().position(); 320 SubCell nextPos = path.tail().head().position();
324 SubCell nextCentralPos = GameState.nextCentralPosition(Player.DirectedPosition.moving(path.tail().head())); 321 SubCell nextCentralPos = GameState.nextCentral(Player.DirectedPosition.moving(path.tail().head())).position();
325 322
326 if (!board1.blockAt(nextCentralPos.containingCell()).canHostPlayer()) 323 if (!board1.blockAt(nextCentralPos.containingCell()).canHostPlayer())
327 return true; 324 return true;