aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2016-04-15 10:50:29 +0200
committerPacien TRAN-GIRARD2016-04-15 10:50:29 +0200
commit64498b20f7865a373fdad3ab6c3b61202208ae41 (patch)
treed843784fe08f0994c3fe2c6933f36ca3556a85e6
parent5b5071a54d431f03fee6c3acdae5dc980b2480b8 (diff)
downloadxblast-64498b20f7865a373fdad3ab6c3b61202208ae41.tar.gz
Apply damages according to current position instead of future position
-rw-r--r--src/ch/epfl/xblast/server/GameState.java13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/ch/epfl/xblast/server/GameState.java b/src/ch/epfl/xblast/server/GameState.java
index ece12ed..4c30235 100644
--- a/src/ch/epfl/xblast/server/GameState.java
+++ b/src/ch/epfl/xblast/server/GameState.java
@@ -208,7 +208,7 @@ public final class GameState {
208 Sq<Player.DirectedPosition> directedPos1 = GameState.moveAhead(player0, updatedPath, board1, bombedCells1); 208 Sq<Player.DirectedPosition> directedPos1 = GameState.moveAhead(player0, updatedPath, board1, bombedCells1);
209 209
210 // 3. Apply damages and generate a new LifeState Sequence 210 // 3. Apply damages and generate a new LifeState Sequence
211 Sq<Player.LifeState> lifeStates1 = GameState.nextLifeState(player0, directedPos1, blastedCells1); 211 Sq<Player.LifeState> lifeStates1 = GameState.nextLifeState(player0, blastedCells1);
212 212
213 // 4. Create the new player given the new parameters 213 // 4. Create the new player given the new parameters
214 Player p1 = new Player(player0.id(), lifeStates1, directedPos1, player0.maxBombs(), player0.bombRange()); 214 Player p1 = new Player(player0.id(), lifeStates1, directedPos1, player0.maxBombs(), player0.bombRange());
@@ -336,15 +336,12 @@ public final class GameState {
336 /** 336 /**
337 * Applies damages and generate a new LifeState sequence. 337 * Applies damages and generate a new LifeState sequence.
338 * 338 *
339 * @param player0 the Player 339 * @param player0 the Player
340 * @param directedPositions1 the DirectedPosition sequence 340 * @param blastedCells1 the Set of blasted Cell-s
341 * @param blastedCells1 the Set of blasted Cell-s
342 * @return the next LifeState sequence 341 * @return the next LifeState sequence
343 */ 342 */
344 private static Sq<Player.LifeState> nextLifeState(Player player0, Sq<Player.DirectedPosition> directedPositions1, 343 private static Sq<Player.LifeState> nextLifeState(Player player0, Set<Cell> blastedCells1) {
345 Set<Cell> blastedCells1) { 344 Cell currentCell = player0.position().containingCell();
346
347 Cell currentCell = directedPositions1.head().position().containingCell();
348 345
349 if (player0.isVulnerable() && blastedCells1.contains(currentCell)) 346 if (player0.isVulnerable() && blastedCells1.contains(currentCell))
350 return player0.statesForNextLife(); 347 return player0.statesForNextLife();