From 0b7d819060a6e954d156e155c5329b2c3577f8d3 Mon Sep 17 00:00:00 2001 From: Timothée Floure Date: Mon, 7 Mar 2016 15:27:00 +0100 Subject: Fix the Bomb & Player secondary builder --- src/ch/epfl/xblast/server/Bomb.java | 4 +--- 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 { * @throws NullPointerException if ownerId, position or fuseLengths is null */ public Bomb(PlayerID ownerId, Cell position, int fuseLength, int range) { - this.ownerId = Objects.requireNonNull(ownerId); - this.position = Objects.requireNonNull(position); if (fuseLength == 0) { throw new IllegalArgumentException(); } else { fuseLengths = Sq.iterate(fuseLength, fuseLengths -> fuseLength - 1 ); } - this.range = ArgumentChecker.requireNonNegative(range); + this.Bomb(ownerId, position, fuseLengths, range); } /** 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 { */ public Player(PlayerID id, int lives, Cell position, int maxBombs, int bombRange) { this.id = Objects.requireNonNull(id); - DirectedPosition newDirectedPos = new DirectedPosition(SubCell.centralSubCellOf(Objects.requireNonNull(position)), Direction.S); - this.directedPos = DirectedPosition.stopped(newDirectedPos); + DirectedPosition newDirectedPosition = new DirectedPosition(SubCell.centralSubCellOf(Objects.requireNonNull(position)), Direction.S); + DirectedPosition directedPositionSequence = DirectedPosition.stopped(newDirectedPos); LifeState invulnerability = new LifeState(ArgumentChecker.requireNonNegative(lives), LifeState.State.INVULNERABLE); LifeState vulnerability = new LifeState(ArgumentChecker.requireNonNegative(lives), LifeState.State.VULNERABLE); - this.lifeStates = Sq.repeat(Ticks.PLAYER_INVULNERABLE_TICKS,invulnerability).concat(Sq.constant(vulnerability)); + Sq lifeStateSequence = Sq.repeat(Ticks.PLAYER_INVULNERABLE_TICKS,invulnerability).concat(Sq.constant(vulnerability)); this.maxBombs = ArgumentChecker.requireNonNegative(maxBombs); this.bombRange = ArgumentChecker.requireNonNegative(bombRange); + this.Player(id, lifeStateSequence,directedPositionSequence, maxBombs, bombRange); } /** -- cgit v1.2.3