diff options
Diffstat (limited to 'src/ch/epfl')
-rw-r--r-- | src/ch/epfl/xblast/server/GameState.java | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/ch/epfl/xblast/server/GameState.java b/src/ch/epfl/xblast/server/GameState.java index e133159..61e64f3 100644 --- a/src/ch/epfl/xblast/server/GameState.java +++ b/src/ch/epfl/xblast/server/GameState.java | |||
@@ -232,8 +232,7 @@ public final class GameState { | |||
232 | return p0; | 232 | return p0; |
233 | 233 | ||
234 | if (!newDir.isPresent()) | 234 | if (!newDir.isPresent()) |
235 | // TODO: make this clearer | 235 | return GameState.stopPath(p0); |
236 | return GameState.pathToNextCentralPosition(p0).concat(Player.DirectedPosition.stopped(new Player.DirectedPosition(GameState.nextCentralPosition(p0), p0.head().direction()))); | ||
237 | 236 | ||
238 | if (p0.head().direction().isPerpendicularTo(newDir.get())) | 237 | if (p0.head().direction().isPerpendicularTo(newDir.get())) |
239 | return GameState.pivotPath(Player.DirectedPosition.moving(p0.head()), newDir.get()); | 238 | return GameState.pivotPath(Player.DirectedPosition.moving(p0.head()), newDir.get()); |
@@ -242,6 +241,21 @@ public final class GameState { | |||
242 | } | 241 | } |
243 | 242 | ||
244 | /** | 243 | /** |
244 | * Builds and returns a path stopping at the next central SubCell. | ||
245 | * | ||
246 | * @param p0 the current path | ||
247 | * @return the stop path | ||
248 | */ | ||
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 | ||
254 | .pathToNextCentralPosition(p0) | ||
255 | .concat(Player.DirectedPosition.stopped(new Player.DirectedPosition(nextCentral, currentDir))); | ||
256 | } | ||
257 | |||
258 | /** | ||
245 | * Builds and returns a pivot path reaching the next pivot SubCell and then rotating to the given Direction. | 259 | * Builds and returns a pivot path reaching the next pivot SubCell and then rotating to the given Direction. |
246 | * | 260 | * |
247 | * @param p0 the initial path | 261 | * @param p0 the initial path |