From 69ec741acb840c444471579d53aafd94eae80795 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Mon, 7 Mar 2016 17:08:07 +0100 Subject: Reformat code --- src/ch/epfl/xblast/ArgumentChecker.java | 4 ++- src/ch/epfl/xblast/PlayerID.java | 2 ++ src/ch/epfl/xblast/server/Bomb.java | 32 +++++++++++--------- src/ch/epfl/xblast/server/Player.java | 52 +++++++++++++++++---------------- 4 files changed, 50 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/ch/epfl/xblast/ArgumentChecker.java b/src/ch/epfl/xblast/ArgumentChecker.java index a567fbb..311807e 100644 --- a/src/ch/epfl/xblast/ArgumentChecker.java +++ b/src/ch/epfl/xblast/ArgumentChecker.java @@ -7,12 +7,13 @@ package ch.epfl.xblast; * @author Timothée FLOURE (257420) */ public final class ArgumentChecker { + /** * Returns the given value if it is non-negative. * * @param value the tested value - * @throws IllegalArgumentException if the value is inferior to 0 * @return the given value if non-negative + * @throws IllegalArgumentException if the value is inferior to 0 */ public static int requireNonNegative(int value) { if (value >= 0) { @@ -21,4 +22,5 @@ public final class ArgumentChecker { throw new IllegalArgumentException(); } } + } diff --git a/src/ch/epfl/xblast/PlayerID.java b/src/ch/epfl/xblast/PlayerID.java index bb77405..c2c5c58 100644 --- a/src/ch/epfl/xblast/PlayerID.java +++ b/src/ch/epfl/xblast/PlayerID.java @@ -7,8 +7,10 @@ package ch.epfl.xblast; * @author Timothée FLOURE (257420) */ public enum PlayerID { + PLAYER_1, PLAYER_2, PLAYER_3, PLAYER_4 + } diff --git a/src/ch/epfl/xblast/server/Bomb.java b/src/ch/epfl/xblast/server/Bomb.java index 4b89752..12e8888 100644 --- a/src/ch/epfl/xblast/server/Bomb.java +++ b/src/ch/epfl/xblast/server/Bomb.java @@ -1,14 +1,14 @@ package ch.epfl.xblast.server; -import ch.epfl.xblast.PlayerID; -import ch.epfl.xblast.Cell; import ch.epfl.cs108.Sq; import ch.epfl.xblast.ArgumentChecker; +import ch.epfl.xblast.Cell; import ch.epfl.xblast.Direction; +import ch.epfl.xblast.PlayerID; -import java.util.Objects; -import java.util.List; import java.util.ArrayList; +import java.util.List; +import java.util.Objects; /** * A Bomb. @@ -17,6 +17,7 @@ import java.util.ArrayList; * @author Timothée FLOURE (257420) */ public final class Bomb { + private PlayerID ownerId; private Cell position; private Sq fuseLengths; @@ -26,18 +27,20 @@ public final class Bomb { * Generates one arm of explosion. */ private Sq> explosionArmTowards(Direction dir) { - return Sq.constant( Sq.iterate(position, position -> position.neighbor(dir)).limit(range)).limit(Ticks.EXPLOSION_TICKS); + return Sq + .constant(Sq.iterate(position, position -> position.neighbor(dir)).limit(range)) + .limit(Ticks.EXPLOSION_TICKS); } /** * Instantiates a new Bomb. * - * @param ownerId id of the owner of the bomb - * @param position position of the bomb + * @param ownerId id of the owner of the bomb + * @param position position of the bomb * @param fuseLengths length of the bomb's fuse - * @param range range of the bomb + * @param range range of the bomb * @throws IllegalArgumentException if range is negative or fuseLenghts is empty - * @throws NullPointerException if ownerId, position or fuseLengths is null + * @throws NullPointerException if ownerId, position or fuseLengths is null */ public Bomb(PlayerID ownerId, Cell position, Sq fuseLengths, int range) { this.ownerId = Objects.requireNonNull(ownerId); @@ -53,15 +56,15 @@ public final class Bomb { /** * Instantiates a new Bomb. * - * @param ownerId id of the owner of the bomb - * @param position position of the bomb + * @param ownerId id of the owner of the bomb + * @param position position of the bomb * @param fuseLength length of the bomb's fuse - * @param range range of the bomb + * @param range range of the bomb * @throws IllegalArgumentException if range or fuseLengths is negative - * @throws NullPointerException if ownerId, position or fuseLengths is null + * @throws NullPointerException if ownerId, position or fuseLengths is null */ public Bomb(PlayerID ownerId, Cell position, int fuseLength, int range) { - this(ownerId, position, Sq.iterate(fuseLength, fl -> fl - 1 ), range); + this(ownerId, position, Sq.iterate(fuseLength, fl -> fl - 1), range); } /** @@ -109,4 +112,5 @@ public final class Bomb { } return explosion; } + } diff --git a/src/ch/epfl/xblast/server/Player.java b/src/ch/epfl/xblast/server/Player.java index 0548125..7b5ac26 100644 --- a/src/ch/epfl/xblast/server/Player.java +++ b/src/ch/epfl/xblast/server/Player.java @@ -1,11 +1,7 @@ package ch.epfl.xblast.server; -import ch.epfl.xblast.ArgumentChecker; -import ch.epfl.xblast.Direction; -import ch.epfl.xblast.Cell; -import ch.epfl.xblast.SubCell; -import ch.epfl.xblast.PlayerID; import ch.epfl.cs108.Sq; +import ch.epfl.xblast.*; import java.util.Objects; @@ -16,10 +12,12 @@ import java.util.Objects; * @author Timothée FLOURE (257420) */ public final class Player { + /** * The life state of a player. */ public static final class LifeState { + /** * Enum containing all the possible life states. */ @@ -65,13 +63,15 @@ public final class Player { public boolean canMove() { return (state() == State.INVULNERABLE || state() == State.VULNERABLE); } + } /** * The "directed" position of a player. */ public static final class DirectedPosition { - private final SubCell position; + + private final SubCell position; private final Direction direction; /** @@ -91,7 +91,7 @@ public final class Player { /** * Instantiates a new DirectedPos * - * @param position the position of the player + * @param position the position of the player * @param direction the direction of the player * @throws IllegalArgumentException if position or direction is null */ @@ -122,11 +122,12 @@ public final class Player { } /** - * @return a new directed position with the previous position and the given direction + * @return a new directed position with the previous position and the given direction */ public DirectedPosition withDirection(Direction newDirection) { return new DirectedPosition(position, newDirection); } + } /** @@ -156,7 +157,7 @@ public final class Player { LifeState.State.VULNERABLE ); - return Sq.repeat(Ticks.PLAYER_INVULNERABLE_TICKS,invulnerability).concat(Sq.constant(vulnerability)); + return Sq.repeat(Ticks.PLAYER_INVULNERABLE_TICKS, invulnerability).concat(Sq.constant(vulnerability)); } /** @@ -177,11 +178,11 @@ public final class Player { /** * Instantiates a new Player. * - * @param id the Player's id - * @param lifeStates a sequence of LifeState-s + * @param id the Player's id + * @param lifeStates a sequence of LifeState-s * @param directedPos a sequence of DirectedPosition-s - * @param maxBombs the maximum number of Bomb-s the Player can carry - * @param bombRange the range of the Bomb-s + * @param maxBombs the maximum number of Bomb-s the Player can carry + * @param bombRange the range of the Bomb-s * @throws IllegalArgumentException * @throws NullPointerException */ @@ -196,22 +197,22 @@ public final class Player { /** * Instantiates a new Player. * - * @param id the Player's id - * @param lives the number of lives of the Player - * @param position the starting position of the Player - * @param maxBombs the maximum number of Bomb-s the Player can carry + * @param id the Player's id + * @param lives the number of lives of the Player + * @param position the starting position of the Player + * @param maxBombs the maximum number of Bomb-s the Player can carry * @param bombRange the range of the Bomb-s * @throws IllegalArgumentException * @throws NullPointerException */ public Player(PlayerID id, int lives, Cell position, int maxBombs, int bombRange) { - this( - id, - Player.buildDefaultLifeStateSequence(lives), - Player.buildDefaultDirectedPositionSequence(position), - maxBombs, - bombRange - ); + this( + id, + Player.buildDefaultLifeStateSequence(lives), + Player.buildDefaultDirectedPositionSequence(position), + maxBombs, + bombRange + ); } /** @@ -244,7 +245,7 @@ public final class Player { LifeState invulnerable = new LifeState(newLives, LifeState.State.INVULNERABLE); LifeState vulnerable = new LifeState(newLives, LifeState.State.VULNERABLE); - nextLifeState = nextLifeState.concat(Sq.repeat(Ticks.PLAYER_INVULNERABLE_TICKS,invulnerable)); + nextLifeState = nextLifeState.concat(Sq.repeat(Ticks.PLAYER_INVULNERABLE_TICKS, invulnerable)); nextLifeState = nextLifeState.concat(Sq.constant(vulnerable)); } @@ -327,4 +328,5 @@ public final class Player { public Bomb newBomb() { return new Bomb(id, position().containingCell(), Ticks.BOMB_FUSE_TICKS, bombRange); } + } -- cgit v1.2.3