diff options
-rw-r--r-- | src/ch/epfl/xblast/server/Bomb.java | 4 | ||||
-rw-r--r-- | src/ch/epfl/xblast/server/Player.java | 7 |
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 | /** |