aboutsummaryrefslogtreecommitdiff
path: root/src/ch/epfl
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2016-04-14 16:12:01 +0200
committerPacien TRAN-GIRARD2016-04-14 16:14:34 +0200
commit998856f1b93d4bfb561b3424645e33bf86678161 (patch)
treea0e37dcadce1d6b32fbf0a2d00a5a3aff6357b2e /src/ch/epfl
parent97b23f67fbbbd1c1d0f69427ea2a629103146f58 (diff)
downloadxblast-998856f1b93d4bfb561b3424645e33bf86678161.tar.gz
Refactor stop path
Diffstat (limited to 'src/ch/epfl')
-rw-r--r--src/ch/epfl/xblast/server/GameState.java18
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