aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimothée Floure2016-03-07 15:27:00 +0100
committerTimothée Floure2016-03-07 15:27:00 +0100
commit0b7d819060a6e954d156e155c5329b2c3577f8d3 (patch)
tree34aec23de32a6b1c50a8eb5725be702dbf794ffa /src
parentb2271f5f8355f74fb1e7c23357fb22059aa02701 (diff)
downloadxblast-0b7d819060a6e954d156e155c5329b2c3577f8d3.tar.gz
Fix the Bomb & Player secondary builder
Diffstat (limited to 'src')
-rw-r--r--src/ch/epfl/xblast/server/Bomb.java4
-rw-r--r--src/ch/epfl/xblast/server/Player.java7
2 files changed, 5 insertions, 6 deletions
diff --git a/src/ch/epfl/xblast/server/Bomb.java b/src/ch/epfl/xblast/server/Bomb.java
index 3f49f64..38bd4c5 100644
--- a/src/ch/epfl/xblast/server/Bomb.java
+++ b/src/ch/epfl/xblast/server/Bomb.java
@@ -58,14 +58,12 @@ public final class Bomb {
58 * @throws NullPointerException if ownerId, position or fuseLengths is null 58 * @throws NullPointerException if ownerId, position or fuseLengths is null
59 */ 59 */
60 public Bomb(PlayerID ownerId, Cell position, int fuseLength, int range) { 60 public Bomb(PlayerID ownerId, Cell position, int fuseLength, int range) {
61 this.ownerId = Objects.requireNonNull(ownerId);
62 this.position = Objects.requireNonNull(position);
63 if (fuseLength == 0) { 61 if (fuseLength == 0) {
64 throw new IllegalArgumentException(); 62 throw new IllegalArgumentException();
65 } else { 63 } else {
66 fuseLengths = Sq.iterate(fuseLength, fuseLengths -> fuseLength - 1 ); 64 fuseLengths = Sq.iterate(fuseLength, fuseLengths -> fuseLength - 1 );
67 } 65 }
68 this.range = ArgumentChecker.requireNonNegative(range); 66 this.Bomb(ownerId, position, fuseLengths, range);
69 } 67 }
70 68
71 /** 69 /**
diff --git a/src/ch/epfl/xblast/server/Player.java b/src/ch/epfl/xblast/server/Player.java
index b3ae851..57a280a 100644
--- a/src/ch/epfl/xblast/server/Player.java
+++ b/src/ch/epfl/xblast/server/Player.java
@@ -166,13 +166,14 @@ public final class Player {
166 */ 166 */
167 public Player(PlayerID id, int lives, Cell position, int maxBombs, int bombRange) { 167 public Player(PlayerID id, int lives, Cell position, int maxBombs, int bombRange) {
168 this.id = Objects.requireNonNull(id); 168 this.id = Objects.requireNonNull(id);
169 DirectedPosition newDirectedPos = new DirectedPosition(SubCell.centralSubCellOf(Objects.requireNonNull(position)), Direction.S); 169 DirectedPosition newDirectedPosition = new DirectedPosition(SubCell.centralSubCellOf(Objects.requireNonNull(position)), Direction.S);
170 this.directedPos = DirectedPosition.stopped(newDirectedPos); 170 DirectedPosition directedPositionSequence = DirectedPosition.stopped(newDirectedPos);
171 LifeState invulnerability = new LifeState(ArgumentChecker.requireNonNegative(lives), LifeState.State.INVULNERABLE); 171 LifeState invulnerability = new LifeState(ArgumentChecker.requireNonNegative(lives), LifeState.State.INVULNERABLE);
172 LifeState vulnerability = new LifeState(ArgumentChecker.requireNonNegative(lives), LifeState.State.VULNERABLE); 172 LifeState vulnerability = new LifeState(ArgumentChecker.requireNonNegative(lives), LifeState.State.VULNERABLE);
173 this.lifeStates = Sq.repeat(Ticks.PLAYER_INVULNERABLE_TICKS,invulnerability).concat(Sq.constant(vulnerability)); 173 Sq<LifeState> lifeStateSequence = Sq.repeat(Ticks.PLAYER_INVULNERABLE_TICKS,invulnerability).concat(Sq.constant(vulnerability));
174 this.maxBombs = ArgumentChecker.requireNonNegative(maxBombs); 174 this.maxBombs = ArgumentChecker.requireNonNegative(maxBombs);
175 this.bombRange = ArgumentChecker.requireNonNegative(bombRange); 175 this.bombRange = ArgumentChecker.requireNonNegative(bombRange);
176 this.Player(id, lifeStateSequence,directedPositionSequence, maxBombs, bombRange);
176 } 177 }
177 178
178 /** 179 /**