From 46752822c0904b0cc1ff787f47787dd4bd6f9b6f Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Fri, 8 Apr 2016 19:28:25 +0200 Subject: Elaborate documentation --- src/ch/epfl/xblast/server/Bomb.java | 12 +++++++ src/ch/epfl/xblast/server/GameState.java | 49 +++++++++++++------------ src/ch/epfl/xblast/server/Player.java | 62 ++++++++++++++++++++++++++++---- 3 files changed, 93 insertions(+), 30 deletions(-) (limited to 'src/ch') diff --git a/src/ch/epfl/xblast/server/Bomb.java b/src/ch/epfl/xblast/server/Bomb.java index f32960f..2eacf6c 100644 --- a/src/ch/epfl/xblast/server/Bomb.java +++ b/src/ch/epfl/xblast/server/Bomb.java @@ -69,6 +69,8 @@ public final class Bomb { } /** + * Returns the Bomb's owner ID. + * * @return the ID of the owner of the bomb */ public PlayerID ownerId() { @@ -76,6 +78,8 @@ public final class Bomb { } /** + * Returns the Bomb's position Cell. + * * @return the position of the bomb */ public Cell position() { @@ -83,6 +87,8 @@ public final class Bomb { } /** + * Returns the Bomb's fuse length sequence. + * * @return the length of the fuse */ public Sq fuseLengths() { @@ -90,6 +96,8 @@ public final class Bomb { } /** + * Returns the Bomb's fuse length. + * * @return the remaining time before the explosion */ public int fuseLength() { @@ -97,6 +105,8 @@ public final class Bomb { } /** + * Returns the Bomb's range. + * * @return the range of the Bomb */ public int range() { @@ -104,6 +114,8 @@ public final class Bomb { } /** + * Builds and returns a new explosion sequence. + * * @return the explosion */ public List>> explosion() { diff --git a/src/ch/epfl/xblast/server/GameState.java b/src/ch/epfl/xblast/server/GameState.java index fefaf02..2797e41 100644 --- a/src/ch/epfl/xblast/server/GameState.java +++ b/src/ch/epfl/xblast/server/GameState.java @@ -206,9 +206,9 @@ public final class GameState { /** * Generate the new Sequence of Directed Positions. * - * @param player0 - * @param requestedDirection - * @return + * @param player0 the Player + * @param requestedDirection the requested Direction + * @return the path */ private static Sq nextPath(Player player0, Direction requestedDirection) { if (!player0.lifeState().canMove()) @@ -232,13 +232,13 @@ public final class GameState { } /** - * Check possible collisions and update the Sequence if necessary (kinda ugly right now) + * Checks for possible collisions and update the path if necessary. * - * @param player0 - * @param projectedPath - * @param board1 - * @param bombedCells1 - * @return + * @param player0 the Player + * @param projectedPath the current path projection + * @param board1 the updated Board + * @param bombedCells1 the Set of bombed Cell-s + * @return the corrected path */ private static Sq handleCollisions(Player player0, Sq projectedPath, @@ -253,11 +253,12 @@ public final class GameState { } /** - * @param player0 - * @param projectedPath - * @return + * Computes a projection of the next DirectedPosition. + * + * @param player0 the Player + * @param projectedPath the projected path + * @return the projected next DirectedPosition */ - private static Player.DirectedPosition projectedDirectedPosition(Player player0, Sq projectedPath) { if (!player0.lifeState().canMove()) return new Player.DirectedPosition(player0.position(), player0.direction()); @@ -267,11 +268,13 @@ public final class GameState { } /** - * @param player0 - * @param projectedCell - * @param board1 - * @param bombedCells1 - * @return + * Returns T(the player is colliding with an object). + * + * @param player0 the Player + * @param projectedCell the projected next Cell + * @param board1 the updated Board + * @param bombedCells1 the Set of bombed Cell-s + * @return T(the player is colliding with an object) */ private static boolean isColliding(Player player0, Cell projectedCell, Board board1, Set bombedCells1) { if (!board1.blockAt(projectedCell).canHostPlayer()) @@ -285,12 +288,12 @@ public final class GameState { } /** - * Apply damages and generate a new LifeState Sequence + * Applies damages and generate a new LifeState sequence. * - * @param player0 - * @param directedPositions1 - * @param blastedCells1 - * @return + * @param player0 the Player + * @param directedPositions1 the DirectedPosition sequence + * @param blastedCells1 the Set of blasted Cell-s + * @return the next LifeState sequence */ private static Sq nextLifeState(Player player0, Sq directedPositions1, Set blastedCells1) { diff --git a/src/ch/epfl/xblast/server/Player.java b/src/ch/epfl/xblast/server/Player.java index fdc4715..f6f6c99 100644 --- a/src/ch/epfl/xblast/server/Player.java +++ b/src/ch/epfl/xblast/server/Player.java @@ -44,6 +44,8 @@ public final class Player { } /** + * Returns the number of lives. + * * @return the number of lives */ public int lives() { @@ -51,6 +53,8 @@ public final class Player { } /** + * Returns the State. + * * @return the state */ public State state() { @@ -58,7 +62,9 @@ public final class Player { } /** - * @return true if the actual state allow to move + * Returns T(this State allows the player to move). + * + * @return T(this State allows the player to move) */ public boolean canMove() { return this.state() == State.INVULNERABLE || this.state() == State.VULNERABLE; @@ -75,21 +81,25 @@ public final class Player { private final Direction direction; /** - * @return an infinite sequence of directed positions corresponding to a stopped player. + * Builds and returns an infinite sequence of directed positions corresponding to a stopped player. + * + * @return the sequence */ public static Sq stopped(DirectedPosition p) { return Sq.constant(p); } /** - * @return an infinite sequence of directed position corresponding to a moving player. + * Builds and returns an infinite sequence of directed position corresponding to a moving player. + * + * @return the sequence */ public static Sq moving(DirectedPosition p) { return Sq.iterate(p, x -> x.withPosition(x.position().neighbor(x.direction()))); } /** - * Instantiates a new DirectedPos + * Instantiates a new DirectedPosition. * * @param position the position of the player * @param direction the direction of the player @@ -101,6 +111,8 @@ public final class Player { } /** + * Returns the position. + * * @return the position */ public SubCell position() { @@ -108,6 +120,8 @@ public final class Player { } /** + * Creates and returns a DirectedPosition with the given SubCell position. + * * @return a new directed position with the given position and the previous direction */ public DirectedPosition withPosition(SubCell newPosition) { @@ -115,6 +129,8 @@ public final class Player { } /** + * Returns the direction. + * * @return the direction */ public Direction direction() { @@ -122,6 +138,8 @@ public final class Player { } /** + * Creates and returns a DirectedPosition with the given Direction. + * * @return a new directed position with the previous position and the given direction */ public DirectedPosition withDirection(Direction newDirection) { @@ -216,6 +234,8 @@ public final class Player { } /** + * Returns the Player's ID. + * * @return the player's ID */ public PlayerID id() { @@ -223,6 +243,8 @@ public final class Player { } /** + * Returns the Player's LifeState sequence. + * * @return the player's life states */ public Sq lifeStates() { @@ -230,7 +252,9 @@ public final class Player { } /** - * @return the sequence related to the player's next life + * Builds and returns the Player's next life LifeState sequence. + * + * @return the sequence related to the Player's next life */ public Sq statesForNextLife() { LifeState dying = new LifeState(lives(), LifeState.State.DYING); @@ -247,12 +271,14 @@ public final class Player { nextLifeState = nextLifeState.concat(Sq.repeat(Ticks.PLAYER_INVULNERABLE_TICKS, invulnerable)); nextLifeState = nextLifeState.concat(Sq.constant(vulnerable)); - } + return nextLifeState; } /** + * Returns the Player's current LifeState. + * * @return the current life state of the player */ public LifeState lifeState() { @@ -260,6 +286,8 @@ public final class Player { } /** + * Returns the Player's vulnerability state. + * * @return the vulnerability state of the player */ public boolean isVulnerable() { @@ -267,6 +295,8 @@ public final class Player { } /** + * Returns the Player's current number of remaining lives. + * * @return the current number of lives of the player */ public int lives() { @@ -274,13 +304,17 @@ public final class Player { } /** - * @return true is the player has more than 0 lives + * Returns T(the player has more than 0 lives) + * + * @return T(the player is alive) */ public boolean isAlive() { return this.lives() > 0; } /** + * Returns the Player's DirectedPosition sequence. + * * @return the directed position sequence of the player */ public Sq directedPositions() { @@ -288,6 +322,8 @@ public final class Player { } /** + * Returns the Player's current position (SubCell). + * * @return the position of the player */ public SubCell position() { @@ -295,6 +331,8 @@ public final class Player { } /** + * Returns the Player's current Direction. + * * @return the current direction of the player */ public Direction direction() { @@ -302,6 +340,8 @@ public final class Player { } /** + * Returns the Player's Bomb limit. + * * @return the maximum number of bombs that the player can use */ public int maxBombs() { @@ -309,6 +349,8 @@ public final class Player { } /** + * Instantiates a new Player with the given Bomb limit. + * * @return a new Player with the new maximum of bombs */ public Player withMaxBombs(int newMaxBombs) { @@ -316,6 +358,8 @@ public final class Player { } /** + * Returns the Player's Bomb range. + * * @return the range of the player's bomb */ public int bombRange() { @@ -323,6 +367,8 @@ public final class Player { } /** + * Instantiates and returns a new Player with the given Bomb range. + * * @return a new Player with the new bomb range */ public Player withBombRange(int newBombRange) { @@ -330,6 +376,8 @@ public final class Player { } /** + * Instantiates and returns a new Bomb for the current Player, registered with its ID, current position and range. + * * @return a new bomb posed by the Player */ public Bomb newBomb() { -- cgit v1.2.3