From 7e3beef9efa53abe448130585aee97c4c9158411 Mon Sep 17 00:00:00 2001 From: Timothée Floure Date: Fri, 15 Apr 2016 14:32:53 +0200 Subject: Comments & fix typos --- src/ch/epfl/xblast/ArgumentChecker.java | 2 +- src/ch/epfl/xblast/Cell.java | 3 ++- src/ch/epfl/xblast/Direction.java | 2 +- src/ch/epfl/xblast/Lists.java | 4 +-- src/ch/epfl/xblast/SubCell.java | 3 ++- src/ch/epfl/xblast/server/Block.java | 8 +++--- src/ch/epfl/xblast/server/Board.java | 14 +++++++--- src/ch/epfl/xblast/server/Bomb.java | 27 +++++++++++++++++++ src/ch/epfl/xblast/server/GameState.java | 14 +++++++++- src/ch/epfl/xblast/server/Player.java | 45 +++++++++++++++++++++++++++++--- 10 files changed, 105 insertions(+), 17 deletions(-) (limited to 'src/ch') diff --git a/src/ch/epfl/xblast/ArgumentChecker.java b/src/ch/epfl/xblast/ArgumentChecker.java index a8ca31a..8ba744e 100644 --- a/src/ch/epfl/xblast/ArgumentChecker.java +++ b/src/ch/epfl/xblast/ArgumentChecker.java @@ -42,7 +42,7 @@ public final class ArgumentChecker { } /** - * Requires the given sequence to be non-empty and returns it or throw an IllegalArgumentException otherwise. + * Requires the given Sequence to be non-empty and returns it or throw an IllegalArgumentException otherwise. * * @param s the sequence to check * @param the sequence type diff --git a/src/ch/epfl/xblast/Cell.java b/src/ch/epfl/xblast/Cell.java index 16632cc..8214066 100644 --- a/src/ch/epfl/xblast/Cell.java +++ b/src/ch/epfl/xblast/Cell.java @@ -28,7 +28,7 @@ public final class Cell { public static final int COUNT = COLUMNS * ROWS; /** - * The list of the board's Cell's, major-ordered. + * The list of the board's Cell-s, major-ordered. */ public static final List ROW_MAJOR_ORDER = Collections.unmodifiableList(rowMajorOrder()); @@ -36,6 +36,7 @@ public final class Cell { * The list of the board's Cell-s, spiral-ordered. */ public static final List SPIRAL_ORDER = Collections.unmodifiableList(spiralOrder()); + /** * The coordinates of the Cell. */ diff --git a/src/ch/epfl/xblast/Direction.java b/src/ch/epfl/xblast/Direction.java index 5f5df33..b8852de 100644 --- a/src/ch/epfl/xblast/Direction.java +++ b/src/ch/epfl/xblast/Direction.java @@ -1,7 +1,7 @@ package ch.epfl.xblast; /** - * A Direction. + * Directions. * * @author Pacien TRAN-GIRARD (261948) * @author Timothée FLOURE (257420) diff --git a/src/ch/epfl/xblast/Lists.java b/src/ch/epfl/xblast/Lists.java index d599776..22d9d06 100644 --- a/src/ch/epfl/xblast/Lists.java +++ b/src/ch/epfl/xblast/Lists.java @@ -34,7 +34,7 @@ public final class Lists { * * @param l the list to reverse * @param the type of the list's elements - * @return a reversed copy of the list. + * @return a reversed copy of the list */ private static List reversed(List l) { List r = new ArrayList<>(l); @@ -70,7 +70,7 @@ public final class Lists { } /** - * Returns all the permutations of the elements of the given list + * Returns all the permutations of the elements of the given list. * * @param l given list * @param the type of the list's elements diff --git a/src/ch/epfl/xblast/SubCell.java b/src/ch/epfl/xblast/SubCell.java index 9585fd2..51cbbb4 100644 --- a/src/ch/epfl/xblast/SubCell.java +++ b/src/ch/epfl/xblast/SubCell.java @@ -27,6 +27,7 @@ public final class SubCell { * The height of the board (total of sub-rows). */ private static final int SUB_ROWS = SUB_ROW_DIVISIONS * Cell.ROWS; + /** * The coordinates of the SubCell. */ @@ -148,7 +149,7 @@ public final class SubCell { /** * Returns a String representation of the coordinates of the SubCell. * - * @return a String representation of the coordinates of the SubCell. + * @return a String representation of the coordinates of the SubCell */ @Override public String toString() { diff --git a/src/ch/epfl/xblast/server/Block.java b/src/ch/epfl/xblast/server/Block.java index 1bfe891..5ada099 100644 --- a/src/ch/epfl/xblast/server/Block.java +++ b/src/ch/epfl/xblast/server/Block.java @@ -3,7 +3,7 @@ package ch.epfl.xblast.server; import java.util.NoSuchElementException; /** - * A Block. + * Blocks. * * @author Pacien TRAN-GIRARD (261948) * @author Timothée FLOURE (257420) @@ -41,19 +41,19 @@ public enum Block { BONUS_RANGE(Bonus.INC_RANGE); /** - * Corresponding bonus, or null + * Corresponding bonus, or null. */ private Bonus maybeAssociatedBonus; /** - * Main builder, used by the bonus blocks + * Main builder, used by the bonus blocks. */ Block(Bonus maybeAssociatedBonus) { this.maybeAssociatedBonus = maybeAssociatedBonus; } /** - * Default builder, used by the non-bonus blocks + * Default builder, used by the non-bonus blocks. */ Block() { this.maybeAssociatedBonus = null; diff --git a/src/ch/epfl/xblast/server/Board.java b/src/ch/epfl/xblast/server/Board.java index 06f3081..a18422a 100644 --- a/src/ch/epfl/xblast/server/Board.java +++ b/src/ch/epfl/xblast/server/Board.java @@ -23,13 +23,21 @@ public final class Board { */ static final int BOMB_BLOCKING_DISTANCE = 6; - private static final int BLOCKS_LIST_SIZE = 195; + /** + * Dimensions of the Board. + */ private static final int BOARD_ROWS = 13; private static final int BOARD_COLUMNS = 15; private static final int INNER_BOARD_ROWS = BOARD_ROWS - 2; private static final int INNER_BOARD_COLUMNS = BOARD_COLUMNS - 2; private static final int QUADRANT_ROWS = 6; private static final int QUADRANT_COLUMNS = 7; + + /** + * Number of blocks of a Board. + */ + private static final int BLOCKS_LIST_SIZE = BOARD_ROWS * BOARD_COLUMNS; + /** * List containing all the blocks of the board. */ @@ -83,7 +91,7 @@ public final class Board { } /** - * Build a walled board filled with the given inner rows + * Build a walled board filled with the given inner rows. * * @param innerBlocks lists of the internal rows * @return a new walled board filled with the given rows @@ -134,7 +142,7 @@ public final class Board { * Return the sequence of blocks related to the given cell. * * @param c cell - * @return the sequence of blocks related to the given cell. + * @return the sequence of blocks related to the given cell */ public Sq blocksAt(Cell c) { return this.blocks.get(c.rowMajorIndex()); diff --git a/src/ch/epfl/xblast/server/Bomb.java b/src/ch/epfl/xblast/server/Bomb.java index 78de111..535573f 100644 --- a/src/ch/epfl/xblast/server/Bomb.java +++ b/src/ch/epfl/xblast/server/Bomb.java @@ -20,11 +20,31 @@ import java.util.stream.Stream; */ public final class Bomb { + /** + * Function consuming a step of the Bomb's fuse. + */ private static final UnaryOperator FUSE_STEP_FUNCTION = fl -> fl - 1; + + /** + * Owner of the Bomb. + */ private PlayerID ownerId; + + /** + * Position of the Bomb. + */ private Cell position; + + /** + * Fuse of the Bomb. + */ private Sq fuseLengths; + + /** + * Range of the Bomb. + */ private int range; + /** * Instantiates a new Bomb. * @@ -69,6 +89,8 @@ public final class Bomb { /** * Generates one arm of explosion. + * + * @param dir the Direction of the arm */ private Sq> explosionArmTowards(Direction dir) { return Sq @@ -132,6 +154,11 @@ public final class Bomb { .collect(Collectors.toList()); } + /** + * Returns a String representation of the parameters of the Bomb. + * + * @return a String representation of the parameters of the Bomb. + */ @Override public String toString() { return "Bomb{" + diff --git a/src/ch/epfl/xblast/server/GameState.java b/src/ch/epfl/xblast/server/GameState.java index 86e596e..44fd5d1 100644 --- a/src/ch/epfl/xblast/server/GameState.java +++ b/src/ch/epfl/xblast/server/GameState.java @@ -37,6 +37,7 @@ public final class GameState { * Pseudo-random source for randomized behaviours. */ private static final Random RANDOM_SOURCE = new Random(GameState.RANDOM_SEED); + private final int ticks; private final Board board; private final List players; @@ -424,6 +425,8 @@ public final class GameState { } /** + * Returns the tick related to the state. + * * @return the tick related to the state. */ public int ticks() { @@ -461,7 +464,7 @@ public final class GameState { } /** - * Return the remaining time. + * Return the remaining game time. * * @return the remaining game time (in seconds) */ @@ -482,6 +485,8 @@ public final class GameState { } /** + * Returns the game board. + * * @return the game board */ public Board board() { @@ -489,6 +494,8 @@ public final class GameState { } /** + * Returns the players. + * * @return the players */ public List players() { @@ -688,6 +695,11 @@ public final class GameState { .collect(Collectors.toSet()); } + /** + * Returns a String representation of the GameState. + * + * @return a String representation of the GameState + */ @Override public String toString() { return "GameState{" + diff --git a/src/ch/epfl/xblast/server/Player.java b/src/ch/epfl/xblast/server/Player.java index fc2508c..2532773 100644 --- a/src/ch/epfl/xblast/server/Player.java +++ b/src/ch/epfl/xblast/server/Player.java @@ -17,11 +17,17 @@ public final class Player { * The default Direction of a new Player. */ private static final Direction DEFAULT_DIRECTION = Direction.S; + private final PlayerID id; private final Sq lifeStates; - private final Sq directedPos; private final int maxBombs; private final int bombRange; + + /** + * The sequence of Directed Positions (= the expected path) of the player. + */ + private final Sq directedPos; + /** * Instantiates a new Player. * @@ -150,7 +156,7 @@ public final class Player { } /** - * Returns T(the player has more than 0 lives) + * Returns T(the player has more than 0 lives). * * @return T(the player is alive) */ @@ -253,8 +259,16 @@ public final class Player { */ public static final class LifeState { + /** + * Remaining lives of the player. + */ private final int lives; + + /** + * State of the player. + */ private final State state; + /** * Instantiates a new LifeSate. * @@ -294,6 +308,11 @@ public final class Player { return this.state; } + /** + * Returns a String representation of the LifeState. + * + * @return a String representation of the LifeState + */ @Override public String toString() { return "LifeState{" + @@ -319,7 +338,14 @@ public final class Player { */ public static final class DirectedPosition { + /** + * Position of the player. + */ private final SubCell position; + + /** + * Direction of the player. + */ private final Direction direction; /** @@ -336,7 +362,7 @@ public final class Player { /** * Builds and returns an infinite sequence of directed positions corresponding to a stopped player. - * + * @param p the infinitely repeated element of the Sequence * @return the sequence */ public static Sq stopped(DirectedPosition p) { @@ -346,6 +372,7 @@ public final class Player { /** * Builds and returns an infinite sequence of directed position corresponding to a moving player. * + * @param p the initial DirectedPosition of Sequence * @return the sequence */ public static Sq moving(DirectedPosition p) { @@ -355,6 +382,7 @@ public final class Player { /** * Creates and returns a DirectedPosition with the given SubCell position. * + * @param newPosition the new position of the player * @return a new directed position with the given position and the previous direction */ public DirectedPosition withPosition(SubCell newPosition) { @@ -382,12 +410,18 @@ public final class Player { /** * Creates and returns a DirectedPosition with the given Direction. * + * @param newDirection the new direction of the player * @return a new directed position with the previous position and the given direction */ public DirectedPosition withDirection(Direction newDirection) { return new DirectedPosition(this.position(), newDirection); } + /** + * Returns a String representation of the Directed Position. + * + * @return a String representation of the Directed Position. + */ @Override public String toString() { return "DirectedPosition{" + @@ -398,6 +432,11 @@ public final class Player { } + /** + * Returns a String representation of the Player. + * + * @return a String representation of the Player + */ @Override public String toString() { return "Player{" + -- cgit v1.2.3