diff options
author | Pacien TRAN-GIRARD | 2016-04-15 11:50:09 +0200 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2016-04-15 11:50:09 +0200 |
commit | aaad994749b1096aa77e18ff32717fa4061270d8 (patch) | |
tree | 853b900bbbf175b8cdc78d57b7d70e96837d3298 | |
parent | 36e3b47ec524cd305e1a605a2736721fea308f17 (diff) | |
download | xblast-aaad994749b1096aa77e18ff32717fa4061270d8.tar.gz |
Use last pivot direction for stopped path
-rw-r--r-- | src/ch/epfl/xblast/server/GameState.java | 15 |
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; |